From 3fa83c6c77de88b9874ecd06322ada787b90ac25 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 12 Oct 2021 09:49:48 +0200 Subject: [PATCH] help v8 hashing the bigint --- lib/optimize/SplitChunksPlugin.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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; };