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
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const Generator = require("../Generator");
|
9
|
+
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
|
9
10
|
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
|
10
11
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
11
12
|
const { compareModulesByIdentifier } = require("../util/comparators");
|
@@ -26,6 +27,8 @@ const getWebAssemblyJavascriptGenerator = memoize(() =>
|
|
26
27
|
);
|
27
28
|
const getWebAssemblyParser = memoize(() => require("./WebAssemblyParser"));
|
28
29
|
|
30
|
+
const PLUGIN_NAME = "WebAssemblyModulesPlugin";
|
31
|
+
|
29
32
|
class WebAssemblyModulesPlugin {
|
30
33
|
constructor(options) {
|
31
34
|
this.options = options;
|
@@ -38,7 +41,7 @@ class WebAssemblyModulesPlugin {
|
|
38
41
|
*/
|
39
42
|
apply(compiler) {
|
40
43
|
compiler.hooks.compilation.tap(
|
41
|
-
|
44
|
+
PLUGIN_NAME,
|
42
45
|
(compilation, { normalModuleFactory }) => {
|
43
46
|
compilation.dependencyFactories.set(
|
44
47
|
WebAssemblyImportDependency,
|
@@ -51,16 +54,16 @@ class WebAssemblyModulesPlugin {
|
|
51
54
|
);
|
52
55
|
|
53
56
|
normalModuleFactory.hooks.createParser
|
54
|
-
.for(
|
55
|
-
.tap(
|
57
|
+
.for(WEBASSEMBLY_MODULE_TYPE_SYNC)
|
58
|
+
.tap(PLUGIN_NAME, () => {
|
56
59
|
const WebAssemblyParser = getWebAssemblyParser();
|
57
60
|
|
58
61
|
return new WebAssemblyParser();
|
59
62
|
});
|
60
63
|
|
61
64
|
normalModuleFactory.hooks.createGenerator
|
62
|
-
.for(
|
63
|
-
.tap(
|
65
|
+
.for(WEBASSEMBLY_MODULE_TYPE_SYNC)
|
66
|
+
.tap(PLUGIN_NAME, () => {
|
64
67
|
const WebAssemblyJavascriptGenerator =
|
65
68
|
getWebAssemblyJavascriptGenerator();
|
66
69
|
const WebAssemblyGenerator = getWebAssemblyGenerator();
|
@@ -71,53 +74,49 @@ class WebAssemblyModulesPlugin {
|
|
71
74
|
});
|
72
75
|
});
|
73
76
|
|
74
|
-
compilation.hooks.renderManifest.tap(
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
result.push({
|
89
|
-
render: () =>
|
90
|
-
codeGenerationResults.getSource(
|
91
|
-
module,
|
92
|
-
chunk.runtime,
|
93
|
-
"webassembly"
|
94
|
-
),
|
95
|
-
filenameTemplate,
|
96
|
-
pathOptions: {
|
77
|
+
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
|
78
|
+
const { chunkGraph } = compilation;
|
79
|
+
const { chunk, outputOptions, codeGenerationResults } = options;
|
80
|
+
|
81
|
+
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
82
|
+
chunk,
|
83
|
+
compareModulesByIdentifier
|
84
|
+
)) {
|
85
|
+
if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
|
86
|
+
const filenameTemplate = outputOptions.webassemblyModuleFilename;
|
87
|
+
|
88
|
+
result.push({
|
89
|
+
render: () =>
|
90
|
+
codeGenerationResults.getSource(
|
97
91
|
module,
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
}
|
107
|
-
|
92
|
+
chunk.runtime,
|
93
|
+
"webassembly"
|
94
|
+
),
|
95
|
+
filenameTemplate,
|
96
|
+
pathOptions: {
|
97
|
+
module,
|
98
|
+
runtime: chunk.runtime,
|
99
|
+
chunkGraph
|
100
|
+
},
|
101
|
+
auxiliary: true,
|
102
|
+
identifier: `webassemblyModule${chunkGraph.getModuleId(
|
103
|
+
module
|
104
|
+
)}`,
|
105
|
+
hash: chunkGraph.getModuleHash(module, chunk.runtime)
|
106
|
+
});
|
108
107
|
}
|
109
|
-
|
110
|
-
return result;
|
111
108
|
}
|
112
|
-
);
|
113
109
|
|
114
|
-
|
110
|
+
return result;
|
111
|
+
});
|
112
|
+
|
113
|
+
compilation.hooks.afterChunks.tap(PLUGIN_NAME, () => {
|
115
114
|
const chunkGraph = compilation.chunkGraph;
|
116
115
|
const initialWasmModules = new Set();
|
117
116
|
for (const chunk of compilation.chunks) {
|
118
117
|
if (chunk.canBeInitial()) {
|
119
118
|
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
|
120
|
-
if (module.type ===
|
119
|
+
if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
|
121
120
|
initialWasmModules.add(module);
|
122
121
|
}
|
123
122
|
}
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
8
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
10
|
const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
|
10
11
|
|
@@ -40,7 +41,7 @@ class FetchCompileAsyncWasmPlugin {
|
|
40
41
|
if (
|
41
42
|
!chunkGraph.hasModuleInGraph(
|
42
43
|
chunk,
|
43
|
-
m => m.type ===
|
44
|
+
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
|
44
45
|
)
|
45
46
|
) {
|
46
47
|
return;
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
|
8
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
10
|
const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule");
|
10
11
|
|
@@ -12,6 +13,8 @@ const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRunt
|
|
12
13
|
|
13
14
|
// TODO webpack 6 remove
|
14
15
|
|
16
|
+
const PLUGIN_NAME = "FetchCompileWasmPlugin";
|
17
|
+
|
15
18
|
class FetchCompileWasmPlugin {
|
16
19
|
constructor(options) {
|
17
20
|
this.options = options || {};
|
@@ -23,48 +26,45 @@ class FetchCompileWasmPlugin {
|
|
23
26
|
* @returns {void}
|
24
27
|
*/
|
25
28
|
apply(compiler) {
|
26
|
-
compiler.hooks.thisCompilation.tap(
|
27
|
-
|
28
|
-
|
29
|
-
const
|
30
|
-
const
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
const generateLoadBinaryCode = path =>
|
39
|
-
`fetch(${RuntimeGlobals.publicPath} + ${path})`;
|
29
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
30
|
+
const globalWasmLoading = compilation.outputOptions.wasmLoading;
|
31
|
+
const isEnabledForChunk = chunk => {
|
32
|
+
const options = chunk.getEntryOptions();
|
33
|
+
const wasmLoading =
|
34
|
+
options && options.wasmLoading !== undefined
|
35
|
+
? options.wasmLoading
|
36
|
+
: globalWasmLoading;
|
37
|
+
return wasmLoading === "fetch";
|
38
|
+
};
|
39
|
+
const generateLoadBinaryCode = path =>
|
40
|
+
`fetch(${RuntimeGlobals.publicPath} + ${path})`;
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
chunk,
|
49
|
-
m => m.type === "webassembly/sync"
|
50
|
-
)
|
51
|
-
) {
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
set.add(RuntimeGlobals.moduleCache);
|
55
|
-
set.add(RuntimeGlobals.publicPath);
|
56
|
-
compilation.addRuntimeModule(
|
42
|
+
compilation.hooks.runtimeRequirementInTree
|
43
|
+
.for(RuntimeGlobals.ensureChunkHandlers)
|
44
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
45
|
+
if (!isEnabledForChunk(chunk)) return;
|
46
|
+
const chunkGraph = compilation.chunkGraph;
|
47
|
+
if (
|
48
|
+
!chunkGraph.hasModuleInGraph(
|
57
49
|
chunk,
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
50
|
+
m => m.type === WEBASSEMBLY_MODULE_TYPE_SYNC
|
51
|
+
)
|
52
|
+
) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
set.add(RuntimeGlobals.moduleCache);
|
56
|
+
set.add(RuntimeGlobals.publicPath);
|
57
|
+
compilation.addRuntimeModule(
|
58
|
+
chunk,
|
59
|
+
new WasmChunkLoadingRuntimeModule({
|
60
|
+
generateLoadBinaryCode,
|
61
|
+
supportsStreaming: true,
|
62
|
+
mangleImports: this.options.mangleImports,
|
63
|
+
runtimeRequirements: set
|
64
|
+
})
|
65
|
+
);
|
66
|
+
});
|
67
|
+
});
|
68
68
|
}
|
69
69
|
}
|
70
70
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.78.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|