webpack 5.102.0 → 5.103.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 +121 -134
- package/lib/ChunkGraph.js +2 -2
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +25 -2
- package/lib/Compilation.js +30 -13
- package/lib/ConcatenationScope.js +0 -15
- package/lib/ContextModule.js +3 -1
- package/lib/CssModule.js +6 -1
- package/lib/DefinePlugin.js +12 -12
- package/lib/Dependency.js +8 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DotenvPlugin.js +457 -0
- package/lib/EnvironmentPlugin.js +19 -16
- package/lib/EvalSourceMapDevToolPlugin.js +16 -0
- package/lib/ExportsInfo.js +6 -2
- package/lib/ExternalModule.js +20 -28
- package/lib/ExternalModuleFactoryPlugin.js +10 -8
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +9 -12
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +3 -0
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +2 -1
- package/lib/ModuleSourceTypesConstants.js +0 -6
- package/lib/MultiCompiler.js +1 -1
- package/lib/NodeStuffPlugin.js +419 -121
- package/lib/NormalModule.js +18 -17
- package/lib/NormalModuleFactory.js +75 -4
- package/lib/RuntimeGlobals.js +22 -4
- package/lib/RuntimePlugin.js +27 -6
- package/lib/RuntimeTemplate.js +125 -57
- package/lib/SourceMapDevToolPlugin.js +26 -8
- package/lib/WebpackOptionsApply.js +33 -9
- package/lib/asset/AssetBytesGenerator.js +2 -1
- package/lib/asset/AssetGenerator.js +3 -5
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +82 -76
- package/lib/config/defaults.js +105 -20
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +7 -1
- package/lib/css/CssGenerator.js +283 -57
- package/lib/css/CssLoadingRuntimeModule.js +2 -0
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +86 -40
- package/lib/css/CssParser.js +1174 -667
- package/lib/css/walkCssTokens.js +98 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
- package/lib/dependencies/CommonJsPlugin.js +12 -0
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CssIcssExportDependency.js +247 -8
- package/lib/dependencies/CssIcssFromIdentifierDependency.js +124 -0
- package/lib/dependencies/CssIcssGlobalIdentifierDependency.js +48 -0
- package/lib/dependencies/CssIcssImportDependency.js +60 -54
- package/lib/dependencies/CssIcssLocalIdentifierDependency.js +61 -0
- package/lib/dependencies/{CssSelfLocalIdentifierDependency.js → CssIcssSelfLocalIdentifierDependency.js} +88 -10
- package/lib/dependencies/CssIcssSymbolDependency.js +31 -29
- package/lib/dependencies/CssImportDependency.js +15 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +95 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +32 -21
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +12 -8
- package/lib/dependencies/HarmonyImportDependency.js +27 -28
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
- package/lib/dependencies/ImportContextDependency.js +13 -0
- package/lib/dependencies/ImportDependency.js +10 -4
- package/lib/dependencies/ImportEagerDependency.js +6 -3
- package/lib/dependencies/ImportMetaPlugin.js +98 -10
- package/lib/dependencies/ImportParserPlugin.js +19 -21
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportWeakDependency.js +6 -3
- package/lib/dependencies/ModuleDependency.js +5 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +1 -3
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
- package/lib/hmr/LazyCompilationPlugin.js +1 -0
- package/lib/ids/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +5 -2
- package/lib/index.js +6 -0
- package/lib/javascript/ChunkHelpers.js +16 -5
- package/lib/javascript/JavascriptGenerator.js +101 -101
- package/lib/javascript/JavascriptModulesPlugin.js +25 -16
- package/lib/javascript/JavascriptParser.js +143 -39
- package/lib/json/JsonParser.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +0 -10
- package/lib/library/SystemLibraryPlugin.js +19 -5
- package/lib/library/UmdLibraryPlugin.js +1 -1
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
- package/lib/optimize/ConcatenatedModule.js +161 -135
- package/lib/optimize/RealContentHashPlugin.js +5 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
- package/lib/serialization/FileMiddleware.js +1 -1
- package/lib/serialization/ObjectMiddleware.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
- package/lib/util/Hash.js +35 -5
- package/lib/util/comparators.js +4 -3
- package/lib/util/create-schema-validation.js +1 -1
- package/lib/util/createHash.js +85 -15
- package/lib/util/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- package/lib/util/internalSerializables.js +4 -4
- package/lib/util/jsonParseEvenBetterErrors.js +10 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +8 -5
- package/lib/wasm-async/AsyncWebAssemblyParser.js +0 -9
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +8 -4
- package/lib/wasm-sync/WebAssemblyParser.js +0 -9
- package/lib/web/FetchCompileWasmPlugin.js +0 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +85 -82
- package/module.d.ts +5 -0
- package/package.json +28 -26
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +110 -15
- package/schemas/plugins/{HashedModuleIdsPlugin.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -1
- package/types.d.ts +788 -127
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -252
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const Hash = require("../Hash");
|
|
9
|
+
|
|
8
10
|
// 65536 is the size of a wasm memory page
|
|
9
11
|
// 64 is the maximum chunk size for every possible wasm hash implementation
|
|
10
12
|
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
|
11
13
|
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
|
12
14
|
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
|
13
15
|
|
|
14
|
-
class WasmHash {
|
|
16
|
+
class WasmHash extends Hash {
|
|
15
17
|
/**
|
|
16
18
|
* @param {WebAssembly.Instance} instance wasm instance
|
|
17
19
|
* @param {WebAssembly.Instance[]} instancesPool pool of instances
|
|
@@ -19,6 +21,8 @@ class WasmHash {
|
|
|
19
21
|
* @param {number} digestSize size of digest returned by wasm
|
|
20
22
|
*/
|
|
21
23
|
constructor(instance, instancesPool, chunkSize, digestSize) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
22
26
|
const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
|
|
23
27
|
exports.init();
|
|
24
28
|
this.exports = exports;
|
|
@@ -35,17 +39,39 @@ class WasmHash {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
42
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
43
|
+
* @overload
|
|
44
|
+
* @param {string | Buffer} data data
|
|
45
|
+
* @returns {Hash} updated hash
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
49
|
+
* @overload
|
|
50
|
+
* @param {string} data data
|
|
51
|
+
* @param {string=} inputEncoding data encoding
|
|
52
|
+
* @returns {this} updated hash
|
|
41
53
|
*/
|
|
42
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
56
|
+
* @param {string | Buffer} data data
|
|
57
|
+
* @param {string=} inputEncoding data encoding
|
|
58
|
+
* @returns {this} updated hash
|
|
59
|
+
*/
|
|
60
|
+
update(data, inputEncoding) {
|
|
43
61
|
if (typeof data === "string") {
|
|
44
62
|
while (data.length > MAX_SHORT_STRING) {
|
|
45
|
-
this._updateWithShortString(
|
|
63
|
+
this._updateWithShortString(
|
|
64
|
+
data.slice(0, MAX_SHORT_STRING),
|
|
65
|
+
/** @type {NodeJS.BufferEncoding} */
|
|
66
|
+
(inputEncoding)
|
|
67
|
+
);
|
|
46
68
|
data = data.slice(MAX_SHORT_STRING);
|
|
47
69
|
}
|
|
48
|
-
this._updateWithShortString(
|
|
70
|
+
this._updateWithShortString(
|
|
71
|
+
data,
|
|
72
|
+
/** @type {NodeJS.BufferEncoding} */
|
|
73
|
+
(inputEncoding)
|
|
74
|
+
);
|
|
49
75
|
return this;
|
|
50
76
|
}
|
|
51
77
|
this._updateWithBuffer(data);
|
|
@@ -136,17 +162,31 @@ class WasmHash {
|
|
|
136
162
|
}
|
|
137
163
|
|
|
138
164
|
/**
|
|
139
|
-
* @
|
|
140
|
-
* @
|
|
165
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
166
|
+
* @overload
|
|
167
|
+
* @returns {Buffer} digest
|
|
168
|
+
*/
|
|
169
|
+
/**
|
|
170
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
171
|
+
* @overload
|
|
172
|
+
* @param {string=} encoding encoding of the return value
|
|
173
|
+
* @returns {string} digest
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
177
|
+
* @param {string=} encoding encoding of the return value
|
|
178
|
+
* @returns {string | Buffer} digest
|
|
141
179
|
*/
|
|
142
|
-
digest(
|
|
180
|
+
digest(encoding) {
|
|
143
181
|
const { exports, buffered, mem, digestSize } = this;
|
|
144
182
|
exports.final(buffered);
|
|
145
183
|
this.instancesPool.push(this);
|
|
146
184
|
const hex = mem.toString("latin1", 0, digestSize);
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
149
|
-
return Buffer.from(hex, "hex").toString(
|
|
185
|
+
if (encoding === "hex") return hex;
|
|
186
|
+
if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex");
|
|
187
|
+
return Buffer.from(hex, "hex").toString(
|
|
188
|
+
/** @type {NodeJS.BufferEncoding} */ (encoding)
|
|
189
|
+
);
|
|
150
190
|
}
|
|
151
191
|
}
|
|
152
192
|
|
|
@@ -73,10 +73,10 @@ module.exports = {
|
|
|
73
73
|
require("../dependencies/CriticalDependencyWarning"),
|
|
74
74
|
"dependencies/CssImportDependency": () =>
|
|
75
75
|
require("../dependencies/CssImportDependency"),
|
|
76
|
-
"dependencies/
|
|
77
|
-
require("../dependencies/
|
|
78
|
-
"dependencies/
|
|
79
|
-
require("../dependencies/
|
|
76
|
+
"dependencies/CssIcssLocalIdentifierDependency": () =>
|
|
77
|
+
require("../dependencies/CssIcssLocalIdentifierDependency"),
|
|
78
|
+
"dependencies/CssIcssSelfLocalIdentifierDependency": () =>
|
|
79
|
+
require("../dependencies/CssIcssSelfLocalIdentifierDependency"),
|
|
80
80
|
"dependencies/CssIcssImportDependency": () =>
|
|
81
81
|
require("../dependencies/CssIcssImportDependency"),
|
|
82
82
|
"dependencies/CssIcssExportDependency": () =>
|
|
@@ -77,7 +77,6 @@ class EnableWasmLoadingPlugin {
|
|
|
77
77
|
switch (type) {
|
|
78
78
|
case "fetch": {
|
|
79
79
|
if (compiler.options.experiments.syncWebAssembly) {
|
|
80
|
-
// TODO webpack 6 remove FetchCompileWasmPlugin
|
|
81
80
|
const FetchCompileWasmPlugin = require("../web/FetchCompileWasmPlugin");
|
|
82
81
|
|
|
83
82
|
new FetchCompileWasmPlugin({
|
|
@@ -95,7 +94,6 @@ class EnableWasmLoadingPlugin {
|
|
|
95
94
|
}
|
|
96
95
|
case "async-node": {
|
|
97
96
|
if (compiler.options.experiments.syncWebAssembly) {
|
|
98
|
-
// TODO webpack 6 remove ReadFileCompileWasmPlugin
|
|
99
97
|
const ReadFileCompileWasmPlugin = require("../node/ReadFileCompileWasmPlugin");
|
|
100
98
|
|
|
101
99
|
new ReadFileCompileWasmPlugin({
|
|
@@ -119,9 +117,17 @@ class EnableWasmLoadingPlugin {
|
|
|
119
117
|
break;
|
|
120
118
|
}
|
|
121
119
|
case "universal": {
|
|
122
|
-
|
|
120
|
+
if (compiler.options.experiments.syncWebAssembly) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
"Universal wasm loading type is only supported by asynchronous web assembly."
|
|
123
|
+
);
|
|
124
|
+
}
|
|
123
125
|
|
|
124
|
-
|
|
126
|
+
if (compiler.options.experiments.asyncWebAssembly) {
|
|
127
|
+
const UniversalCompileAsyncWasmPlugin = require("../wasm-async/UniversalCompileAsyncWasmPlugin");
|
|
128
|
+
|
|
129
|
+
new UniversalCompileAsyncWasmPlugin().apply(compiler);
|
|
130
|
+
}
|
|
125
131
|
break;
|
|
126
132
|
}
|
|
127
133
|
default:
|
|
@@ -20,7 +20,7 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe
|
|
|
20
20
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @typedef {{ request: string, importVar: string }} ImportObjRequestItem
|
|
23
|
+
* @typedef {{ request: string, importVar: string, dependency: WebAssemblyImportDependency }} ImportObjRequestItem
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
@@ -70,7 +70,8 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
70
70
|
if (!depModules.has(module)) {
|
|
71
71
|
depModules.set(module, {
|
|
72
72
|
request: dep.request,
|
|
73
|
-
importVar: `WEBPACK_IMPORTED_MODULE_${depModules.size}
|
|
73
|
+
importVar: `WEBPACK_IMPORTED_MODULE_${depModules.size}`,
|
|
74
|
+
dependency: dep
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
let list = wasmDepsByRequest.get(dep.request);
|
|
@@ -87,7 +88,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
87
88
|
|
|
88
89
|
const importStatements = Array.from(
|
|
89
90
|
depModules,
|
|
90
|
-
([importedModule, { request, importVar }]) => {
|
|
91
|
+
([importedModule, { request, importVar, dependency }]) => {
|
|
91
92
|
if (moduleGraph.isAsync(importedModule)) {
|
|
92
93
|
promises.push(importVar);
|
|
93
94
|
}
|
|
@@ -99,7 +100,8 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
99
100
|
request,
|
|
100
101
|
originModule: module,
|
|
101
102
|
importVar,
|
|
102
|
-
runtimeRequirements
|
|
103
|
+
runtimeRequirements,
|
|
104
|
+
dependency
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
);
|
|
@@ -132,7 +134,8 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
132
134
|
importVar,
|
|
133
135
|
initFragments,
|
|
134
136
|
runtime,
|
|
135
|
-
runtimeRequirements
|
|
137
|
+
runtimeRequirements,
|
|
138
|
+
dependency: dep
|
|
136
139
|
})}`;
|
|
137
140
|
});
|
|
138
141
|
return Template.asString([
|
|
@@ -26,15 +26,6 @@ const decoderOpts = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
class WebAssemblyParser extends Parser {
|
|
29
|
-
/**
|
|
30
|
-
* @param {{}=} options parser options
|
|
31
|
-
*/
|
|
32
|
-
constructor(options) {
|
|
33
|
-
super();
|
|
34
|
-
this.hooks = Object.freeze({});
|
|
35
|
-
this.options = options;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
29
|
/**
|
|
39
30
|
* @param {string | Buffer | PreparsedAst} source the source to parse
|
|
40
31
|
* @param {ParserState} state the parser state
|
|
@@ -71,6 +71,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
71
71
|
importedModules.set(
|
|
72
72
|
moduleGraph.getModule(dep),
|
|
73
73
|
(importData = {
|
|
74
|
+
dependency: moduleDep,
|
|
74
75
|
importVar: `m${index}`,
|
|
75
76
|
index,
|
|
76
77
|
request: (moduleDep && moduleDep.userRequest) || undefined,
|
|
@@ -106,7 +107,8 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
106
107
|
defaultInterop: true,
|
|
107
108
|
initFragments,
|
|
108
109
|
runtime,
|
|
109
|
-
runtimeRequirements
|
|
110
|
+
runtimeRequirements,
|
|
111
|
+
dependency: dep
|
|
110
112
|
})
|
|
111
113
|
);
|
|
112
114
|
}
|
|
@@ -138,7 +140,8 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
138
140
|
defaultInterop: true,
|
|
139
141
|
initFragments,
|
|
140
142
|
runtime,
|
|
141
|
-
runtimeRequirements
|
|
143
|
+
runtimeRequirements,
|
|
144
|
+
dependency: dep
|
|
142
145
|
})};`,
|
|
143
146
|
`if(WebAssembly.Global) ${exportProp} = ` +
|
|
144
147
|
`new WebAssembly.Global({ value: ${JSON.stringify(
|
|
@@ -154,7 +157,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
154
157
|
const importsCode = Template.asString(
|
|
155
158
|
Array.from(
|
|
156
159
|
importedModules,
|
|
157
|
-
([module, { importVar, request, reexports }]) => {
|
|
160
|
+
([module, { importVar, request, reexports, dependency }]) => {
|
|
158
161
|
const importStatement = runtimeTemplate.importStatement({
|
|
159
162
|
module,
|
|
160
163
|
moduleGraph,
|
|
@@ -162,7 +165,8 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
162
165
|
request,
|
|
163
166
|
importVar,
|
|
164
167
|
originModule: module,
|
|
165
|
-
runtimeRequirements
|
|
168
|
+
runtimeRequirements,
|
|
169
|
+
dependency
|
|
166
170
|
});
|
|
167
171
|
return importStatement[0] + importStatement[1] + reexports.join("\n");
|
|
168
172
|
}
|
|
@@ -63,15 +63,6 @@ const decoderOpts = {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
class WebAssemblyParser extends Parser {
|
|
66
|
-
/**
|
|
67
|
-
* @param {{}=} options parser options
|
|
68
|
-
*/
|
|
69
|
-
constructor(options) {
|
|
70
|
-
super();
|
|
71
|
-
this.hooks = Object.freeze({});
|
|
72
|
-
this.options = options;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
66
|
/**
|
|
76
67
|
* @param {string | Buffer | PreparsedAst} source the source to parse
|
|
77
68
|
* @param {ParserState} state the parser state
|
|
@@ -17,8 +17,6 @@ const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRunt
|
|
|
17
17
|
* @property {boolean=} mangleImports mangle imports
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
// TODO webpack 6 remove
|
|
21
|
-
|
|
22
20
|
const PLUGIN_NAME = "FetchCompileWasmPlugin";
|
|
23
21
|
|
|
24
22
|
class FetchCompileWasmPlugin {
|
|
@@ -69,7 +69,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
69
69
|
if (options && options.baseUri) {
|
|
70
70
|
return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
|
|
71
71
|
}
|
|
72
|
-
return `${RuntimeGlobals.baseURI} = (document && document.baseURI) || self.location.href;`;
|
|
72
|
+
return `${RuntimeGlobals.baseURI} = (typeof document !== 'undefined' && document.baseURI) || self.location.href;`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
package/lib/webpack.js
CHANGED
|
@@ -106,107 +106,110 @@ const createCompiler = (rawOptions, compilerIndex) => {
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* @
|
|
109
|
+
* @template T
|
|
110
|
+
* @param {T[] | T} options options
|
|
111
|
+
* @returns {T[]} array of options
|
|
112
|
+
*/
|
|
113
|
+
const asArray = (options) =>
|
|
114
|
+
Array.isArray(options) ? [...options] : [options];
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @overload
|
|
110
118
|
* @param {WebpackOptions} options options object
|
|
111
|
-
* @param {Callback<Stats
|
|
119
|
+
* @param {Callback<Stats>} callback callback
|
|
112
120
|
* @returns {Compiler | null} the compiler object
|
|
113
121
|
*/
|
|
114
|
-
|
|
115
122
|
/**
|
|
116
|
-
* @
|
|
123
|
+
* @overload
|
|
124
|
+
* @param {WebpackOptions} options options object
|
|
125
|
+
* @returns {Compiler} the compiler object
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* @overload
|
|
117
129
|
* @param {MultiWebpackOptions} options options objects
|
|
118
|
-
* @param {Callback<MultiStats
|
|
130
|
+
* @param {Callback<MultiStats>} callback callback
|
|
119
131
|
* @returns {MultiCompiler | null} the multi compiler object
|
|
120
132
|
*/
|
|
121
|
-
|
|
122
133
|
/**
|
|
123
|
-
* @
|
|
124
|
-
* @param {
|
|
125
|
-
* @returns {
|
|
134
|
+
* @overload
|
|
135
|
+
* @param {MultiWebpackOptions} options options objects
|
|
136
|
+
* @returns {MultiCompiler} the multi compiler object
|
|
126
137
|
*/
|
|
127
|
-
const asArray = (options) =>
|
|
128
|
-
Array.isArray(options) ? [...options] : [options];
|
|
129
|
-
|
|
130
138
|
/**
|
|
131
|
-
* @callback WebpackCallback
|
|
132
139
|
* @param {WebpackOptions | MultiWebpackOptions} options options
|
|
133
140
|
* @param {Callback<Stats> & Callback<MultiStats>=} callback callback
|
|
134
141
|
* @returns {Compiler | MultiCompiler | null} Compiler or MultiCompiler
|
|
135
142
|
*/
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/** @type {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
/** @type {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
);
|
|
166
|
-
watch = options.some((options) => options.watch);
|
|
167
|
-
watchOptions = options.map((options) => options.watchOptions || {});
|
|
168
|
-
} else {
|
|
169
|
-
const webpackOptions = /** @type {WebpackOptions} */ (options);
|
|
170
|
-
/** @type {Compiler} */
|
|
171
|
-
compiler = createCompiler(webpackOptions);
|
|
172
|
-
watch = webpackOptions.watch;
|
|
173
|
-
watchOptions = webpackOptions.watchOptions || {};
|
|
174
|
-
}
|
|
175
|
-
return { compiler, watch, watchOptions };
|
|
176
|
-
};
|
|
177
|
-
if (callback) {
|
|
178
|
-
try {
|
|
179
|
-
const { compiler, watch, watchOptions } = create();
|
|
180
|
-
if (watch) {
|
|
181
|
-
compiler.watch(watchOptions, callback);
|
|
182
|
-
} else {
|
|
183
|
-
compiler.run((err, stats) => {
|
|
184
|
-
compiler.close((err2) => {
|
|
185
|
-
callback(
|
|
186
|
-
err || err2,
|
|
187
|
-
/** @type {options extends WebpackOptions ? Stats : MultiStats} */
|
|
188
|
-
(stats)
|
|
189
|
-
);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return compiler;
|
|
194
|
-
} catch (err) {
|
|
195
|
-
process.nextTick(() => callback(/** @type {Error} */ (err)));
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
143
|
+
const webpack = (options, callback) => {
|
|
144
|
+
const create = () => {
|
|
145
|
+
if (
|
|
146
|
+
!asArray(/** @type {WebpackOptions} */ (options)).every(
|
|
147
|
+
webpackOptionsSchemaCheck
|
|
148
|
+
)
|
|
149
|
+
) {
|
|
150
|
+
getValidateSchema()(webpackOptionsSchema, options);
|
|
151
|
+
util.deprecate(
|
|
152
|
+
() => {},
|
|
153
|
+
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
|
154
|
+
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
|
|
155
|
+
)();
|
|
156
|
+
}
|
|
157
|
+
/** @type {MultiCompiler|Compiler} */
|
|
158
|
+
let compiler;
|
|
159
|
+
/** @type {boolean | undefined} */
|
|
160
|
+
let watch = false;
|
|
161
|
+
/** @type {WatchOptions | WatchOptions[]} */
|
|
162
|
+
let watchOptions;
|
|
163
|
+
if (Array.isArray(options)) {
|
|
164
|
+
/** @type {MultiCompiler} */
|
|
165
|
+
compiler = createMultiCompiler(
|
|
166
|
+
options,
|
|
167
|
+
/** @type {MultiCompilerOptions} */
|
|
168
|
+
(options)
|
|
169
|
+
);
|
|
170
|
+
watch = options.some((options) => options.watch);
|
|
171
|
+
watchOptions = options.map((options) => options.watchOptions || {});
|
|
198
172
|
} else {
|
|
199
|
-
const
|
|
173
|
+
const webpackOptions = /** @type {WebpackOptions} */ (options);
|
|
174
|
+
/** @type {Compiler} */
|
|
175
|
+
compiler = createCompiler(webpackOptions);
|
|
176
|
+
watch = webpackOptions.watch;
|
|
177
|
+
watchOptions = webpackOptions.watchOptions || {};
|
|
178
|
+
}
|
|
179
|
+
return { compiler, watch, watchOptions };
|
|
180
|
+
};
|
|
181
|
+
if (callback) {
|
|
182
|
+
try {
|
|
183
|
+
const { compiler, watch, watchOptions } = create();
|
|
200
184
|
if (watch) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
185
|
+
compiler.watch(watchOptions, callback);
|
|
186
|
+
} else {
|
|
187
|
+
compiler.run((err, stats) => {
|
|
188
|
+
compiler.close((err2) => {
|
|
189
|
+
callback(
|
|
190
|
+
err || err2,
|
|
191
|
+
/** @type {options extends WebpackOptions ? Stats : MultiStats} */
|
|
192
|
+
(stats)
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
206
196
|
}
|
|
207
197
|
return compiler;
|
|
198
|
+
} catch (err) {
|
|
199
|
+
process.nextTick(() => callback(/** @type {Error} */ (err)));
|
|
200
|
+
return null;
|
|
208
201
|
}
|
|
202
|
+
} else {
|
|
203
|
+
const { compiler, watch } = create();
|
|
204
|
+
if (watch) {
|
|
205
|
+
util.deprecate(
|
|
206
|
+
() => {},
|
|
207
|
+
"A 'callback' argument needs to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
|
|
208
|
+
"DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
|
|
209
|
+
)();
|
|
210
|
+
}
|
|
211
|
+
return compiler;
|
|
209
212
|
}
|
|
210
|
-
|
|
213
|
+
};
|
|
211
214
|
|
|
212
215
|
module.exports = webpack;
|
package/module.d.ts
CHANGED
|
@@ -161,10 +161,15 @@ declare namespace webpack {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
interface ImportMetaEnv {
|
|
165
|
+
[key: string]: string | boolean | undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
164
168
|
interface ImportMeta {
|
|
165
169
|
url: string;
|
|
166
170
|
webpack: number;
|
|
167
171
|
webpackHot: webpack.Hot;
|
|
172
|
+
env: ImportMetaEnv;
|
|
168
173
|
webpackContext: (
|
|
169
174
|
request: string,
|
|
170
175
|
options?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.103.0",
|
|
4
4
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
|
5
5
|
"homepage": "https://github.com/webpack/webpack",
|
|
6
6
|
"bugs": "https://github.com/webpack/webpack/issues",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@webassemblyjs/wasm-parser": "^1.14.1",
|
|
90
90
|
"acorn": "^8.15.0",
|
|
91
91
|
"acorn-import-phases": "^1.0.3",
|
|
92
|
-
"browserslist": "^4.
|
|
92
|
+
"browserslist": "^4.26.3",
|
|
93
93
|
"chrome-trace-event": "^1.0.2",
|
|
94
94
|
"enhanced-resolve": "^5.17.3",
|
|
95
95
|
"es-module-lexer": "^1.2.1",
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"glob-to-regexp": "^0.4.1",
|
|
99
99
|
"graceful-fs": "^4.2.11",
|
|
100
100
|
"json-parse-even-better-errors": "^2.3.1",
|
|
101
|
-
"loader-runner": "^4.
|
|
101
|
+
"loader-runner": "^4.3.1",
|
|
102
102
|
"mime-types": "^2.1.27",
|
|
103
103
|
"neo-async": "^2.6.2",
|
|
104
|
-
"schema-utils": "^4.3.
|
|
105
|
-
"tapable": "^2.
|
|
104
|
+
"schema-utils": "^4.3.3",
|
|
105
|
+
"tapable": "^2.3.0",
|
|
106
106
|
"terser-webpack-plugin": "^5.3.11",
|
|
107
107
|
"watchpack": "^2.4.4",
|
|
108
108
|
"webpack-sources": "^3.3.3"
|
|
@@ -110,17 +110,17 @@
|
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@babel/core": "^7.27.1",
|
|
112
112
|
"@babel/preset-react": "^7.27.1",
|
|
113
|
-
"@codspeed/core": "^
|
|
114
|
-
"@eslint/js": "^9.
|
|
115
|
-
"@eslint/markdown": "^7.
|
|
116
|
-
"@stylistic/eslint-plugin": "^5.
|
|
113
|
+
"@codspeed/core": "^5.0.1",
|
|
114
|
+
"@eslint/js": "^9.37.0",
|
|
115
|
+
"@eslint/markdown": "^7.4.0",
|
|
116
|
+
"@stylistic/eslint-plugin": "^5.4.0",
|
|
117
117
|
"@types/glob-to-regexp": "^0.4.4",
|
|
118
118
|
"@types/graceful-fs": "^4.1.9",
|
|
119
119
|
"@types/jest": "^30.0.0",
|
|
120
120
|
"@types/mime-types": "^2.1.4",
|
|
121
|
-
"@types/node": "^24.1
|
|
121
|
+
"@types/node": "^24.9.1",
|
|
122
122
|
"@types/xxhashjs": "^0.2.4",
|
|
123
|
-
"assemblyscript": "^0.28.
|
|
123
|
+
"assemblyscript": "^0.28.9",
|
|
124
124
|
"babel-loader": "^10.0.0",
|
|
125
125
|
"bundle-loader": "^0.5.6",
|
|
126
126
|
"coffee-loader": "^5.0.0",
|
|
@@ -131,60 +131,62 @@
|
|
|
131
131
|
"date-fns": "^4.0.0",
|
|
132
132
|
"es5-ext": "^0.10.53",
|
|
133
133
|
"es6-promise-polyfill": "^1.2.0",
|
|
134
|
-
"eslint": "^9.
|
|
134
|
+
"eslint": "^9.37.0",
|
|
135
135
|
"eslint-config-prettier": "^10.1.1",
|
|
136
136
|
"eslint-config-webpack": "^4.5.1",
|
|
137
137
|
"eslint-plugin-import": "^2.32.0",
|
|
138
138
|
"eslint-plugin-jest": "^29.0.1",
|
|
139
139
|
"eslint-plugin-jsdoc": "^51.2.3",
|
|
140
|
-
"eslint-plugin-n": "^17.
|
|
140
|
+
"eslint-plugin-n": "^17.23.1",
|
|
141
141
|
"eslint-plugin-prettier": "^5.5.0",
|
|
142
|
-
"eslint-plugin-unicorn": "^
|
|
142
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
143
143
|
"file-loader": "^6.0.0",
|
|
144
144
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
145
145
|
"globals": "^16.0.0",
|
|
146
146
|
"hash-wasm": "^4.9.0",
|
|
147
147
|
"husky": "^9.0.11",
|
|
148
148
|
"istanbul": "^0.4.5",
|
|
149
|
-
"jest": "^30.
|
|
150
|
-
"jest-circus": "^30.
|
|
151
|
-
"jest-cli": "^30.
|
|
152
|
-
"jest-diff": "^30.
|
|
153
|
-
"jest-environment-node": "^30.
|
|
149
|
+
"jest": "^30.2.0",
|
|
150
|
+
"jest-circus": "^30.2.0",
|
|
151
|
+
"jest-cli": "^30.2.0",
|
|
152
|
+
"jest-diff": "^30.2.0",
|
|
153
|
+
"jest-environment-node": "^30.2.0",
|
|
154
154
|
"jest-junit": "^16.0.0",
|
|
155
155
|
"json-loader": "^0.5.7",
|
|
156
156
|
"json5": "^2.1.3",
|
|
157
|
-
"less": "^4.
|
|
157
|
+
"less": "^4.4.2",
|
|
158
158
|
"less-loader": "^12.2.0",
|
|
159
|
-
"lint-staged": "^16.
|
|
159
|
+
"lint-staged": "^16.2.3",
|
|
160
160
|
"lodash": "^4.17.19",
|
|
161
161
|
"lodash-es": "^4.17.15",
|
|
162
|
-
"memfs": "^4.
|
|
162
|
+
"memfs": "^4.49.0",
|
|
163
|
+
"meriyah": "^6.1.4",
|
|
163
164
|
"mini-css-extract-plugin": "^2.9.0",
|
|
164
165
|
"mini-svg-data-uri": "^1.2.3",
|
|
165
166
|
"node-gyp": "^11.2.0",
|
|
166
167
|
"nyc": "^17.1.0",
|
|
167
168
|
"open-cli": "^8.0.0",
|
|
169
|
+
"pkg-pr-new": "^0.0.60",
|
|
168
170
|
"prettier": "^3.6.0",
|
|
169
171
|
"prettier-2": "npm:prettier@^2",
|
|
170
172
|
"pretty-format": "^30.0.5",
|
|
171
173
|
"pug": "^3.0.3",
|
|
172
174
|
"pug-loader": "^2.4.0",
|
|
173
175
|
"raw-loader": "^4.0.1",
|
|
174
|
-
"react": "^19.
|
|
175
|
-
"react-dom": "^19.
|
|
176
|
+
"react": "^19.2.0",
|
|
177
|
+
"react-dom": "^19.2.0",
|
|
176
178
|
"rimraf": "^3.0.2",
|
|
177
179
|
"script-loader": "^0.7.2",
|
|
178
180
|
"simple-git": "^3.28.0",
|
|
179
181
|
"strip-ansi": "^6.0.0",
|
|
180
182
|
"style-loader": "^4.0.0",
|
|
181
183
|
"terser": "^5.43.1",
|
|
182
|
-
"three": "^0.
|
|
184
|
+
"three": "^0.181.0",
|
|
183
185
|
"tinybench": "^5.0.0",
|
|
184
186
|
"toml": "^3.0.0",
|
|
185
187
|
"tooling": "webpack/tooling#v1.24.3",
|
|
186
188
|
"ts-loader": "^9.5.1",
|
|
187
|
-
"typescript": "^5.9.
|
|
189
|
+
"typescript": "^5.9.3",
|
|
188
190
|
"url-loader": "^4.1.0",
|
|
189
191
|
"wast-loader": "^1.12.1",
|
|
190
192
|
"webassembly-feature": "1.3.0",
|