webpack 5.108.4 → 5.109.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/lib/APIPlugin.js +48 -29
- package/lib/CacheFacade.js +8 -0
- package/lib/ChunkGroup.js +1 -0
- package/lib/CompatibilityPlugin.js +31 -29
- package/lib/Compilation.js +49 -4
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextModule.js +239 -6
- package/lib/ContextModuleFactory.js +139 -14
- package/lib/DefinePlugin.js +396 -101
- package/lib/Entrypoint.js +1 -1
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +107 -5
- package/lib/ExternalModuleFactoryPlugin.js +20 -1
- package/lib/FileSystemInfo.js +130 -74
- package/lib/HotModuleReplacementPlugin.js +18 -15
- package/lib/Module.js +3 -0
- package/lib/ModuleFilenameHelpers.js +2 -2
- package/lib/ModuleTypeConstants.js +8 -1
- package/lib/MultiCompiler.js +13 -2
- package/lib/MultiWatching.js +1 -0
- package/lib/NodeStuffPlugin.js +51 -33
- package/lib/NormalModule.js +169 -401
- package/lib/NormalModuleFactory.js +76 -2
- package/lib/ProgressPlugin.js +211 -119
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RuntimeGlobals.js +47 -0
- package/lib/RuntimePlugin.js +33 -0
- package/lib/RuntimeTemplate.js +304 -16
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +24 -19
- package/lib/asset/AssetGenerator.js +110 -28
- package/lib/asset/AssetModulesPlugin.js +92 -2
- package/lib/asset/WebManifestGenerator.js +164 -0
- package/lib/asset/WebManifestParser.js +130 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +14 -4
- package/lib/async-modules/isGeneratorLowered.js +26 -0
- package/lib/cache/PackFileCacheStrategy.js +9 -3
- package/lib/config/browserslistTargetHandler.js +40 -0
- package/lib/config/defaults.js +219 -29
- package/lib/config/normalization.js +26 -0
- package/lib/config/target.js +9 -1
- package/lib/css/CssGenerator.js +40 -31
- package/lib/css/CssLoadingRuntimeModule.js +5 -1
- package/lib/css/CssModulesPlugin.js +13 -0
- package/lib/css/CssParser.js +594 -263
- package/lib/css/syntax.js +875 -462
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -6
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +13 -13
- package/lib/dependencies/CommonJsDependencyHelpers.js +39 -0
- package/lib/dependencies/CommonJsExportsDependency.js +47 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +10 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +18 -18
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/CommonJsRequireDependency.js +26 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +32 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CreateRequireParserPlugin.js +6 -6
- package/lib/dependencies/CssIcssExportDependency.js +162 -71
- package/lib/dependencies/CssUrlDependency.js +35 -4
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -2
- package/lib/dependencies/HarmonyCompatibilityDependency.js +32 -14
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +43 -13
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +7 -19
- package/lib/dependencies/HarmonyImportDependency.js +12 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +11 -11
- package/lib/dependencies/HarmonyModulesPlugin.js +6 -0
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/HtmlEntryDependency.js +797 -172
- package/lib/dependencies/HtmlSourceDependency.js +26 -0
- package/lib/dependencies/ImportDependency.js +43 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +31 -18
- package/lib/dependencies/ImportMetaContextPlugin.js +38 -7
- package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
- package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
- package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
- package/lib/dependencies/ImportMetaPlugin.js +532 -180
- package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
- package/lib/dependencies/ImportParserPlugin.js +80 -17
- package/lib/dependencies/ImportPhase.js +10 -8
- package/lib/dependencies/LoaderPlugin.js +5 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -11
- package/lib/dependencies/SystemPlugin.js +2 -4
- package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
- package/lib/dependencies/URLDependency.js +141 -21
- package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +324 -112
- package/lib/dependencies/WorkerDependency.js +86 -18
- package/lib/dependencies/WorkletDependency.js +278 -0
- package/lib/dll/DelegatedModuleFactoryPlugin.js +19 -0
- package/lib/errors/EnvironmentNotSupportAsyncWarning.js +1 -1
- package/lib/errors/LoaderLoadingError.js +20 -0
- package/lib/errors/ModuleParseError.js +39 -22
- package/lib/errors/NodeStuffInWebError.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +47 -14
- package/lib/esm/ModuleChunkLoadingPlugin.js +8 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +29 -1
- package/lib/hmr/lazyCompilationBackend.js +32 -8
- package/lib/html/HtmlGenerator.js +887 -15
- package/lib/html/HtmlModule.js +2 -2
- package/lib/html/HtmlModulesPlugin.js +610 -166
- package/lib/html/HtmlParser.js +603 -247
- package/lib/html/favicon.svg +1 -0
- package/lib/html/syntax.js +1264 -661
- package/lib/ids/IdHelpers.js +1 -1
- package/lib/index.js +6 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
- package/lib/javascript/BasicEvaluatedExpression.js +366 -48
- package/lib/javascript/JavascriptGenerator.js +197 -49
- package/lib/javascript/JavascriptModulesPlugin.js +178 -24
- package/lib/javascript/JavascriptParser.js +701 -355
- package/lib/javascript/JavascriptParserHelpers.js +3 -6
- package/lib/javascript/syntax.js +4380 -0
- package/lib/library/ModuleLibraryPlugin.js +38 -1
- package/lib/loaders/LoaderRunner.js +714 -0
- package/lib/loaders/loadLoader.js +100 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +19 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +14 -0
- package/lib/optimize/ConcatenatedModule.js +120 -16
- package/lib/optimize/FlagIncludedChunksPlugin.js +13 -3
- package/lib/optimize/InnerGraphPlugin.js +50 -30
- package/lib/optimize/ModuleConcatenationPlugin.js +69 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +86 -43
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +15 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +24 -13
- package/lib/prefetch/ResourceHintPlugin.js +663 -0
- package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
- package/lib/prefetch/parseResourceHintOptions.js +103 -0
- package/lib/rules/RuleSetCompiler.js +114 -0
- package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +24 -8
- package/lib/runtime/AutoPublicPathRuntimeModule.js +7 -1
- package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +204 -8
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +4 -1
- package/lib/schemes/HttpUriPlugin.js +40 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -2
- package/lib/serialization/FileMiddleware.js +29 -3
- package/lib/stats/DefaultStatsFactoryPlugin.js +32 -3
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -2
- package/lib/stats/StatsFactory.js +15 -8
- package/lib/url/URLParserPlugin.js +66 -13
- package/lib/util/AsyncQueue.js +122 -72
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/StackedMap.js +122 -48
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/concatenate.js +40 -14
- package/lib/util/createHooksRegistry.js +13 -5
- package/lib/util/dataURL.js +2 -2
- package/lib/util/deterministicGrouping.js +7 -5
- package/lib/util/formatSize.js +6 -2
- package/lib/util/globUtils.js +710 -0
- package/lib/util/identifier.js +23 -6
- package/lib/util/implicitTypeLoaderFallback.js +62 -0
- package/lib/util/internalSerializables.js +88 -71
- package/lib/util/magicComment.js +121 -25
- package/lib/util/numberHash.js +2 -2
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +24 -18
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +33 -22
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +79 -16
- package/lib/web/FetchCompileAsyncWasmPlugin.js +19 -0
- package/lib/web/FetchCompileWasmPlugin.js +14 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -0
- package/lib/webpack.js +65 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -0
- package/module.d.ts +21 -0
- package/package.json +13 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +759 -36
- package/schemas/plugins/HtmlParserOptions.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +17 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1213 -96
package/lib/APIPlugin.js
CHANGED
|
@@ -31,9 +31,22 @@ const GetFullHashRuntimeModule = require("./runtime/GetFullHashRuntimeModule");
|
|
|
31
31
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
32
32
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
33
33
|
/** @typedef {import("./javascript/JavascriptModule").JavascriptModuleBuildInfo} JavascriptModuleBuildInfo */
|
|
34
|
+
/** @typedef {import("./Compilation")} Compilation */
|
|
34
35
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
35
36
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
36
37
|
|
|
38
|
+
// Compilations where a module reassigns `__webpack_public_path__` at runtime.
|
|
39
|
+
// A baked analyzable specifier can't reflect that, so those forms fall back.
|
|
40
|
+
/** @type {WeakSet<Compilation>} */
|
|
41
|
+
const runtimePublicPathOverride = new WeakSet();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {Compilation} compilation compilation
|
|
45
|
+
* @returns {boolean} true when a module reassigns `__webpack_public_path__` at runtime
|
|
46
|
+
*/
|
|
47
|
+
const usesRuntimePublicPathOverride = (compilation) =>
|
|
48
|
+
runtimePublicPathOverride.has(compilation);
|
|
49
|
+
|
|
37
50
|
/**
|
|
38
51
|
* Returns the replacement definitions used for webpack API identifiers.
|
|
39
52
|
* @returns {Record<string, { expr: string, req: string[] | null, type?: string, assign: boolean }>} replacements
|
|
@@ -225,27 +238,28 @@ class APIPlugin {
|
|
|
225
238
|
}
|
|
226
239
|
});
|
|
227
240
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
) {
|
|
243
|
-
/** @type {BuildInfo} */
|
|
244
|
-
(parser.state.module.buildInfo).moduleArgument =
|
|
245
|
-
"__webpack_module__";
|
|
246
|
-
}
|
|
241
|
+
/**
|
|
242
|
+
* @param {import("estree").Statement | import("estree").ModuleDeclaration | import("estree").MaybeNamedFunctionDeclaration | import("estree").MaybeNamedClassDeclaration} statement statement
|
|
243
|
+
*/
|
|
244
|
+
const moduleDeclarationHandler = (statement) => {
|
|
245
|
+
if (
|
|
246
|
+
parser.scope.topLevelScope === true &&
|
|
247
|
+
(statement.type === "FunctionDeclaration" ||
|
|
248
|
+
statement.type === "ClassDeclaration") &&
|
|
249
|
+
statement.id &&
|
|
250
|
+
statement.id.name === "module"
|
|
251
|
+
) {
|
|
252
|
+
/** @type {BuildInfo} */
|
|
253
|
+
(parser.state.module.buildInfo).moduleArgument =
|
|
254
|
+
"__webpack_module__";
|
|
247
255
|
}
|
|
248
|
-
}
|
|
256
|
+
};
|
|
257
|
+
parser.hooks.preStatementByType
|
|
258
|
+
.for("FunctionDeclaration")
|
|
259
|
+
.tap(PLUGIN_NAME, moduleDeclarationHandler);
|
|
260
|
+
parser.hooks.preStatementByType
|
|
261
|
+
.for("ClassDeclaration")
|
|
262
|
+
.tap(PLUGIN_NAME, moduleDeclarationHandler);
|
|
249
263
|
|
|
250
264
|
for (const key of Object.keys(REPLACEMENTS)) {
|
|
251
265
|
const info = REPLACEMENTS[key];
|
|
@@ -260,9 +274,7 @@ class APIPlugin {
|
|
|
260
274
|
const warning = new WebpackError(
|
|
261
275
|
`${PLUGIN_NAME}\n__non_webpack_require__ is only allowed in target node`
|
|
262
276
|
);
|
|
263
|
-
warning.loc =
|
|
264
|
-
expression.loc
|
|
265
|
-
);
|
|
277
|
+
warning.loc = parser.getLocation(expression);
|
|
266
278
|
warning.module = parser.state.module;
|
|
267
279
|
compilation.warnings.push(warning);
|
|
268
280
|
}
|
|
@@ -273,9 +285,15 @@ class APIPlugin {
|
|
|
273
285
|
if (info.assign === false) {
|
|
274
286
|
parser.hooks.assign.for(key).tap(PLUGIN_NAME, (expr) => {
|
|
275
287
|
const err = new WebpackError(`${key} must not be assigned`);
|
|
276
|
-
err.loc =
|
|
288
|
+
err.loc = parser.getLocation(expr);
|
|
277
289
|
throw err;
|
|
278
290
|
});
|
|
291
|
+
} else if (key === "__webpack_public_path__") {
|
|
292
|
+
// Flag the runtime override (still let the default handler emit
|
|
293
|
+
// `__webpack_require__.p = …`); returning nothing keeps that path.
|
|
294
|
+
parser.hooks.assign.for(key).tap(PLUGIN_NAME, () => {
|
|
295
|
+
runtimePublicPathOverride.add(compilation);
|
|
296
|
+
});
|
|
279
297
|
}
|
|
280
298
|
if (info.type) {
|
|
281
299
|
parser.hooks.evaluateTypeof
|
|
@@ -291,7 +309,7 @@ class APIPlugin {
|
|
|
291
309
|
JSON.stringify(parser.state.module.layer),
|
|
292
310
|
/** @type {Range} */ (expr.range)
|
|
293
311
|
);
|
|
294
|
-
dep.loc =
|
|
312
|
+
dep.loc = parser.getLocation(expr);
|
|
295
313
|
parser.state.module.addPresentationalDependency(dep);
|
|
296
314
|
return true;
|
|
297
315
|
});
|
|
@@ -326,7 +344,7 @@ class APIPlugin {
|
|
|
326
344
|
const dep = new RuntimeRequirementsDependency([
|
|
327
345
|
RuntimeGlobals.moduleId
|
|
328
346
|
]);
|
|
329
|
-
dep.loc =
|
|
347
|
+
dep.loc = parser.getLocation(expr);
|
|
330
348
|
parser.state.module.addPresentationalDependency(dep);
|
|
331
349
|
} else {
|
|
332
350
|
const initDep = new ModuleInitFragmentDependency(
|
|
@@ -340,7 +358,7 @@ class APIPlugin {
|
|
|
340
358
|
/** @type {Range} */ (expr.range),
|
|
341
359
|
[]
|
|
342
360
|
);
|
|
343
|
-
dep.loc =
|
|
361
|
+
dep.loc = parser.getLocation(expr);
|
|
344
362
|
parser.state.module.addPresentationalDependency(dep);
|
|
345
363
|
}
|
|
346
364
|
return true;
|
|
@@ -357,7 +375,7 @@ class APIPlugin {
|
|
|
357
375
|
const dep = new RuntimeRequirementsDependency([
|
|
358
376
|
RuntimeGlobals.module
|
|
359
377
|
]);
|
|
360
|
-
dep.loc =
|
|
378
|
+
dep.loc = parser.getLocation(expr);
|
|
361
379
|
parser.state.module.addPresentationalDependency(dep);
|
|
362
380
|
} else {
|
|
363
381
|
const initDep = new ModuleInitFragmentDependency(
|
|
@@ -371,7 +389,7 @@ class APIPlugin {
|
|
|
371
389
|
/** @type {Range} */ (expr.range),
|
|
372
390
|
[]
|
|
373
391
|
);
|
|
374
|
-
dep.loc =
|
|
392
|
+
dep.loc = parser.getLocation(expr);
|
|
375
393
|
parser.state.module.addPresentationalDependency(dep);
|
|
376
394
|
}
|
|
377
395
|
return true;
|
|
@@ -396,3 +414,4 @@ class APIPlugin {
|
|
|
396
414
|
}
|
|
397
415
|
|
|
398
416
|
module.exports = APIPlugin;
|
|
417
|
+
module.exports.usesRuntimePublicPathOverride = usesRuntimePublicPathOverride;
|
package/lib/CacheFacade.js
CHANGED
|
@@ -227,6 +227,14 @@ class CacheFacade {
|
|
|
227
227
|
this._hashFunction = hashFunction;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Returns whether a cache backend is active.
|
|
232
|
+
* @returns {boolean} true, when get or store can have an effect
|
|
233
|
+
*/
|
|
234
|
+
isEnabled() {
|
|
235
|
+
return this._cache.hooks.get.isUsed() || this._cache.hooks.store.isUsed();
|
|
236
|
+
}
|
|
237
|
+
|
|
230
238
|
/**
|
|
231
239
|
* Returns child cache.
|
|
232
240
|
* @param {string} name the child cache name#
|
package/lib/ChunkGroup.js
CHANGED
|
@@ -30,6 +30,7 @@ const {
|
|
|
30
30
|
* @typedef {object} RawChunkGroupOptions
|
|
31
31
|
* @property {number=} preloadOrder
|
|
32
32
|
* @property {number=} prefetchOrder
|
|
33
|
+
* @property {number=} cssPreloadOrder preload only the chunk's CSS (`as="style"`), not its JS
|
|
33
34
|
* @property {("low" | "high" | "auto")=} fetchPriority
|
|
34
35
|
*/
|
|
35
36
|
|
|
@@ -89,7 +89,7 @@ class CompatibilityPlugin {
|
|
|
89
89
|
"require",
|
|
90
90
|
/** @type {Range} */ (expr.callee.range)
|
|
91
91
|
);
|
|
92
|
-
dep.loc =
|
|
92
|
+
dep.loc = parser.getLocation(expr);
|
|
93
93
|
if (parser.state.current.dependencies.length > 0) {
|
|
94
94
|
const last =
|
|
95
95
|
/** @type {ContextDependency} */
|
|
@@ -122,31 +122,33 @@ class CompatibilityPlugin {
|
|
|
122
122
|
*/
|
|
123
123
|
const handler = (parser) => {
|
|
124
124
|
// Handle nested requires
|
|
125
|
-
parser.hooks.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
125
|
+
parser.hooks.preStatementByType
|
|
126
|
+
.for("FunctionDeclaration")
|
|
127
|
+
.tap(PLUGIN_NAME, (statement) => {
|
|
128
|
+
if (
|
|
129
|
+
statement.type === "FunctionDeclaration" &&
|
|
130
|
+
statement.id &&
|
|
131
|
+
statement.id.name === RuntimeGlobals.require
|
|
132
|
+
) {
|
|
133
|
+
const newName = `__nested_webpack_require_${
|
|
134
|
+
/** @type {Range} */
|
|
135
|
+
(statement.range)[0]
|
|
136
|
+
}__`;
|
|
137
|
+
parser.tagVariable(
|
|
138
|
+
statement.id.name,
|
|
139
|
+
nestedWebpackIdentifierTag,
|
|
140
|
+
{
|
|
141
|
+
name: newName,
|
|
142
|
+
declaration: {
|
|
143
|
+
updated: false,
|
|
144
|
+
loc: parser.getLocation(statement.id),
|
|
145
|
+
range: /** @type {Range} */ (statement.id.range)
|
|
146
|
+
}
|
|
144
147
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
});
|
|
148
|
+
);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
150
152
|
parser.hooks.pattern
|
|
151
153
|
.for(RuntimeGlobals.require)
|
|
152
154
|
.tap(PLUGIN_NAME, (pattern) => {
|
|
@@ -157,7 +159,7 @@ class CompatibilityPlugin {
|
|
|
157
159
|
name: newName,
|
|
158
160
|
declaration: {
|
|
159
161
|
updated: false,
|
|
160
|
-
loc:
|
|
162
|
+
loc: parser.getLocation(pattern),
|
|
161
163
|
range: /** @type {Range} */ (pattern.range)
|
|
162
164
|
}
|
|
163
165
|
});
|
|
@@ -173,7 +175,7 @@ class CompatibilityPlugin {
|
|
|
173
175
|
name: newName,
|
|
174
176
|
declaration: {
|
|
175
177
|
updated: false,
|
|
176
|
-
loc:
|
|
178
|
+
loc: parser.getLocation(pattern),
|
|
177
179
|
range: /** @type {Range} */ (pattern.range)
|
|
178
180
|
}
|
|
179
181
|
});
|
|
@@ -218,7 +220,7 @@ class CompatibilityPlugin {
|
|
|
218
220
|
name,
|
|
219
221
|
/** @type {Range} */ (expr.range)
|
|
220
222
|
);
|
|
221
|
-
dep.loc =
|
|
223
|
+
dep.loc = parser.getLocation(expr);
|
|
222
224
|
parser.state.module.addPresentationalDependency(dep);
|
|
223
225
|
return true;
|
|
224
226
|
});
|
|
@@ -231,7 +233,7 @@ class CompatibilityPlugin {
|
|
|
231
233
|
if (parser.state.source.slice(0, 2).toString() !== "#!") return;
|
|
232
234
|
// this is a hashbang comment
|
|
233
235
|
const dep = new ConstDependency("//", 0);
|
|
234
|
-
dep.loc =
|
|
236
|
+
dep.loc = parser.getLocation(c);
|
|
235
237
|
parser.state.module.addPresentationalDependency(dep);
|
|
236
238
|
}
|
|
237
239
|
});
|
package/lib/Compilation.js
CHANGED
|
@@ -251,6 +251,7 @@ const { isSourceEqual } = require("./util/source");
|
|
|
251
251
|
* @typedef {object} ExecuteModuleResult
|
|
252
252
|
* @property {ExecuteModuleExports} exports
|
|
253
253
|
* @property {boolean} cacheable
|
|
254
|
+
* @property {string[]} notCacheableReasons reasons why the executed modules are not cacheable
|
|
254
255
|
* @property {ExecuteModuleAssets} assets
|
|
255
256
|
* @property {FileSystemDependencies} fileDependencies
|
|
256
257
|
* @property {FileSystemDependencies} contextDependencies
|
|
@@ -4084,6 +4085,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4084
4085
|
* @param {WebpackError[]} errors errors
|
|
4085
4086
|
* @param {CodeGenerationResults} results results
|
|
4086
4087
|
* @param {(err?: WebpackError | null, result?: boolean) => void} callback callback
|
|
4088
|
+
* @returns {void}
|
|
4087
4089
|
*/
|
|
4088
4090
|
_codeGenerationModule(
|
|
4089
4091
|
module,
|
|
@@ -4099,6 +4101,39 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4099
4101
|
callback
|
|
4100
4102
|
) {
|
|
4101
4103
|
let codeGenerated = false;
|
|
4104
|
+
// without a cache backend, skip building the cache keys — the module
|
|
4105
|
+
// identifier strings are large (concatenated modules join all inner ids)
|
|
4106
|
+
if (!this._codeGenerationCache.isEnabled()) {
|
|
4107
|
+
/** @type {CodeGenerationResult} */
|
|
4108
|
+
let result;
|
|
4109
|
+
try {
|
|
4110
|
+
codeGenerated = true;
|
|
4111
|
+
this.codeGeneratedModules.add(module);
|
|
4112
|
+
result = module.codeGeneration({
|
|
4113
|
+
chunkGraph,
|
|
4114
|
+
moduleGraph,
|
|
4115
|
+
dependencyTemplates,
|
|
4116
|
+
runtimeTemplate,
|
|
4117
|
+
runtime,
|
|
4118
|
+
runtimes,
|
|
4119
|
+
codeGenerationResults: results,
|
|
4120
|
+
compilation: this
|
|
4121
|
+
});
|
|
4122
|
+
} catch (err) {
|
|
4123
|
+
errors.push(
|
|
4124
|
+
new CodeGenerationError(module, /** @type {Error} */ (err))
|
|
4125
|
+
);
|
|
4126
|
+
result = {
|
|
4127
|
+
sources: new Map(),
|
|
4128
|
+
runtimeRequirements: null,
|
|
4129
|
+
data: undefined
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
for (const runtime of runtimes) {
|
|
4133
|
+
results.add(module, runtime, result);
|
|
4134
|
+
}
|
|
4135
|
+
return callback(null, codeGenerated);
|
|
4136
|
+
}
|
|
4102
4137
|
const cache = new MultiItemCache(
|
|
4103
4138
|
runtimes.map((runtime) =>
|
|
4104
4139
|
this._codeGenerationCache.getItemCache(
|
|
@@ -5990,6 +6025,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5990
6025
|
const assets = new Map();
|
|
5991
6026
|
|
|
5992
6027
|
let cacheable = true;
|
|
6028
|
+
/** @type {ExecuteModuleResult["notCacheableReasons"]} */
|
|
6029
|
+
const notCacheableReasons = [];
|
|
5993
6030
|
|
|
5994
6031
|
/** @type {ExecuteModuleContext} */
|
|
5995
6032
|
const context = {
|
|
@@ -6025,11 +6062,18 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
6025
6062
|
missingDependencies,
|
|
6026
6063
|
buildDependencies
|
|
6027
6064
|
);
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
) {
|
|
6065
|
+
const buildInfo = /** @type {BuildInfo} */ (
|
|
6066
|
+
module.buildInfo
|
|
6067
|
+
);
|
|
6068
|
+
if (buildInfo.cacheable === false) {
|
|
6032
6069
|
cacheable = false;
|
|
6070
|
+
if (buildInfo.notCacheableReasons) {
|
|
6071
|
+
for (const reason of buildInfo.notCacheableReasons) {
|
|
6072
|
+
if (!notCacheableReasons.includes(reason)) {
|
|
6073
|
+
notCacheableReasons.push(reason);
|
|
6074
|
+
}
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6033
6077
|
}
|
|
6034
6078
|
if (module.buildInfo && module.buildInfo.assets) {
|
|
6035
6079
|
const { assets: moduleAssets, assetsInfo } =
|
|
@@ -6181,6 +6225,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
6181
6225
|
exports,
|
|
6182
6226
|
assets,
|
|
6183
6227
|
cacheable,
|
|
6228
|
+
notCacheableReasons,
|
|
6184
6229
|
fileDependencies,
|
|
6185
6230
|
contextDependencies,
|
|
6186
6231
|
missingDependencies,
|
package/lib/ConstPlugin.js
CHANGED
|
@@ -175,7 +175,7 @@ class ConstPlugin {
|
|
|
175
175
|
`${bool}`,
|
|
176
176
|
/** @type {Range} */ (param.range)
|
|
177
177
|
);
|
|
178
|
-
dep.loc =
|
|
178
|
+
dep.loc = parser.getLocation(statement);
|
|
179
179
|
parser.state.module.addPresentationalDependency(dep);
|
|
180
180
|
} else {
|
|
181
181
|
parser.walkExpression(statement.test);
|
|
@@ -212,7 +212,7 @@ class ConstPlugin {
|
|
|
212
212
|
` ${bool}`,
|
|
213
213
|
/** @type {Range} */ (param.range)
|
|
214
214
|
);
|
|
215
|
-
dep.loc =
|
|
215
|
+
dep.loc = parser.getLocation(expression);
|
|
216
216
|
parser.state.module.addPresentationalDependency(dep);
|
|
217
217
|
} else {
|
|
218
218
|
parser.walkExpression(expression.test);
|
|
@@ -235,7 +235,7 @@ class ConstPlugin {
|
|
|
235
235
|
"0",
|
|
236
236
|
/** @type {Range} */ (branchToRemove.range)
|
|
237
237
|
);
|
|
238
|
-
dep.loc =
|
|
238
|
+
dep.loc = parser.getLocation(branchToRemove);
|
|
239
239
|
parser.state.module.addPresentationalDependency(dep);
|
|
240
240
|
return bool;
|
|
241
241
|
}
|
|
@@ -315,7 +315,7 @@ class ConstPlugin {
|
|
|
315
315
|
` ${bool}`,
|
|
316
316
|
/** @type {Range} */ (param.range)
|
|
317
317
|
);
|
|
318
|
-
dep.loc =
|
|
318
|
+
dep.loc = parser.getLocation(expression);
|
|
319
319
|
parser.state.module.addPresentationalDependency(dep);
|
|
320
320
|
} else {
|
|
321
321
|
parser.walkExpression(expression.left);
|
|
@@ -325,7 +325,7 @@ class ConstPlugin {
|
|
|
325
325
|
"0",
|
|
326
326
|
/** @type {Range} */ (expression.right.range)
|
|
327
327
|
);
|
|
328
|
-
dep.loc =
|
|
328
|
+
dep.loc = parser.getLocation(expression);
|
|
329
329
|
parser.state.module.addPresentationalDependency(dep);
|
|
330
330
|
}
|
|
331
331
|
return keepRight;
|
|
@@ -368,14 +368,14 @@ class ConstPlugin {
|
|
|
368
368
|
" null",
|
|
369
369
|
/** @type {Range} */ (param.range)
|
|
370
370
|
);
|
|
371
|
-
dep.loc =
|
|
371
|
+
dep.loc = parser.getLocation(expression);
|
|
372
372
|
parser.state.module.addPresentationalDependency(dep);
|
|
373
373
|
} else {
|
|
374
374
|
const dep = new ConstDependency(
|
|
375
375
|
"0",
|
|
376
376
|
/** @type {Range} */ (expression.right.range)
|
|
377
377
|
);
|
|
378
|
-
dep.loc =
|
|
378
|
+
dep.loc = parser.getLocation(expression);
|
|
379
379
|
parser.state.module.addPresentationalDependency(dep);
|
|
380
380
|
parser.walkExpression(expression.left);
|
|
381
381
|
}
|
|
@@ -437,7 +437,7 @@ class ConstPlugin {
|
|
|
437
437
|
" undefined",
|
|
438
438
|
/** @type {Range} */ (expr.range)
|
|
439
439
|
);
|
|
440
|
-
dep.loc =
|
|
440
|
+
dep.loc = parser.getLocation(expr);
|
|
441
441
|
parser.state.module.addPresentationalDependency(dep);
|
|
442
442
|
return true;
|
|
443
443
|
}
|
|
@@ -464,7 +464,7 @@ class ConstPlugin {
|
|
|
464
464
|
/** @type {Range} */ (expr.range),
|
|
465
465
|
"__resourceQuery"
|
|
466
466
|
);
|
|
467
|
-
dep.loc =
|
|
467
|
+
dep.loc = parser.getLocation(expr);
|
|
468
468
|
parser.state.module.addPresentationalDependency(dep);
|
|
469
469
|
return true;
|
|
470
470
|
});
|
|
@@ -490,7 +490,7 @@ class ConstPlugin {
|
|
|
490
490
|
/** @type {Range} */ (expr.range),
|
|
491
491
|
"__resourceFragment"
|
|
492
492
|
);
|
|
493
|
-
dep.loc =
|
|
493
|
+
dep.loc = parser.getLocation(expr);
|
|
494
494
|
parser.state.module.addPresentationalDependency(dep);
|
|
495
495
|
return true;
|
|
496
496
|
});
|
|
@@ -562,7 +562,7 @@ class ConstPlugin {
|
|
|
562
562
|
`// removed by dead control flow\n${replacement}`,
|
|
563
563
|
/** @type {Range} */ (statement.range)
|
|
564
564
|
);
|
|
565
|
-
dep.loc =
|
|
565
|
+
dep.loc = parser.getLocation(statement);
|
|
566
566
|
parser.state.module.addPresentationalDependency(dep);
|
|
567
567
|
}
|
|
568
568
|
}
|