2.50
Circular dependencies in Babel's AMD output
StealJS will hand an empty module {}
to a module with circular dependencies while the body of said module is executed.
Babel adds a little helper so non ES6 modules work when imported using the ES6 syntax
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
When empty modules {}
are passed to this function, they are wrapped with a default
property which makes non-ES6 modules work fine, but it causes a nested default
property in circular dependencies that are late bound.
This release of transpile adds a little helper to modules flagged as circular to make sure there are no nested default
properties in the module. Each variable holding the module reference returned by _interopRequireDefault
is given a setter to fix the default
reference.
function _patchCircularDependency(obj) {
var defaultExport;
Object.defineProperty(obj.default, 'default', {
set: function (value) {
if (obj.default.__esModule) {
obj.default = value;
}
defaultExport = value;
},
get: function () {
return defaultExport;
}
});