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

Commit c503866

Browse files
committed
correction to groupIndex algorithm
1 parent f9a0319 commit c503866

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,20 @@ function logloads(loads) {
607607
// otherwise it is the same as the parent
608608
var loadDepGroupIndex = load.groupIndex + (loadDep.kind != load.kind);
609609

610-
if (loadDep.groupIndex === undefined) {
610+
// the group index of an entry is always the maximum
611+
if (loadDep.groupIndex === undefined || loadDep.groupIndex < loadDepGroupIndex) {
612+
613+
// if already in a group, remove from the old group
614+
if (loadDep.groupIndex) {
615+
groups[loadDep.groupIndex].splice(groups[loadDep.groupIndex].indexOf(loadDep), 1);
616+
617+
// if the old group is empty, then we have a mixed depndency cycle
618+
if (groups[loadDep.groupIndex].length == 0)
619+
throw new TypeError("Mixed dependency cycle detected");
620+
}
621+
611622
loadDep.groupIndex = loadDepGroupIndex;
612623
}
613-
else if (loadDep.groupIndex != loadDepGroupIndex) {
614-
// if the dependency already has a group index
615-
// a groupIndex inconsistency implies a mixed dependency cycle
616-
throw new TypeError('Mixed dependency cycle detected.');
617-
}
618624

619625
buildLinkageGroups(loadDep, loads, groups, loader);
620626
}

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: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,14 +1291,20 @@ function logloads(loads) {
12911291
// otherwise it is the same as the parent
12921292
var loadDepGroupIndex = load.groupIndex + (loadDep.kind != load.kind);
12931293

1294-
if (loadDep.groupIndex === undefined) {
1294+
// the group index of an entry is always the maximum
1295+
if (loadDep.groupIndex === undefined || loadDep.groupIndex < loadDepGroupIndex) {
1296+
1297+
// if already in a group, remove from the old group
1298+
if (loadDep.groupIndex) {
1299+
groups[loadDep.groupIndex].splice(groups[loadDep.groupIndex].indexOf(loadDep), 1);
1300+
1301+
// if the old group is empty, then we have a mixed depndency cycle
1302+
if (groups[loadDep.groupIndex].length == 0)
1303+
throw new TypeError("Mixed dependency cycle detected");
1304+
}
1305+
12951306
loadDep.groupIndex = loadDepGroupIndex;
12961307
}
1297-
else if (loadDep.groupIndex != loadDepGroupIndex) {
1298-
// if the dependency already has a group index
1299-
// a groupIndex inconsistency implies a mixed dependency cycle
1300-
throw new TypeError('Mixed dependency cycle detected.');
1301-
}
13021308

13031309
buildLinkageGroups(loadDep, loads, groups, loader);
13041310
}

0 commit comments

Comments
 (0)