Merge pull request #14413 from webpack/bugfix/cache-unaffected

bugfix cacheUnaffected
This commit is contained in:
Tobias Koppers 2021-10-05 20:19:38 +02:00 committed by GitHub
commit 48c3d290c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -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<Module, string | number | undefined>, 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) {