aurelia / loader-webpack

An implementation of Aurelia's loader interface to enable webpack.
MIT License
26 stars 10 forks source link

[Question] No view model found in module "app" #23

Closed dev0x10 closed 7 years ago

dev0x10 commented 7 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: Cannot load app view

Expected/desired behavior:

App view loaded successfully

So, I try to load my Aurelia app inside an iFrame. For Chrome it works fine without any problem but Firefox throwing error "No view model common found in module "app"."

I debug a little bit and end up in this method

WebpackLoader.prototype._import = function _import(moduleId) {
    var _this2 = this;

    if (this.modulesBeingLoaded[moduleId]) {
      return this.modulesBeingLoaded[moduleId];
    }
    var moduleIdParts = moduleId.split('!');
    var path = moduleIdParts.splice(moduleIdParts.length - 1, 1)[0];
    var loaderPlugin = moduleIdParts.length === 1 ? moduleIdParts[0] : null;

    var action = new Promise(function (resolve, reject) {
      if (loaderPlugin) {
        try {
          return resolve(_this2.loaderPlugins[loaderPlugin].fetch(path));
        } catch (e) {
          return reject(e);
        }
      } else {
        try {
          var result = __webpack_require__(path);
          return _this2._getActualResult(result, resolve, reject);
        } catch (_) {
          delete __webpack_require__.c[path];
        }
        require.ensure([], function (require) {
          var result = require('aurelia-loader-context/' + path);
//----------------------------------------------------------
// in here, var result is 'undefined' and path value is 'app'
// Chrome doesn't enter this function
//----------------------------------------------------------
          return _this2._getActualResult(result, resolve, reject);
        }, 'app');
      }
    }).then(function (result) {
      _this2.modulesBeingLoaded[moduleId] = undefined;
      return result;
    });
    this.modulesBeingLoaded[moduleId] = action;
    return action;
  };

If the page loaded outside iFrame, there is no problem at all.

niieani commented 7 years ago

The new, experimental Webpack-Aurelia stack should fix this. Will be available soon.

dev0x10 commented 7 years ago

@niieani could you tell me where is the problem because I haven't debug it deeper. Is there any workaround?

niieani commented 7 years ago

Fixed by https://github.com/aurelia/skeleton-navigation/pull/714