Skip to content

Commit

Permalink
fix unstable sorting of ChunkGroups and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Apr 17, 2018
1 parent 205ca62 commit 8e2e19b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Chunk.js
Expand Up @@ -389,7 +389,7 @@ class Chunk {
const cmp = b.order - a.order;
if (cmp !== 0) return cmp;
// TOOD webpack 5 remove this check of compareTo
if (a.compareTo) return a.compareTo(b);
if (a.group.compareTo) return a.group.compareTo(b.group);
return 0;
});
result[name] = Array.from(
Expand Down
2 changes: 1 addition & 1 deletion lib/ChunkGroup.js
Expand Up @@ -349,7 +349,7 @@ class ChunkGroup {
const cmp = b.order - a.order;
if (cmp !== 0) return cmp;
// TOOD webpack 5 remove this check of compareTo
if (a.compareTo) return a.compareTo(b);
if (a.group.compareTo) return a.group.compareTo(b.group);
return 0;
});
result[name] = list.map(i => i.group);
Expand Down
4 changes: 2 additions & 2 deletions test/statsCases/prefetch-preload-mixed/expected.txt
@@ -1,7 +1,7 @@
chunk {0} a.js (a) 136 bytes <{3}> >{10}< >{9}< (prefetch: {10} {9}) [rendered]
chunk {0} a.js (a) 136 bytes <{3}> >{10}< >{9}< (prefetch: {9} {10}) [rendered]
chunk {1} b.js (b) 203 bytes <{3}> >{6}< >{7}< >{8}< (prefetch: {6} {8}) (preload: {7}) [rendered]
chunk {2} c.js (c) 134 bytes <{3}> >{4}< >{5}< (preload: {4} {5}) [rendered]
chunk {3} main.js (main) 126 bytes >{0}< >{1}< >{2}< [entry] [rendered]
chunk {3} main.js (main) 195 bytes >{0}< >{1}< >{2}< (prefetch: {0} {1} {2}) [entry] [rendered]
chunk {4} c1.js (c1) 0 bytes <{2}> [rendered]
chunk {5} c2.js (c2) 0 bytes <{2}> [rendered]
chunk {6} b1.js (b1) 0 bytes <{1}> [rendered]
Expand Down
6 changes: 3 additions & 3 deletions test/statsCases/prefetch-preload-mixed/index.js
@@ -1,3 +1,3 @@
import(/* webpackChunkName: "a" */"./a");
import(/* webpackChunkName: "b" */"./b");
import(/* webpackChunkName: "c" */"./c");
import(/* webpackPrefetch: true, webpackChunkName: "a" */"./a");
import(/* webpackPrefetch: true, webpackChunkName: "b" */"./b");
import(/* webpackPrefetch: true, webpackChunkName: "c" */"./c");

0 comments on commit 8e2e19b

Please sign in to comment.