Skip to content

Commit

Permalink
Merge pull request #14413 from webpack/bugfix/cache-unaffected
Browse files Browse the repository at this point in the history
bugfix cacheUnaffected
  • Loading branch information
sokra committed Oct 5, 2021
2 parents e841ab0 + 07ad896 commit 48c3d29
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 48c3d29

Please sign in to comment.