Skip to content

Commit

Permalink
use buildInfo instead of hash for cacheUnaffected
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 5, 2021
1 parent 4c68833 commit f05246e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
let statChanged = 0;
let statUnchanged = 0;
let statReferencesChanged = 0;
let statWithoutHash = 0;
let statWithoutBuild = 0;

const computeReferences = module => {
/** @type {WeakMap<Dependency, Module>} */
Expand Down Expand Up @@ -2216,14 +2216,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
const modulesWithoutCache = new Set(modules);
for (const [module, cachedMemCache] of moduleMemCacheCache) {
if (modulesWithoutCache.has(module)) {
const hash = module.buildInfo && module.buildInfo.hash;
if (typeof hash === "string") {
if (cachedMemCache.hash !== hash) {
const buildInfo = module.buildInfo;
if (buildInfo) {
if (cachedMemCache.buildInfo !== buildInfo) {
// use a new one
const memCache = new WeakTupleMap();
moduleMemCaches.set(module, memCache);
affectedModules.add(module);
cachedMemCache.hash = hash;
cachedMemCache.buildInfo = buildInfo;
cachedMemCache.references = computeReferences(module);
cachedMemCache.memCache = memCache;
statChanged++;
Expand All @@ -2243,7 +2243,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
} else {
infectedModules.add(module);
moduleMemCacheCache.delete(module);
statWithoutHash++;
statWithoutBuild++;
}
modulesWithoutCache.delete(module);
} else {
Expand All @@ -2252,12 +2252,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
}

for (const module of modulesWithoutCache) {
const hash = module.buildInfo && module.buildInfo.hash;
if (typeof hash === "string") {
const buildInfo = module.buildInfo && module.buildInfo.buildInfo;
if (buildInfo) {
// create a new entry
const memCache = new WeakTupleMap();
moduleMemCacheCache.set(module, {
hash: hash,
buildInfo,
references: computeReferences(module),
memCache
});
Expand All @@ -2266,7 +2266,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
statNew++;
} else {
infectedModules.add(module);
statWithoutHash++;
statWithoutBuild++;
}
}

Expand Down Expand Up @@ -2330,7 +2330,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
infectedModules.size
} infected of ${
this.modules.size
}) modules flagged as affected (${statNew} new modules, ${statChanged} changed, ${statReferencesChanged} references changed, ${statUnchanged} unchanged, ${statWithoutHash} without hash)`
}) modules flagged as affected (${statNew} new modules, ${statChanged} changed, ${statReferencesChanged} references changed, ${statUnchanged} unchanged, ${statWithoutBuild} were not built)`
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class Compiler {

this.cache = new Cache();

/** @type {Map<Module, { hash: string, references: WeakMap<Dependency, Module>, memCache: WeakTupleMap }> | undefined} */
/** @type {Map<Module, { buildInfo: object, references: WeakMap<Dependency, Module>, memCache: WeakTupleMap }> | undefined} */
this.moduleMemCaches = undefined;

this.compilerPath = "";
Expand Down
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ declare class Compiler {
moduleMemCaches?: Map<
Module,
{
hash: string;
buildInfo: object;
references: WeakMap<Dependency, Module>;
memCache: WeakTupleMap<any, any>;
}
Expand Down

0 comments on commit f05246e

Please sign in to comment.