Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
__useDefault as backup default store for default overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 26, 2017
1 parent e48b2d9 commit ad8ca7d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/register-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ function instantiate (loader, load, link, registry, state) {

// process System.registerDynamic declaration
if (registration[2]) {
link.moduleObj.default = {};
link.moduleObj.__useDefault = true;
link.moduleObj.default = link.moduleObj.__useDefault = {};
link.executingRequire = registration[1];
link.execute = registration[2];
}
Expand Down Expand Up @@ -561,7 +560,7 @@ function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations
else
module = ensureEvaluate(loader, depLoad, depLoad.linkRecord, registry, state, seen);

return module.__useDefault ? module.default : module;
return module.__useDefault || module;
}
}
throw new Error('Module ' + name + ' not declared as a System.registerDynamic dependency of ' + key);
Expand Down Expand Up @@ -616,10 +615,10 @@ function doEvaluate (loader, load, link, registry, state, seen) {
Object.defineProperty(module, 'exports', {
configurable: true,
set: function (exports) {
moduleObj.default = exports;
moduleObj.default = moduleObj.__useDefault = exports;
},
get: function () {
return moduleObj.default;
return moduleObj.__useDefault;
}
});

Expand All @@ -634,7 +633,7 @@ function doEvaluate (loader, load, link, registry, state, seen) {

// pick up defineProperty calls to module.exports when we can
if (module.exports !== moduleObj.default)
moduleObj.default = module.exports;
moduleObj.default = moduleObj.__useDefault = module.exports;

var moduleDefault = moduleObj.default;

Expand Down

0 comments on commit ad8ca7d

Please sign in to comment.