@depup/webpack 5.109.0-depup.0 → 5.109.2-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/webpack.js +12 -0
- package/changes.json +4 -4
- package/lib/ChunkGraph.js +17 -15
- package/lib/CleanPlugin.js +11 -9
- package/lib/CompatibilityPlugin.js +31 -0
- package/lib/Compilation.js +21 -5
- package/lib/Compiler.js +16 -4
- package/lib/DefinePlugin.js +47 -20
- package/lib/ExportsInfo.js +22 -5
- package/lib/ExternalModule.js +10 -7
- package/lib/FileSystemInfo.js +126 -26
- package/lib/FlagDependencyUsagePlugin.js +33 -12
- package/lib/InitFragment.js +20 -32
- package/lib/ModuleFilenameHelpers.js +13 -2
- package/lib/NormalModule.js +80 -71
- package/lib/NormalModuleFactory.js +8 -2
- package/lib/RuntimePlugin.js +40 -113
- package/lib/Template.js +23 -3
- package/lib/cache/PackFileCacheStrategy.js +259 -5
- package/lib/config/defaults.js +21 -2
- package/lib/container/HoistContainerReferencesPlugin.js +47 -55
- package/lib/container/ModuleFederationPlugin.js +15 -9
- package/lib/css/CssGenerator.js +8 -2
- package/lib/css/CssLoadingRuntimeModule.js +25 -12
- package/lib/css/CssModulesPlugin.js +29 -18
- package/lib/css/CssParser.js +135 -50
- package/lib/css/syntax.js +862 -765
- package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +33 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +17 -9
- package/lib/dependencies/HarmonyImportDependency.js +1 -1
- package/lib/dependencies/HarmonyImportGuard.js +2 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -7
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -9
- package/lib/hmr/lazyCompilationBackend.js +19 -4
- package/lib/html/HtmlGenerator.js +23 -3
- package/lib/html/HtmlModulesPlugin.js +30 -12
- package/lib/html/syntax.js +2485 -2399
- package/lib/ids/IdHelpers.js +24 -10
- package/lib/javascript/JavascriptModulesPlugin.js +83 -49
- package/lib/javascript/JavascriptParser.js +49 -13
- package/lib/javascript/syntax.js +700 -43
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +10 -2
- package/lib/optimize/AggressiveMergingPlugin.js +19 -15
- package/lib/optimize/ConcatenatedModule.js +19 -15
- package/lib/optimize/ModuleConcatenationPlugin.js +73 -24
- package/lib/optimize/RealContentHashPlugin.js +10 -7
- package/lib/optimize/SplitChunksPlugin.js +146 -44
- package/lib/prefetch/ResourceHintPlugin.js +96 -72
- package/lib/serialization/BinaryMiddleware.js +270 -938
- package/lib/serialization/FileMiddleware.js +299 -60
- package/lib/stats/DefaultStatsFactoryPlugin.js +204 -198
- package/lib/stats/DefaultStatsPrinterPlugin.js +24 -166
- package/lib/stats/StatsFactory.js +31 -9
- package/lib/util/identifier.js +21 -1
- package/package.json +10 -10
- package/schemas/WebpackOptions.json +110 -55
- package/types.d.ts +832 -247
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/webpack
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [webpack](https://www.npmjs.com/package/webpack) @ 5.109.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [webpack](https://www.npmjs.com/package/webpack) @ 5.109.2 |
|
|
17
|
+
| Processed | 2026-08-02 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 9 |
|
|
20
20
|
|
|
@@ -23,10 +23,10 @@ npm install @depup/webpack
|
|
|
23
23
|
| Dependency | From | To |
|
|
24
24
|
|------------|------|-----|
|
|
25
25
|
| @types/estree | ^1.0.8 | ^1.0.9 |
|
|
26
|
-
| acorn | ^8.16.0 | ^8.
|
|
26
|
+
| acorn | ^8.16.0 | ^8.18.0 |
|
|
27
27
|
| browserslist | ^4.28.1 | ^4.28.7 |
|
|
28
28
|
| chrome-trace-event | ^1.0.2 | ^1.0.4 |
|
|
29
|
-
| enhanced-resolve | ^5.24.
|
|
29
|
+
| enhanced-resolve | ^5.24.4 | ^5.24.5 |
|
|
30
30
|
| es-module-lexer | ^2.1.0 | ^2.3.1 |
|
|
31
31
|
| eslint-scope | 5.1.1 | ^9.1.2 |
|
|
32
32
|
| events | ^3.2.0 | ^3.3.0 |
|
package/bin/webpack.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
|
+
// Cache compiled module bytecode on disk (available since Node.js 22.8)
|
|
6
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
7
|
+
const { enableCompileCache } = require("module");
|
|
8
|
+
|
|
9
|
+
if (enableCompileCache) {
|
|
10
|
+
try {
|
|
11
|
+
enableCompileCache();
|
|
12
|
+
} catch (_error) {
|
|
13
|
+
// Nothing
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* @param {string} command process to run
|
|
7
19
|
* @param {string[]} args command line arguments
|
package/changes.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
},
|
|
7
7
|
"acorn": {
|
|
8
8
|
"from": "^8.16.0",
|
|
9
|
-
"to": "^8.
|
|
9
|
+
"to": "^8.18.0"
|
|
10
10
|
},
|
|
11
11
|
"browserslist": {
|
|
12
12
|
"from": "^4.28.1",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"to": "^1.0.4"
|
|
18
18
|
},
|
|
19
19
|
"enhanced-resolve": {
|
|
20
|
-
"from": "^5.24.
|
|
21
|
-
"to": "^5.24.
|
|
20
|
+
"from": "^5.24.4",
|
|
21
|
+
"to": "^5.24.5"
|
|
22
22
|
},
|
|
23
23
|
"es-module-lexer": {
|
|
24
24
|
"from": "^2.1.0",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"to": "^2.3.3"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"timestamp": "2026-
|
|
40
|
+
"timestamp": "2026-08-02T00:59:09.770Z",
|
|
41
41
|
"totalUpdated": 9
|
|
42
42
|
}
|
package/lib/ChunkGraph.js
CHANGED
|
@@ -52,6 +52,19 @@ const EMPTY_SET = new Set();
|
|
|
52
52
|
|
|
53
53
|
const ZERO_BIG_INT = BigInt(0);
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Active state to string. Module-level (depends only on ModuleGraphConnection)
|
|
57
|
+
* so it isn't re-allocated on every getModuleGraphHash call, incl. cache hits.
|
|
58
|
+
* @param {ConnectionState} state state
|
|
59
|
+
* @returns {"F" | "T" | "O"} result
|
|
60
|
+
*/
|
|
61
|
+
const activeStateToString = (state) => {
|
|
62
|
+
if (state === false) return "F";
|
|
63
|
+
if (state === true) return "T";
|
|
64
|
+
if (state === ModuleGraphConnection.TRANSITIVE_ONLY) return "O";
|
|
65
|
+
throw new Error("Not implemented active state");
|
|
66
|
+
};
|
|
67
|
+
|
|
55
68
|
const compareModuleIterables = compareIterables(compareModulesByIdentifier);
|
|
56
69
|
|
|
57
70
|
/** @typedef {(c: Chunk, chunkGraph: ChunkGraph) => boolean} ChunkFilterPredicate */
|
|
@@ -1821,22 +1834,11 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1821
1834
|
cgm.graphHashesWithConnections = new RuntimeSpecMap();
|
|
1822
1835
|
}
|
|
1823
1836
|
|
|
1824
|
-
/**
|
|
1825
|
-
* Active state to string.
|
|
1826
|
-
* @param {ConnectionState} state state
|
|
1827
|
-
* @returns {"F" | "T" | "O"} result
|
|
1828
|
-
*/
|
|
1829
|
-
const activeStateToString = (state) => {
|
|
1830
|
-
if (state === false) return "F";
|
|
1831
|
-
if (state === true) return "T";
|
|
1832
|
-
if (state === ModuleGraphConnection.TRANSITIVE_ONLY) return "O";
|
|
1833
|
-
throw new Error("Not implemented active state");
|
|
1834
|
-
};
|
|
1835
|
-
const strict =
|
|
1836
|
-
module.buildMeta &&
|
|
1837
|
-
/** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
|
|
1838
|
-
.strictHarmonyModule;
|
|
1839
1837
|
return cgm.graphHashesWithConnections.provide(runtime, () => {
|
|
1838
|
+
const strict =
|
|
1839
|
+
module.buildMeta &&
|
|
1840
|
+
/** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
|
|
1841
|
+
.strictHarmonyModule;
|
|
1840
1842
|
const graphHash = this._getModuleGraphHashBigInt(
|
|
1841
1843
|
cgm,
|
|
1842
1844
|
module,
|
package/lib/CleanPlugin.js
CHANGED
|
@@ -22,10 +22,17 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
22
22
|
|
|
23
23
|
/** @typedef {Map<string, number>} Assets */
|
|
24
24
|
|
|
25
|
+
const createCompilationHooks = () => ({
|
|
26
|
+
/**
|
|
27
|
+
* When returning true the file/directory will be kept during cleaning, returning false will clean it and ignore the following plugins and config.
|
|
28
|
+
* @type {SyncBailHook<[string], boolean | void>}
|
|
29
|
+
* @since 5.20.0
|
|
30
|
+
*/
|
|
31
|
+
keep: new SyncBailHook(["ignore"])
|
|
32
|
+
});
|
|
33
|
+
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @typedef {object} CleanPluginCompilationHooks
|
|
28
|
-
* @property {SyncBailHook<[string], boolean | void>} keep when returning true the file/directory will be kept during cleaning, returning false will clean it and ignore the following plugins and config
|
|
35
|
+
* @typedef {ReturnType<typeof createCompilationHooks>} CleanPluginCompilationHooks
|
|
29
36
|
*/
|
|
30
37
|
|
|
31
38
|
/**
|
|
@@ -484,12 +491,7 @@ class CleanPlugin {
|
|
|
484
491
|
}
|
|
485
492
|
}
|
|
486
493
|
|
|
487
|
-
CleanPlugin.getCompilationHooks = createHooksRegistry(
|
|
488
|
-
() =>
|
|
489
|
-
/** @type {CleanPluginCompilationHooks} */ ({
|
|
490
|
-
keep: new SyncBailHook(["ignore"])
|
|
491
|
-
})
|
|
492
|
-
);
|
|
494
|
+
CleanPlugin.getCompilationHooks = createHooksRegistry(createCompilationHooks);
|
|
493
495
|
|
|
494
496
|
module.exports = CleanPlugin;
|
|
495
497
|
module.exports._getDirectories = getDirectories;
|
|
@@ -181,6 +181,37 @@ class CompatibilityPlugin {
|
|
|
181
181
|
});
|
|
182
182
|
return true;
|
|
183
183
|
});
|
|
184
|
+
// `const`/`let` are block-pre-walked, by which point the name is no
|
|
185
|
+
// longer free and `hooks.pattern` is not dispatched for it — tag
|
|
186
|
+
// them through the kind-specific declaration hooks instead.
|
|
187
|
+
// Returning nothing lets the variable be defined, keeping the tag.
|
|
188
|
+
for (const hookMap of [
|
|
189
|
+
parser.hooks.varDeclarationConst,
|
|
190
|
+
parser.hooks.varDeclarationLet
|
|
191
|
+
]) {
|
|
192
|
+
hookMap.for(RuntimeGlobals.require).tap(PLUGIN_NAME, (ident) => {
|
|
193
|
+
parser.tagVariable(ident.name, nestedWebpackIdentifierTag, {
|
|
194
|
+
name: `__nested_webpack_require_${
|
|
195
|
+
/** @type {Range} */ (ident.range)[0]
|
|
196
|
+
}__`,
|
|
197
|
+
declaration: {
|
|
198
|
+
updated: false,
|
|
199
|
+
loc: parser.getLocation(ident),
|
|
200
|
+
range: /** @type {Range} */ (ident.range)
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
hookMap.for(RuntimeGlobals.exports).tap(PLUGIN_NAME, (ident) => {
|
|
205
|
+
parser.tagVariable(ident.name, nestedWebpackIdentifierTag, {
|
|
206
|
+
name: "__nested_webpack_exports__",
|
|
207
|
+
declaration: {
|
|
208
|
+
updated: false,
|
|
209
|
+
loc: parser.getLocation(ident),
|
|
210
|
+
range: /** @type {Range} */ (ident.range)
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
184
215
|
// Update single `var __webpack_require__ = {};` and `var __webpack_exports__ = {};` without expression
|
|
185
216
|
parser.hooks.declarator.tap(PLUGIN_NAME, (declarator) => {
|
|
186
217
|
if (
|
package/lib/Compilation.js
CHANGED
|
@@ -884,9 +884,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
884
884
|
"runtime"
|
|
885
885
|
]),
|
|
886
886
|
|
|
887
|
-
/**
|
|
887
|
+
/**
|
|
888
|
+
* @type {SyncHook<[ExecuteModuleArgument, ExecuteModuleContext]>}
|
|
889
|
+
* @since 5.32.0
|
|
890
|
+
*/
|
|
888
891
|
executeModule: new SyncHook(["options", "context"]),
|
|
889
|
-
/**
|
|
892
|
+
/**
|
|
893
|
+
* @type {AsyncParallelHook<[ExecuteModuleArgument, ExecuteModuleContext]>}
|
|
894
|
+
* @since 5.33.0
|
|
895
|
+
*/
|
|
890
896
|
prepareModuleExecution: new AsyncParallelHook(["options", "context"]),
|
|
891
897
|
|
|
892
898
|
/** @type {AsyncSeriesHook<[Iterable<Module>]>} */
|
|
@@ -1090,7 +1096,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1090
1096
|
|
|
1091
1097
|
processAssets: processAssetsHook,
|
|
1092
1098
|
afterProcessAssets: afterProcessAssetsHook,
|
|
1093
|
-
/**
|
|
1099
|
+
/**
|
|
1100
|
+
* @type {AsyncSeriesHook<[CompilationAssets]>}
|
|
1101
|
+
* @since 5.8.0
|
|
1102
|
+
*/
|
|
1094
1103
|
processAdditionalAssets: new AsyncSeriesHook(["assets"]),
|
|
1095
1104
|
|
|
1096
1105
|
/** @type {SyncBailHook<[], boolean | void>} */
|
|
@@ -3504,6 +3513,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3504
3513
|
this.addModuleQueue.clear();
|
|
3505
3514
|
// lazy barrel only acts during make; release its bookkeeping now
|
|
3506
3515
|
this._lazyBarrelController.clear();
|
|
3516
|
+
// unsafe-cache restore tables are only read during make; release them
|
|
3517
|
+
// so they stop pinning restored modules for the rest of the compilation
|
|
3518
|
+
this._restoredUnsafeCacheModuleEntries.clear();
|
|
3519
|
+
this._restoredUnsafeCacheEntries.clear();
|
|
3507
3520
|
return callback(err);
|
|
3508
3521
|
};
|
|
3509
3522
|
|
|
@@ -4754,10 +4767,13 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4754
4767
|
for (const module of this.modules) {
|
|
4755
4768
|
const memCache = moduleMemCaches2 && moduleMemCaches2.get(module);
|
|
4756
4769
|
for (const runtime of chunkGraph.getModuleRuntimes(module)) {
|
|
4770
|
+
const cacheKey = memCache
|
|
4771
|
+
? `moduleHash-${getRuntimeKey(runtime)}`
|
|
4772
|
+
: undefined;
|
|
4757
4773
|
if (memCache) {
|
|
4758
4774
|
const digest =
|
|
4759
4775
|
/** @type {string} */
|
|
4760
|
-
(memCache.get(
|
|
4776
|
+
(memCache.get(/** @type {string} */ (cacheKey)));
|
|
4761
4777
|
if (digest !== undefined) {
|
|
4762
4778
|
chunkGraph.setModuleHashes(
|
|
4763
4779
|
module,
|
|
@@ -4781,7 +4797,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4781
4797
|
errors
|
|
4782
4798
|
);
|
|
4783
4799
|
if (memCache) {
|
|
4784
|
-
memCache.set(
|
|
4800
|
+
memCache.set(/** @type {string} */ (cacheKey), digest);
|
|
4785
4801
|
}
|
|
4786
4802
|
}
|
|
4787
4803
|
}
|
package/lib/Compiler.js
CHANGED
|
@@ -222,9 +222,15 @@ class Compiler {
|
|
|
222
222
|
/** @type {AsyncSeriesHook<[Compilation]>} */
|
|
223
223
|
afterCompile: new AsyncSeriesHook(["compilation"]),
|
|
224
224
|
|
|
225
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* @type {AsyncSeriesHook<[]>}
|
|
227
|
+
* @since 5.67.0
|
|
228
|
+
*/
|
|
226
229
|
readRecords: new AsyncSeriesHook([]),
|
|
227
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* @type {AsyncSeriesHook<[]>}
|
|
232
|
+
* @since 5.67.0
|
|
233
|
+
*/
|
|
228
234
|
emitRecords: new AsyncSeriesHook([]),
|
|
229
235
|
|
|
230
236
|
/** @type {AsyncSeriesHook<[Compiler]>} */
|
|
@@ -235,7 +241,10 @@ class Compiler {
|
|
|
235
241
|
invalid: new SyncHook(["filename", "changeTime"]),
|
|
236
242
|
/** @type {SyncHook<[]>} */
|
|
237
243
|
watchClose: new SyncHook([]),
|
|
238
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* @type {AsyncSeriesHook<[]>}
|
|
246
|
+
* @since 5.17.0
|
|
247
|
+
*/
|
|
239
248
|
shutdown: new AsyncSeriesHook([]),
|
|
240
249
|
|
|
241
250
|
/** @type {SyncBailHook<[string, string, EXPECTED_ANY[] | undefined], true | void>} */
|
|
@@ -243,7 +252,10 @@ class Compiler {
|
|
|
243
252
|
|
|
244
253
|
// TODO the following hooks are weirdly located here
|
|
245
254
|
// TODO move them for webpack 5
|
|
246
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* @type {SyncHook<[]>}
|
|
257
|
+
* @since 5.106.0
|
|
258
|
+
*/
|
|
247
259
|
validate: new SyncHook([]),
|
|
248
260
|
/** @type {SyncHook<[]>} */
|
|
249
261
|
environment: new SyncHook([]),
|
package/lib/DefinePlugin.js
CHANGED
|
@@ -628,10 +628,36 @@ const getRuntimeRequirements = (code) => {
|
|
|
628
628
|
: [RuntimeGlobals.requireScope];
|
|
629
629
|
};
|
|
630
630
|
|
|
631
|
+
const createCompilationHooks = () => ({
|
|
632
|
+
/**
|
|
633
|
+
* @type {SyncWaterfallHook<[Record<string, CodeValue>]>}
|
|
634
|
+
* @since 5.104.0
|
|
635
|
+
*/
|
|
636
|
+
definitions: new SyncWaterfallHook(["definitions"])
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Prefixes an evaluation error with the offending define key so a bare
|
|
641
|
+
* "Unexpected token" becomes actionable. The original error is mutated and
|
|
642
|
+
* returned (not re-wrapped) so its `loc`/`stack` survive for ModuleParseError's
|
|
643
|
+
* code frame instead of being dumped into the message.
|
|
644
|
+
* @param {string} key the defined key
|
|
645
|
+
* @param {CodeValue} code the defined value
|
|
646
|
+
* @param {unknown} error the original evaluation error
|
|
647
|
+
* @returns {Error} the annotated error
|
|
648
|
+
*/
|
|
649
|
+
const annotateEvaluationError = (key, code, error) => {
|
|
650
|
+
const value = typeof code === "string" ? code : JSON.stringify(code);
|
|
651
|
+
const prefix = `DefinePlugin: failed to evaluate value for "${key}" (\`${value}\`)`;
|
|
652
|
+
if (error instanceof Error) {
|
|
653
|
+
error.message = `${prefix}: ${error.message}`;
|
|
654
|
+
return error;
|
|
655
|
+
}
|
|
656
|
+
return new WebpackError(`${prefix}: ${error}`);
|
|
657
|
+
};
|
|
658
|
+
|
|
631
659
|
/**
|
|
632
|
-
*
|
|
633
|
-
* @typedef {object} DefinePluginHooks
|
|
634
|
-
* @property {SyncWaterfallHook<[Record<string, CodeValue>]>} definitions
|
|
660
|
+
* @typedef {ReturnType<typeof createCompilationHooks>} DefinePluginHooks
|
|
635
661
|
*/
|
|
636
662
|
|
|
637
663
|
/** @typedef {Record<string, CodeValue>} Definitions */
|
|
@@ -954,17 +980,23 @@ class DefinePlugin {
|
|
|
954
980
|
});
|
|
955
981
|
parser.hooks.typeof.for(key).tap(PLUGIN_NAME, (expr) => {
|
|
956
982
|
addValueDependency(originalKey);
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
983
|
+
/** @type {BasicEvaluatedExpression} */
|
|
984
|
+
let res;
|
|
985
|
+
try {
|
|
986
|
+
const codeCode = toCode(
|
|
987
|
+
code,
|
|
988
|
+
parser,
|
|
989
|
+
compilation.valueCacheVersions,
|
|
990
|
+
originalKey,
|
|
991
|
+
runtimeTemplate,
|
|
992
|
+
logger,
|
|
993
|
+
null
|
|
994
|
+
);
|
|
995
|
+
const typeofCode = isTypeof ? codeCode : `typeof (${codeCode})`;
|
|
996
|
+
res = parser.evaluate(typeofCode);
|
|
997
|
+
} catch (err) {
|
|
998
|
+
throw annotateEvaluationError(originalKey, code, err);
|
|
999
|
+
}
|
|
968
1000
|
if (!res.isString()) return;
|
|
969
1001
|
return toConstantDependency(
|
|
970
1002
|
parser,
|
|
@@ -1233,12 +1265,7 @@ class DefinePlugin {
|
|
|
1233
1265
|
}
|
|
1234
1266
|
}
|
|
1235
1267
|
|
|
1236
|
-
DefinePlugin.getCompilationHooks = createHooksRegistry(
|
|
1237
|
-
() =>
|
|
1238
|
-
/** @type {DefinePluginHooks} */ ({
|
|
1239
|
-
definitions: new SyncWaterfallHook(["definitions"])
|
|
1240
|
-
})
|
|
1241
|
-
);
|
|
1268
|
+
DefinePlugin.getCompilationHooks = createHooksRegistry(createCompilationHooks);
|
|
1242
1269
|
|
|
1243
1270
|
module.exports = DefinePlugin;
|
|
1244
1271
|
module.exports.VALUE_DEP_MAIN = VALUE_DEP_MAIN;
|
package/lib/ExportsInfo.js
CHANGED
|
@@ -66,6 +66,11 @@ const UsageState = Object.freeze({
|
|
|
66
66
|
|
|
67
67
|
const RETURNS_TRUE = () => true;
|
|
68
68
|
|
|
69
|
+
// Shared empty visited-set for `findTarget`: `_findTarget` only reads
|
|
70
|
+
// `alreadyVisited` (`.has`), never mutates it, so a fresh `new Set()` per call
|
|
71
|
+
// is pure churn on the per-export reexport hot path. Must stay never-mutated.
|
|
72
|
+
const EMPTY_VISITED = /** @type {Set<ExportInfo>} */ (new Set());
|
|
73
|
+
|
|
69
74
|
const CIRCULAR = Symbol("circular target");
|
|
70
75
|
|
|
71
76
|
// bit layout of ExportInfo._inlineFlags
|
|
@@ -1399,12 +1404,16 @@ class ExportInfo {
|
|
|
1399
1404
|
* @returns {boolean} true, if something has changed
|
|
1400
1405
|
*/
|
|
1401
1406
|
setTarget(key, connection, exportName, priority = 0) {
|
|
1402
|
-
|
|
1407
|
+
// `equals` compares element-wise, so the incoming `exportName` can be used
|
|
1408
|
+
// directly for the change-check; only copy it when actually stored, so the
|
|
1409
|
+
// common no-op (unchanged target) path allocates nothing.
|
|
1403
1410
|
if (!this._target) {
|
|
1404
1411
|
this._target = /** @type {Target} */ (new Map());
|
|
1405
1412
|
this._target.set(key, {
|
|
1406
1413
|
connection,
|
|
1407
|
-
export: /** @type {ExportInfoName[]} */ (
|
|
1414
|
+
export: /** @type {ExportInfoName[]} */ (
|
|
1415
|
+
exportName ? [...exportName] : exportName
|
|
1416
|
+
),
|
|
1408
1417
|
priority
|
|
1409
1418
|
});
|
|
1410
1419
|
return true;
|
|
@@ -1414,7 +1423,9 @@ class ExportInfo {
|
|
|
1414
1423
|
if (oldTarget === null && !connection) return false;
|
|
1415
1424
|
this._target.set(key, {
|
|
1416
1425
|
connection,
|
|
1417
|
-
export: /** @type {ExportInfoName[]} */ (
|
|
1426
|
+
export: /** @type {ExportInfoName[]} */ (
|
|
1427
|
+
exportName ? [...exportName] : exportName
|
|
1428
|
+
),
|
|
1418
1429
|
priority
|
|
1419
1430
|
});
|
|
1420
1431
|
this._maxTarget = undefined;
|
|
@@ -1428,7 +1439,9 @@ class ExportInfo {
|
|
|
1428
1439
|
: oldTarget.export)
|
|
1429
1440
|
) {
|
|
1430
1441
|
oldTarget.connection = connection;
|
|
1431
|
-
oldTarget.export = /** @type {ExportInfoName[]} */ (
|
|
1442
|
+
oldTarget.export = /** @type {ExportInfoName[]} */ (
|
|
1443
|
+
exportName ? [...exportName] : exportName
|
|
1444
|
+
);
|
|
1432
1445
|
oldTarget.priority = priority;
|
|
1433
1446
|
this._maxTarget = undefined;
|
|
1434
1447
|
return true;
|
|
@@ -1578,7 +1591,11 @@ class ExportInfo {
|
|
|
1578
1591
|
* @returns {TargetItemWithoutConnection | null | undefined | false} the target, undefined when there is no target, false when no target is valid
|
|
1579
1592
|
*/
|
|
1580
1593
|
findTarget(moduleGraph, validTargetModuleFilter) {
|
|
1581
|
-
return this._findTarget(
|
|
1594
|
+
return this._findTarget(
|
|
1595
|
+
moduleGraph,
|
|
1596
|
+
validTargetModuleFilter,
|
|
1597
|
+
EMPTY_VISITED
|
|
1598
|
+
);
|
|
1582
1599
|
}
|
|
1583
1600
|
|
|
1584
1601
|
/**
|
package/lib/ExternalModule.js
CHANGED
|
@@ -810,10 +810,16 @@ const getSourceForDefaultCase = (optional, request, runtimeTemplate) => {
|
|
|
810
810
|
/** @typedef {Record<string, string | string[]>} RequestRecord */
|
|
811
811
|
/** @typedef {string | string[] | RequestRecord} ExternalModuleRequest */
|
|
812
812
|
|
|
813
|
+
const createCompilationHooks = () => ({
|
|
814
|
+
/**
|
|
815
|
+
* @type {SyncBailHook<[Chunk, Compilation], boolean>}
|
|
816
|
+
* @since 5.106.0
|
|
817
|
+
*/
|
|
818
|
+
chunkCondition: new SyncBailHook(["chunk", "compilation"])
|
|
819
|
+
});
|
|
820
|
+
|
|
813
821
|
/**
|
|
814
|
-
*
|
|
815
|
-
* @typedef {object} ExternalModuleHooks
|
|
816
|
-
* @property {SyncBailHook<[Chunk, Compilation], boolean>} chunkCondition
|
|
822
|
+
* @typedef {ReturnType<typeof createCompilationHooks>} ExternalModuleHooks
|
|
817
823
|
*/
|
|
818
824
|
|
|
819
825
|
/**
|
|
@@ -1486,10 +1492,7 @@ class ExternalModule extends Module {
|
|
|
1486
1492
|
}
|
|
1487
1493
|
|
|
1488
1494
|
ExternalModule.getCompilationHooks = createHooksRegistry(
|
|
1489
|
-
|
|
1490
|
-
/** @type {ExternalModuleHooks} */ ({
|
|
1491
|
-
chunkCondition: new SyncBailHook(["chunk", "compilation"])
|
|
1492
|
-
})
|
|
1495
|
+
createCompilationHooks
|
|
1493
1496
|
);
|
|
1494
1497
|
|
|
1495
1498
|
makeSerializable(ExternalModule, "webpack/lib/ExternalModule");
|