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

Implement bulk export variation #387

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dist/es6-module-loader-dev.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/es6-module-loader-dev.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions dist/es6-module-loader-sans-promises.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/es6-module-loader-sans-promises.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion dist/es6-module-loader.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es6-module-loader.js.map

Large diffs are not rendered by default.

2,336 changes: 324 additions & 2,012 deletions dist/es6-module-loader.src.js

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions src/declarative.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,24 @@
// By disaling this module write-protection we gain performance.
// It could be useful to allow an option to enable or disable this.
module.locked = true;
moduleObj[name] = value;

// export({name: value})
if (typeof name == 'object') {
for (var p in name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need a hasOwnProperty check here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if we expect to run in environments with Object.prototype extended with enumerable properties.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about export(new MyObject), that has enumerable properties on its prototype. Won't this then copy those over to the module? I'm not to sure it will only receive plain objects, is all.

(If you extend Object.prototype I feel you should be on your own)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is defined to take instances of Object only from transpiler outputs and is independent of user code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically - Object or Module.

moduleObj[p] = name[p];
}
// export(name, value)
else {
moduleObj[name] = value;
}

for (var i = 0, l = module.importers.length; i < l; i++) {
var importerModule = module.importers[i];
if (!importerModule.locked) {
for (var j = 0; j < importerModule.dependencies.length; ++j) {
if (importerModule.dependencies[j] === module) {
importerModule.setters[j](moduleObj);
}
for (var j = 0; j < importerModule.dependencies.length; ++j) {
if (importerModule.dependencies[j] === module) {
importerModule.setters[j](moduleObj);
}
}
}
}
Expand Down