diff --git a/lib/optimize/SplitChunksPlugin.js b/lib/optimize/SplitChunksPlugin.js index 6a19bc58a1e..07102282f54 100644 --- a/lib/optimize/SplitChunksPlugin.js +++ b/lib/optimize/SplitChunksPlugin.js @@ -774,9 +774,13 @@ module.exports = class SplitChunksPlugin { const chunkIndexMap = new Map(); const ZERO = BigInt("0"); const ONE = BigInt("1"); - let index = ONE; + const START = ONE << BigInt("31"); + let index = START; for (const chunk of chunks) { - chunkIndexMap.set(chunk, index); + chunkIndexMap.set( + chunk, + index | BigInt((Math.random() * 0x7fffffff) | 0) + ); index = index << ONE; } /** @@ -793,7 +797,8 @@ module.exports = class SplitChunksPlugin { let key = chunkIndexMap.get(first) | chunkIndexMap.get(result.value); while (!(result = iterator.next()).done) { - key = key | chunkIndexMap.get(result.value); + const raw = chunkIndexMap.get(result.value); + key = key ^ raw; } return key; };