webpack 5.77.0 → 5.78.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/bin/webpack.js +0 -0
- package/lib/APIPlugin.js +25 -18
- package/lib/CompatibilityPlugin.js +53 -52
- package/lib/ConstPlugin.js +22 -15
- package/lib/ContextModule.js +3 -2
- package/lib/DefinePlugin.js +44 -36
- package/lib/DelegatedModule.js +2 -1
- package/lib/DllModule.js +2 -1
- package/lib/ErrorHelpers.js +61 -22
- package/lib/ExportsInfoApiPlugin.js +16 -9
- package/lib/ExternalModule.js +2 -1
- package/lib/FlagAllModulesAsUsedPlugin.js +22 -27
- package/lib/FlagDependencyExportsPlugin.js +336 -348
- package/lib/FlagDependencyUsagePlugin.js +6 -8
- package/lib/FlagEntryExportAsUsedPlugin.js +22 -23
- package/lib/HotModuleReplacementPlugin.js +50 -45
- package/lib/JavascriptMetaInfoPlugin.js +16 -9
- package/lib/ModuleTypeConstants.js +50 -0
- package/lib/NodeStuffPlugin.js +35 -31
- package/lib/NormalModule.js +2 -1
- package/lib/NormalModuleFactory.js +7 -1
- package/lib/ProvidePlugin.js +17 -10
- package/lib/RawModule.js +2 -1
- package/lib/RequireJsStuffPlugin.js +15 -15
- package/lib/UseStrictPlugin.js +15 -8
- package/lib/WebpackIsIncludedPlugin.js +16 -9
- package/lib/config/defaults.js +16 -8
- package/lib/config/normalization.js +4 -0
- package/lib/container/ContainerEntryModule.js +2 -1
- package/lib/css/CssParser.js +22 -2
- package/lib/debug/ProfilingPlugin.js +20 -12
- package/lib/dependencies/AMDPlugin.js +26 -20
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -4
- package/lib/dependencies/CommonJsPlugin.js +29 -25
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
- package/lib/dependencies/HarmonyModulesPlugin.js +11 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +11 -5
- package/lib/dependencies/ImportMetaPlugin.js +26 -20
- package/lib/dependencies/ImportPlugin.js +14 -7
- package/lib/dependencies/RequireContextPlugin.js +12 -6
- package/lib/dependencies/RequireEnsurePlugin.js +13 -7
- package/lib/dependencies/RequireIncludePlugin.js +11 -5
- package/lib/dependencies/SystemPlugin.js +21 -15
- package/lib/dependencies/URLPlugin.js +15 -9
- package/lib/dependencies/WorkerPlugin.js +14 -8
- package/lib/javascript/JavascriptModulesPlugin.js +157 -164
- package/lib/json/JsonModulesPlugin.js +13 -5
- package/lib/library/AmdLibraryPlugin.js +22 -6
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
- package/lib/optimize/ConcatenatedModule.js +2 -1
- package/lib/optimize/InnerGraphPlugin.js +47 -46
- package/lib/optimize/SideEffectsFlagPlugin.js +43 -43
- package/lib/sharing/ConsumeSharedPlugin.js +4 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +9 -6
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +42 -43
- package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +40 -40
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +18 -0
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +8 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
- package/types.d.ts +10 -0
package/lib/DelegatedModule.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
9
9
|
const Module = require("./Module");
|
10
|
+
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
10
11
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
11
12
|
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
12
13
|
const StaticExportsDependency = require("./dependencies/StaticExportsDependency");
|
@@ -40,7 +41,7 @@ const RUNTIME_REQUIREMENTS = new Set([
|
|
40
41
|
|
41
42
|
class DelegatedModule extends Module {
|
42
43
|
constructor(sourceRequest, data, type, userRequest, originalRequest) {
|
43
|
-
super(
|
44
|
+
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
44
45
|
|
45
46
|
// Info from Factory
|
46
47
|
this.sourceRequest = sourceRequest;
|
package/lib/DllModule.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { RawSource } = require("webpack-sources");
|
9
9
|
const Module = require("./Module");
|
10
|
+
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
10
11
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
11
12
|
const makeSerializable = require("./util/makeSerializable");
|
12
13
|
|
@@ -35,7 +36,7 @@ const RUNTIME_REQUIREMENTS = new Set([
|
|
35
36
|
|
36
37
|
class DllModule extends Module {
|
37
38
|
constructor(context, dependencies, name) {
|
38
|
-
super(
|
39
|
+
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, context);
|
39
40
|
|
40
41
|
// Info from Factory
|
41
42
|
this.dependencies = dependencies;
|
package/lib/ErrorHelpers.js
CHANGED
@@ -9,36 +9,57 @@ const loaderFlag = "LOADER_EXECUTION";
|
|
9
9
|
|
10
10
|
const webpackOptionsFlag = "WEBPACK_OPTIONS";
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
/**
|
13
|
+
* @param {string} stack stack trace
|
14
|
+
* @param {string} flag flag to cut off
|
15
|
+
* @returns {string} stack trace without the specified flag included
|
16
|
+
*/
|
17
|
+
const cutOffByFlag = (stack, flag) => {
|
18
|
+
const errorStack = stack.split("\n");
|
19
|
+
for (let i = 0; i < errorStack.length; i++) {
|
20
|
+
if (errorStack[i].includes(flag)) {
|
21
|
+
errorStack.length = i;
|
17
22
|
}
|
18
23
|
}
|
19
|
-
return
|
24
|
+
return errorStack.join("\n");
|
20
25
|
};
|
21
26
|
|
22
|
-
|
23
|
-
|
27
|
+
/**
|
28
|
+
* @param {string} stack stack trace
|
29
|
+
* @returns {string} stack trace without the loader execution flag included
|
30
|
+
*/
|
31
|
+
const cutOffLoaderExecution = stack => cutOffByFlag(stack, loaderFlag);
|
24
32
|
|
25
|
-
|
26
|
-
|
33
|
+
/**
|
34
|
+
* @param {string} stack stack trace
|
35
|
+
* @returns {string} stack trace without the webpack options flag included
|
36
|
+
*/
|
37
|
+
const cutOffWebpackOptions = stack => cutOffByFlag(stack, webpackOptionsFlag);
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
|
39
|
+
/**
|
40
|
+
* @param {string} stack stack trace
|
41
|
+
* @param {string} message error message
|
42
|
+
* @returns {string} stack trace without the message included
|
43
|
+
*/
|
44
|
+
const cutOffMultilineMessage = (stack, message) => {
|
45
|
+
const stackSplitByLines = stack.split("\n");
|
46
|
+
const messageSplitByLines = message.split("\n");
|
31
47
|
|
32
48
|
const result = [];
|
33
49
|
|
34
|
-
|
35
|
-
if (!line.includes(
|
50
|
+
stackSplitByLines.forEach((line, idx) => {
|
51
|
+
if (!line.includes(messageSplitByLines[idx])) result.push(line);
|
36
52
|
});
|
37
53
|
|
38
54
|
return result.join("\n");
|
39
55
|
};
|
40
56
|
|
41
|
-
|
57
|
+
/**
|
58
|
+
* @param {string} stack stack trace
|
59
|
+
* @param {string} message error message
|
60
|
+
* @returns {string} stack trace without the message included
|
61
|
+
*/
|
62
|
+
const cutOffMessage = (stack, message) => {
|
42
63
|
const nextLine = stack.indexOf("\n");
|
43
64
|
if (nextLine === -1) {
|
44
65
|
return stack === message ? "" : stack;
|
@@ -48,14 +69,32 @@ exports.cutOffMessage = (stack, message) => {
|
|
48
69
|
}
|
49
70
|
};
|
50
71
|
|
51
|
-
|
52
|
-
|
53
|
-
|
72
|
+
/**
|
73
|
+
* @param {string} stack stack trace
|
74
|
+
* @param {string} message error message
|
75
|
+
* @returns {string} stack trace without the loader execution flag and message included
|
76
|
+
*/
|
77
|
+
const cleanUp = (stack, message) => {
|
78
|
+
stack = cutOffLoaderExecution(stack);
|
79
|
+
stack = cutOffMessage(stack, message);
|
54
80
|
return stack;
|
55
81
|
};
|
56
82
|
|
57
|
-
|
58
|
-
|
59
|
-
|
83
|
+
/**
|
84
|
+
* @param {string} stack stack trace
|
85
|
+
* @param {string} message error message
|
86
|
+
* @returns {string} stack trace without the webpack options flag and message included
|
87
|
+
*/
|
88
|
+
const cleanUpWebpackOptions = (stack, message) => {
|
89
|
+
stack = cutOffWebpackOptions(stack);
|
90
|
+
stack = cutOffMultilineMessage(stack, message);
|
60
91
|
return stack;
|
61
92
|
};
|
93
|
+
|
94
|
+
exports.cutOffByFlag = cutOffByFlag;
|
95
|
+
exports.cutOffLoaderExecution = cutOffLoaderExecution;
|
96
|
+
exports.cutOffWebpackOptions = cutOffWebpackOptions;
|
97
|
+
exports.cutOffMultilineMessage = cutOffMultilineMessage;
|
98
|
+
exports.cutOffMessage = cutOffMessage;
|
99
|
+
exports.cleanUp = cleanUp;
|
100
|
+
exports.cleanUpWebpackOptions = cleanUpWebpackOptions;
|
@@ -5,12 +5,19 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
11
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
12
|
+
} = require("./ModuleTypeConstants");
|
8
13
|
const ConstDependency = require("./dependencies/ConstDependency");
|
9
14
|
const ExportsInfoDependency = require("./dependencies/ExportsInfoDependency");
|
10
15
|
|
11
16
|
/** @typedef {import("./Compiler")} Compiler */
|
12
17
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
13
18
|
|
19
|
+
const PLUGIN_NAME = "ExportsInfoApiPlugin";
|
20
|
+
|
14
21
|
class ExportsInfoApiPlugin {
|
15
22
|
/**
|
16
23
|
* Apply the plugin
|
@@ -19,7 +26,7 @@ class ExportsInfoApiPlugin {
|
|
19
26
|
*/
|
20
27
|
apply(compiler) {
|
21
28
|
compiler.hooks.compilation.tap(
|
22
|
-
|
29
|
+
PLUGIN_NAME,
|
23
30
|
(compilation, { normalModuleFactory }) => {
|
24
31
|
compilation.dependencyTemplates.set(
|
25
32
|
ExportsInfoDependency,
|
@@ -32,7 +39,7 @@ class ExportsInfoApiPlugin {
|
|
32
39
|
const handler = parser => {
|
33
40
|
parser.hooks.expressionMemberChain
|
34
41
|
.for("__webpack_exports_info__")
|
35
|
-
.tap(
|
42
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
36
43
|
const dep =
|
37
44
|
members.length >= 2
|
38
45
|
? new ExportsInfoDependency(
|
@@ -47,7 +54,7 @@ class ExportsInfoApiPlugin {
|
|
47
54
|
});
|
48
55
|
parser.hooks.expression
|
49
56
|
.for("__webpack_exports_info__")
|
50
|
-
.tap(
|
57
|
+
.tap(PLUGIN_NAME, expr => {
|
51
58
|
const dep = new ConstDependency("true", expr.range);
|
52
59
|
dep.loc = expr.loc;
|
53
60
|
parser.state.module.addPresentationalDependency(dep);
|
@@ -55,14 +62,14 @@ class ExportsInfoApiPlugin {
|
|
55
62
|
});
|
56
63
|
};
|
57
64
|
normalModuleFactory.hooks.parser
|
58
|
-
.for(
|
59
|
-
.tap(
|
65
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
66
|
+
.tap(PLUGIN_NAME, handler);
|
60
67
|
normalModuleFactory.hooks.parser
|
61
|
-
.for(
|
62
|
-
.tap(
|
68
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
69
|
+
.tap(PLUGIN_NAME, handler);
|
63
70
|
normalModuleFactory.hooks.parser
|
64
|
-
.for(
|
65
|
-
.tap(
|
71
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
72
|
+
.tap(PLUGIN_NAME, handler);
|
66
73
|
}
|
67
74
|
);
|
68
75
|
}
|
package/lib/ExternalModule.js
CHANGED
@@ -10,6 +10,7 @@ const ConcatenationScope = require("./ConcatenationScope");
|
|
10
10
|
const { UsageState } = require("./ExportsInfo");
|
11
11
|
const InitFragment = require("./InitFragment");
|
12
12
|
const Module = require("./Module");
|
13
|
+
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
13
14
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
14
15
|
const Template = require("./Template");
|
15
16
|
const StaticExportsDependency = require("./dependencies/StaticExportsDependency");
|
@@ -378,7 +379,7 @@ const getSourceForDefaultCase = (optional, request, runtimeTemplate) => {
|
|
378
379
|
|
379
380
|
class ExternalModule extends Module {
|
380
381
|
constructor(request, type, userRequest) {
|
381
|
-
super(
|
382
|
+
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
382
383
|
|
383
384
|
// Info from Factory
|
384
385
|
/** @type {string | string[] | Record<string, string | string[]>} */
|
@@ -10,6 +10,7 @@ const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime");
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "FlagAllModulesAsUsedPlugin";
|
13
14
|
class FlagAllModulesAsUsedPlugin {
|
14
15
|
constructor(explanation) {
|
15
16
|
this.explanation = explanation;
|
@@ -21,34 +22,28 @@ class FlagAllModulesAsUsedPlugin {
|
|
21
22
|
* @returns {void}
|
22
23
|
*/
|
23
24
|
apply(compiler) {
|
24
|
-
compiler.hooks.compilation.tap(
|
25
|
-
|
26
|
-
compilation => {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
exportsInfo.setUsedInUnknownWay(runtime);
|
42
|
-
moduleGraph.addExtraReason(module, this.explanation);
|
43
|
-
if (module.factoryMeta === undefined) {
|
44
|
-
module.factoryMeta = {};
|
45
|
-
}
|
46
|
-
module.factoryMeta.sideEffectFree = false;
|
47
|
-
}
|
25
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
26
|
+
const moduleGraph = compilation.moduleGraph;
|
27
|
+
compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => {
|
28
|
+
/** @type {RuntimeSpec} */
|
29
|
+
let runtime = undefined;
|
30
|
+
for (const [name, { options }] of compilation.entries) {
|
31
|
+
runtime = mergeRuntimeOwned(
|
32
|
+
runtime,
|
33
|
+
getEntryRuntime(compilation, name, options)
|
34
|
+
);
|
35
|
+
}
|
36
|
+
for (const module of modules) {
|
37
|
+
const exportsInfo = moduleGraph.getExportsInfo(module);
|
38
|
+
exportsInfo.setUsedInUnknownWay(runtime);
|
39
|
+
moduleGraph.addExtraReason(module, this.explanation);
|
40
|
+
if (module.factoryMeta === undefined) {
|
41
|
+
module.factoryMeta = {};
|
48
42
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
module.factoryMeta.sideEffectFree = false;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
});
|
52
47
|
}
|
53
48
|
}
|
54
49
|
|