Skip to content

Commit 7564bdf

Browse files
author
Jarand Millett
committed
Fix sorting of undefined moduleIndex
1 parent 30b89d0 commit 7564bdf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,12 @@ class MiniCssExtractPlugin {
387387
// with different order this can lead to wrong order
388388
// but it's not possible to create a correct order in
389389
// this case. Don't share chunks if you don't like it.
390+
391+
390392
const [chunkGroup] = chunk.groupsIterable;
391393
if (typeof chunkGroup.getModuleIndex2 === 'function') {
392394
modules.sort(
393-
(a, b) => chunkGroup.getModuleIndex2(a) - chunkGroup.getModuleIndex2(b)
395+
(a, b) => (chunkGroup.getModuleIndex2(a) || 0) < (chunkGroup.getModuleIndex2(b) || 0) ? 1 : -1
394396
);
395397
} else {
396398
// fallback for older webpack versions

0 commit comments

Comments
 (0)