From 07ad896f7aedee7d32e8247323b54b759b7637e5 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 5 Oct 2021 20:14:21 +0200 Subject: [PATCH] bugfix cacheUnaffected --- lib/Compilation.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Compilation.js b/lib/Compilation.js index 6dd4d1acf..74b858ec8 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -2252,7 +2252,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si } for (const module of modulesWithoutCache) { - const buildInfo = module.buildInfo && module.buildInfo.buildInfo; + const buildInfo = module.buildInfo; if (buildInfo) { // create a new entry const memCache = new WeakTupleMap(); @@ -2340,6 +2340,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si const moduleMemCaches2 = (this.moduleMemCaches2 = new Map()); const { moduleGraph, chunkGraph } = this; const key = "memCache2"; + let statUnchanged = 0; + let statChanged = 0; + let statNew = 0; /** * @param {Module} module module * @returns {{ modules?: Map, blocks?: (string | number)[] }} references @@ -2354,7 +2357,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si for (const m of outgoing.keys()) { if (!m) continue; if (modules === undefined) modules = new Map(); - modules.set(m, chunkGraph.getModuleId(module)); + modules.set(m, chunkGraph.getModuleId(m)); } } if (module.blocks.length > 0) { @@ -2416,15 +2419,24 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si memCache: memCache2 }); moduleMemCaches2.set(module, memCache2); + statNew++; } else if (!compareReferences(module, cache.references)) { const memCache = new WeakTupleMap(); cache.references = computeReferences(module); cache.memCache = memCache; moduleMemCaches2.set(module, memCache); + statChanged++; } else { moduleMemCaches2.set(module, cache.memCache); + statUnchanged++; } } + + this.logger.log( + `${Math.round( + (100 * statChanged) / (statNew + statChanged + statUnchanged) + )}% modules flagged as affected by chunk graph (${statNew} new modules, ${statChanged} changed, ${statUnchanged} unchanged)` + ); } finish(callback) {