diff --git a/src/app.js b/src/app.js index 73f2c21cd8..6e29c7ed52 100644 --- a/src/app.js +++ b/src/app.js @@ -201,14 +201,18 @@ function run () { if (provider && provider.exists(url)) { return provider.get(url, cb) } - handleImports.import(url, (error, content, cleanUrl, type, url) => { - if (!error) { - filesProviders[type].addReadOnly(cleanUrl, content, url) - cb(null, content) - } else { - cb(error) + handleImports.import(url, + (loadingMsg) => { + $('#output').append($('
').append($('
').text(loadingMsg)))
       }
-    })
+      (error, content, cleanUrl, type, url) => {
+        if (!error) {
+          filesProviders[type].addReadOnly(cleanUrl, content, url)
+          cb(null, content)
+        } else {
+          cb(error)
+        }
+      })
   })
   var offsetToLineColumnConverter = new OffsetToLineColumnConverter(compiler.event)
 
diff --git a/src/app/compiler/compiler-imports.js b/src/app/compiler/compiler-imports.js
index a6162cb972..48251e395c 100644
--- a/src/app/compiler/compiler-imports.js
+++ b/src/app/compiler/compiler-imports.js
@@ -48,7 +48,7 @@ module.exports = {
     ]
   },
 
-  import: function (url, cb) {
+  import: function (url, loadingCb, cb) {
     var handlers = this.handlers()
 
     var found = false
@@ -61,8 +61,7 @@ module.exports = {
       if (match) {
         found = true
 
-        // TODO: this needs to be moved to the caller
-        $('#output').append($('
').append($('
').text('Loading ' + url + ' ...')))
+        loadingCb('Loading ' + url + ' ...')
         handler.handler(match, function (err, content, cleanUrl) {
           if (err) {
             cb('Unable to import "' + cleanUrl + '": ' + err)