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

Commit 45c474b

Browse files
committed
remove support for named exports from dynamic modules
1 parent a9e5478 commit 45c474b

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

core/register-loader.js

-30
Original file line numberDiff line numberDiff line change
@@ -301,32 +301,6 @@ function traceLoad (loader, load, link) {
301301
*
302302
* Sets the default value to the module, while also reading off named exports carefully.
303303
*/
304-
305-
// NB re-evaluate if this will even exist, and if it should be restricted to valid identifiers only
306-
function copyNamedExports (exports, moduleObj) {
307-
if ((typeof exports === 'object' || typeof exports === 'function') && exports !== global) {
308-
var props = Object.getOwnPropertyNames(exports);
309-
for (var i = 0; i < props.length; i++)
310-
defineOrCopyProperty(moduleObj, exports, props[i]);
311-
}
312-
moduleObj.default = exports;
313-
}
314-
315-
function defineOrCopyProperty (targetObj, sourceObj, propName) {
316-
// don't trigger getters/setters in environments that support them
317-
try {
318-
var d;
319-
if (d = Object.getOwnPropertyDescriptor(sourceObj, propName)) {
320-
// only copy data descriptors
321-
if (d.value)
322-
targetObj[propName] = d.value;
323-
}
324-
}
325-
catch (e) {
326-
// Object.getOwnPropertyDescriptor threw an exception -> not own property
327-
}
328-
}
329-
330304
function registerDeclarative (loader, load, link, declare) {
331305
var moduleObj = link.moduleObj;
332306
var importerSetters = load.importerSetters;
@@ -640,10 +614,6 @@ function doEvaluate (loader, load, link, registry, state, seen) {
640614
module.exports,
641615
module
642616
]);
643-
644-
// copy module.exports onto the module object
645-
if (!err)
646-
copyNamedExports(module.exports, moduleObj);
647617
}
648618
}
649619

test/3-register-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ describe('System Register Loader', function() {
227227
it('should load a System.registerDynamic module', async function () {
228228
var m = await loader.import('./dynamic-modules/basic-exports.js');
229229
assert.equal(m.default(), 'ok');
230-
assert.equal(m.named, 'name!');
230+
assert.equal(m.default.named, 'name!');
231231
});
232232

233233
it('should load mixed bundles of register and registerDynamic', async function () {

0 commit comments

Comments
 (0)