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

Commit ec44a82

Browse files
committed
fix data-init function
1 parent e92b654 commit ec44a82

File tree

5 files changed

+40
-19
lines changed

5 files changed

+40
-19
lines changed

dist/es6-module-loader-sans-promises.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ function logloads(loads) {
652652
if (!module || !(module instanceof Module))
653653
throw new TypeError('Execution must define a Module instance');
654654
load.module = {
655+
name: load.name,
655656
module: module
656657
};
657658
load.status = 'linked';
@@ -736,8 +737,12 @@ function logloads(loads) {
736737

737738
// only declarative modules have dynamic bindings
738739
if (depModule.importers) {
739-
depModule.importers.push(module);
740740
module.dependencies.push(depModule);
741+
depModule.importers.push(module);
742+
}
743+
else {
744+
// track dynamic records as null module records as already linked
745+
module.dependencies.push(null);
741746
}
742747

743748
// run the setter for this dependency
@@ -801,6 +806,10 @@ function logloads(loads) {
801806

802807
for (var i = 0, l = deps.length; i < l; i++) {
803808
var dep = deps[i];
809+
// dynamic dependencies are empty in module.dependencies
810+
// as they are already linked
811+
if (!dep)
812+
continue;
804813
if (indexOf.call(seen, dep) == -1) {
805814
err = ensureEvaluated(dep, seen, loader);
806815
// stop on error, see https://bugs.ecmascript.org/show_bug.cgi?id=2996
@@ -1337,6 +1346,12 @@ function logloads(loads) {
13371346
}
13381347
System.paths = { '*': '*.js' };
13391348

1349+
// note we have to export before runing "init" below
1350+
if (typeof exports === 'object')
1351+
module.exports = System;
1352+
1353+
global.System = System;
1354+
13401355
// <script type="module"> support
13411356
// allow a data-init function callback once loaded
13421357
if (isBrowser) {
@@ -1375,9 +1390,4 @@ function logloads(loads) {
13751390
window[curScript.getAttribute('data-init')]();
13761391
}
13771392

1378-
if (typeof exports === 'object')
1379-
module.exports = System;
1380-
1381-
global.System = System;
1382-
13831393
})(typeof global !== 'undefined' ? global : this);

dist/es6-module-loader-sans-promises.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,7 @@ function logloads(loads) {
18261826
if (!module || !(module instanceof Module))
18271827
throw new TypeError('Execution must define a Module instance');
18281828
load.module = {
1829+
name: load.name,
18291830
module: module
18301831
};
18311832
load.status = 'linked';
@@ -1910,8 +1911,12 @@ function logloads(loads) {
19101911

19111912
// only declarative modules have dynamic bindings
19121913
if (depModule.importers) {
1913-
depModule.importers.push(module);
19141914
module.dependencies.push(depModule);
1915+
depModule.importers.push(module);
1916+
}
1917+
else {
1918+
// track dynamic records as null module records as already linked
1919+
module.dependencies.push(null);
19151920
}
19161921

19171922
// run the setter for this dependency
@@ -1975,6 +1980,10 @@ function logloads(loads) {
19751980

19761981
for (var i = 0, l = deps.length; i < l; i++) {
19771982
var dep = deps[i];
1983+
// dynamic dependencies are empty in module.dependencies
1984+
// as they are already linked
1985+
if (!dep)
1986+
continue;
19781987
if (indexOf.call(seen, dep) == -1) {
19791988
err = ensureEvaluated(dep, seen, loader);
19801989
// stop on error, see https://bugs.ecmascript.org/show_bug.cgi?id=2996
@@ -2511,6 +2520,12 @@ function logloads(loads) {
25112520
}
25122521
System.paths = { '*': '*.js' };
25132522

2523+
// note we have to export before runing "init" below
2524+
if (typeof exports === 'object')
2525+
module.exports = System;
2526+
2527+
global.System = System;
2528+
25142529
// <script type="module"> support
25152530
// allow a data-init function callback once loaded
25162531
if (isBrowser) {
@@ -2549,9 +2564,4 @@ function logloads(loads) {
25492564
window[curScript.getAttribute('data-init')]();
25502565
}
25512566

2552-
if (typeof exports === 'object')
2553-
module.exports = System;
2554-
2555-
global.System = System;
2556-
25572567
})(typeof global !== 'undefined' ? global : this);

dist/es6-module-loader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/system.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@
221221
}
222222
System.paths = { '*': '*.js' };
223223

224+
// note we have to export before runing "init" below
225+
if (typeof exports === 'object')
226+
module.exports = System;
227+
228+
global.System = System;
229+
224230
// <script type="module"> support
225231
// allow a data-init function callback once loaded
226232
if (isBrowser) {
@@ -259,9 +265,4 @@
259265
window[curScript.getAttribute('data-init')]();
260266
}
261267

262-
if (typeof exports === 'object')
263-
module.exports = System;
264-
265-
global.System = System;
266-
267268
})(typeof global !== 'undefined' ? global : this);

0 commit comments

Comments
 (0)