Skip to content

Commit 6c6e48c

Browse files
committed
avoid RuntimeSpecMap in favor of directly setting on memCache
1 parent a82ab66 commit 6c6e48c

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

lib/Compilation.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const {
7878
createFakeHook
7979
} = require("./util/deprecation");
8080
const processAsyncTree = require("./util/processAsyncTree");
81-
const { getRuntimeKey, RuntimeSpecMap } = require("./util/runtime");
81+
const { getRuntimeKey } = require("./util/runtime");
8282
const { isSourceEqual } = require("./util/source");
8383

8484
/** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
@@ -3095,16 +3095,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
30953095
// modules with async blocks depend on the chunk graph and can't be cached that way
30963096
module.blocks.length === 0 &&
30973097
moduleMemCaches.get(module);
3098-
/** @type {RuntimeSpecMap<Set<string>>} */
3099-
const moduleRuntimeRequirementsMemCache =
3100-
memCache &&
3101-
memCache.provide(
3102-
"moduleRuntimeRequirements",
3103-
() => new RuntimeSpecMap()
3104-
);
31053098
for (const runtime of chunkGraph.getModuleRuntimes(module)) {
3106-
if (moduleRuntimeRequirementsMemCache) {
3107-
const cached = moduleRuntimeRequirementsMemCache.get(runtime);
3099+
if (memCache) {
3100+
const cached = memCache.get(
3101+
`moduleRuntimeRequirements-${getRuntimeKey(runtime)}`
3102+
);
31083103
if (cached !== undefined) {
31093104
if (cached !== null) {
31103105
chunkGraph.addModuleRuntimeRequirements(
@@ -3125,8 +3120,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
31253120
} else if (additionalModuleRuntimeRequirements.isUsed()) {
31263121
set = new Set();
31273122
} else {
3128-
if (moduleRuntimeRequirementsMemCache) {
3129-
moduleRuntimeRequirementsMemCache.set(runtime, null);
3123+
if (memCache) {
3124+
memCache.set(
3125+
`moduleRuntimeRequirements-${getRuntimeKey(runtime)}`,
3126+
null
3127+
);
31303128
}
31313129
continue;
31323130
}
@@ -3137,12 +3135,18 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
31373135
if (hook !== undefined) hook.call(module, set, context);
31383136
}
31393137
if (set.size === 0) {
3140-
if (moduleRuntimeRequirementsMemCache) {
3141-
moduleRuntimeRequirementsMemCache.set(runtime, null);
3138+
if (memCache) {
3139+
memCache.set(
3140+
`moduleRuntimeRequirements-${getRuntimeKey(runtime)}`,
3141+
null
3142+
);
31423143
}
31433144
} else {
3144-
if (moduleRuntimeRequirementsMemCache) {
3145-
moduleRuntimeRequirementsMemCache.set(runtime, set);
3145+
if (memCache) {
3146+
memCache.set(
3147+
`moduleRuntimeRequirements-${getRuntimeKey(runtime)}`,
3148+
set
3149+
);
31463150
chunkGraph.addModuleRuntimeRequirements(
31473151
module,
31483152
runtime,
@@ -3555,13 +3559,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
35553559
// modules with async blocks depend on the chunk graph and can't be cached that way
35563560
module.blocks.length === 0 &&
35573561
moduleMemCaches.get(module);
3558-
/** @type {RuntimeSpecMap<string>} */
3559-
const moduleHashesMemCache =
3560-
memCache &&
3561-
memCache.provide("moduleHashes", () => new RuntimeSpecMap());
35623562
for (const runtime of chunkGraph.getModuleRuntimes(module)) {
3563-
if (moduleHashesMemCache) {
3564-
const digest = moduleHashesMemCache.get(runtime);
3563+
if (memCache) {
3564+
const digest = memCache.get(`moduleHash-${getRuntimeKey(runtime)}`);
35653565
if (digest !== undefined) {
35663566
chunkGraph.setModuleHashes(
35673567
module,
@@ -3583,8 +3583,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
35833583
hashDigest,
35843584
hashDigestLength
35853585
);
3586-
if (moduleHashesMemCache) {
3587-
moduleHashesMemCache.set(runtime, digest);
3586+
if (memCache) {
3587+
memCache.set(`moduleHash-${getRuntimeKey(runtime)}`, digest);
35883588
}
35893589
}
35903590
}

0 commit comments

Comments
 (0)