Skip to content

Commit 8e2e19b

Browse files
committed
fix unstable sorting of ChunkGroups and add test
1 parent 205ca62 commit 8e2e19b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/Chunk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class Chunk {
389389
const cmp = b.order - a.order;
390390
if (cmp !== 0) return cmp;
391391
// TOOD webpack 5 remove this check of compareTo
392-
if (a.compareTo) return a.compareTo(b);
392+
if (a.group.compareTo) return a.group.compareTo(b.group);
393393
return 0;
394394
});
395395
result[name] = Array.from(

lib/ChunkGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class ChunkGroup {
349349
const cmp = b.order - a.order;
350350
if (cmp !== 0) return cmp;
351351
// TOOD webpack 5 remove this check of compareTo
352-
if (a.compareTo) return a.compareTo(b);
352+
if (a.group.compareTo) return a.group.compareTo(b.group);
353353
return 0;
354354
});
355355
result[name] = list.map(i => i.group);

test/statsCases/prefetch-preload-mixed/expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
chunk {0} a.js (a) 136 bytes <{3}> >{10}< >{9}< (prefetch: {10} {9}) [rendered]
1+
chunk {0} a.js (a) 136 bytes <{3}> >{10}< >{9}< (prefetch: {9} {10}) [rendered]
22
chunk {1} b.js (b) 203 bytes <{3}> >{6}< >{7}< >{8}< (prefetch: {6} {8}) (preload: {7}) [rendered]
33
chunk {2} c.js (c) 134 bytes <{3}> >{4}< >{5}< (preload: {4} {5}) [rendered]
4-
chunk {3} main.js (main) 126 bytes >{0}< >{1}< >{2}< [entry] [rendered]
4+
chunk {3} main.js (main) 195 bytes >{0}< >{1}< >{2}< (prefetch: {0} {1} {2}) [entry] [rendered]
55
chunk {4} c1.js (c1) 0 bytes <{2}> [rendered]
66
chunk {5} c2.js (c2) 0 bytes <{2}> [rendered]
77
chunk {6} b1.js (b1) 0 bytes <{1}> [rendered]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import(/* webpackChunkName: "a" */"./a");
2-
import(/* webpackChunkName: "b" */"./b");
3-
import(/* webpackChunkName: "c" */"./c");
1+
import(/* webpackPrefetch: true, webpackChunkName: "a" */"./a");
2+
import(/* webpackPrefetch: true, webpackChunkName: "b" */"./b");
3+
import(/* webpackPrefetch: true, webpackChunkName: "c" */"./c");

0 commit comments

Comments
 (0)