From 8e2e19ba50b1d84710cd6b56b85705ee230a86da Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 17 Apr 2018 09:36:26 +0200 Subject: [PATCH] fix unstable sorting of ChunkGroups and add test --- lib/Chunk.js | 2 +- lib/ChunkGroup.js | 2 +- test/statsCases/prefetch-preload-mixed/expected.txt | 4 ++-- test/statsCases/prefetch-preload-mixed/index.js | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Chunk.js b/lib/Chunk.js index 8015636f8a4..4e88ad223cc 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -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( diff --git a/lib/ChunkGroup.js b/lib/ChunkGroup.js index 1665babd052..23b2c219c75 100644 --- a/lib/ChunkGroup.js +++ b/lib/ChunkGroup.js @@ -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); diff --git a/test/statsCases/prefetch-preload-mixed/expected.txt b/test/statsCases/prefetch-preload-mixed/expected.txt index cb56866134d..55597681b9f 100644 --- a/test/statsCases/prefetch-preload-mixed/expected.txt +++ b/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] diff --git a/test/statsCases/prefetch-preload-mixed/index.js b/test/statsCases/prefetch-preload-mixed/index.js index f5d96c450d7..a1bb65b54b3 100644 --- a/test/statsCases/prefetch-preload-mixed/index.js +++ b/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");