webpack 5.51.2 → 5.54.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/lib/AsyncDependenciesBlock.js +9 -2
- package/lib/CacheFacade.js +10 -3
- package/lib/ChunkGraph.js +19 -8
- package/lib/CodeGenerationResults.js +7 -2
- package/lib/Compilation.js +207 -16
- package/lib/Compiler.js +9 -1
- package/lib/DependencyTemplates.js +8 -2
- package/lib/EvalDevToolModulePlugin.js +2 -1
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/ExternalModule.js +36 -18
- package/lib/FileSystemInfo.js +101 -170
- package/lib/FlagDependencyExportsPlugin.js +43 -16
- package/lib/InitFragment.js +23 -0
- package/lib/JavascriptMetaInfoPlugin.js +6 -1
- package/lib/MemCache.js +45 -0
- package/lib/ModuleFilenameHelpers.js +21 -7
- package/lib/NodeStuffInWebError.js +34 -0
- package/lib/NodeStuffPlugin.js +59 -16
- package/lib/NormalModuleFactory.js +7 -4
- package/lib/SourceMapDevToolPlugin.js +7 -3
- package/lib/WebpackOptionsApply.js +20 -4
- package/lib/cache/PackFileCacheStrategy.js +183 -53
- package/lib/cache/getLazyHashedEtag.js +35 -8
- package/lib/config/defaults.js +32 -13
- package/lib/dependencies/CachedConstDependency.js +4 -3
- package/lib/dependencies/ConstDependency.js +12 -4
- package/lib/dependencies/JsonExportsDependency.js +7 -1
- package/lib/dependencies/LoaderPlugin.js +94 -98
- package/lib/dependencies/ModuleDecoratorDependency.js +5 -2
- package/lib/dependencies/ProvidedDependency.js +6 -2
- package/lib/dependencies/PureExpressionDependency.js +5 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/ids/IdHelpers.js +21 -8
- package/lib/ids/NamedChunkIdsPlugin.js +3 -0
- package/lib/ids/NamedModuleIdsPlugin.js +3 -1
- package/lib/index.js +6 -0
- package/lib/javascript/BasicEvaluatedExpression.js +3 -0
- package/lib/javascript/JavascriptParser.js +22 -4
- package/lib/javascript/JavascriptParserHelpers.js +0 -2
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +25 -4
- package/lib/optimize/InnerGraph.js +22 -2
- package/lib/optimize/MangleExportsPlugin.js +21 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +2 -1
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/serialization/BinaryMiddleware.js +11 -2
- package/lib/serialization/FileMiddleware.js +24 -7
- package/lib/serialization/ObjectMiddleware.js +23 -12
- package/lib/util/createHash.js +10 -0
- package/lib/util/hash/BatchedHash.js +65 -0
- package/lib/util/hash/xxhash64.js +154 -0
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/serialization.js +10 -6
- package/package.json +13 -9
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -5
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.json +20 -2
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.json +4 -2
- package/types.d.ts +166 -17
package/lib/ExternalModule.js
CHANGED
@@ -13,6 +13,7 @@ const Module = require("./Module");
|
|
13
13
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
14
14
|
const Template = require("./Template");
|
15
15
|
const StaticExportsDependency = require("./dependencies/StaticExportsDependency");
|
16
|
+
const createHash = require("./util/createHash");
|
16
17
|
const extractUrlAndGlobal = require("./util/extractUrlAndGlobal");
|
17
18
|
const makeSerializable = require("./util/makeSerializable");
|
18
19
|
const propertyAccess = require("./util/propertyAccess");
|
@@ -37,6 +38,7 @@ const { register } = require("./util/serialization");
|
|
37
38
|
/** @typedef {import("./WebpackError")} WebpackError */
|
38
39
|
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
39
40
|
/** @typedef {import("./util/Hash")} Hash */
|
41
|
+
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
40
42
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
41
43
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
42
44
|
|
@@ -159,18 +161,30 @@ const getSourceForImportExternal = (moduleAndSpecifiers, runtimeTemplate) => {
|
|
159
161
|
};
|
160
162
|
|
161
163
|
class ModuleExternalInitFragment extends InitFragment {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
164
|
+
/**
|
165
|
+
* @param {string} request import source
|
166
|
+
* @param {string=} ident recomputed ident
|
167
|
+
* @param {string | HashConstructor=} hashFunction the hash function to use
|
168
|
+
*/
|
169
|
+
constructor(request, ident, hashFunction = "md4") {
|
170
|
+
if (ident === undefined) {
|
171
|
+
ident = Template.toIdentifier(request);
|
172
|
+
if (ident !== request) {
|
173
|
+
ident += `_${createHash(hashFunction)
|
174
|
+
.update(request)
|
175
|
+
.digest("hex")
|
176
|
+
.slice(0, 8)}`;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
const identifier = `__WEBPACK_EXTERNAL_MODULE_${ident}__`;
|
166
180
|
super(
|
167
181
|
`import * as ${identifier} from ${JSON.stringify(request)};\n`,
|
168
182
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
169
183
|
0,
|
170
|
-
`external module import ${
|
184
|
+
`external module import ${ident}`
|
171
185
|
);
|
186
|
+
this._ident = ident;
|
172
187
|
this._identifier = identifier;
|
173
|
-
this._id = id;
|
174
188
|
this._request = request;
|
175
189
|
}
|
176
190
|
|
@@ -185,8 +199,8 @@ register(
|
|
185
199
|
"ModuleExternalInitFragment",
|
186
200
|
{
|
187
201
|
serialize(obj, { write }) {
|
188
|
-
write(obj._id);
|
189
202
|
write(obj._request);
|
203
|
+
write(obj._ident);
|
190
204
|
},
|
191
205
|
deserialize({ read }) {
|
192
206
|
return new ModuleExternalInitFragment(read(), read());
|
@@ -222,23 +236,24 @@ const generateModuleRemapping = (input, exportsInfo, runtime) => {
|
|
222
236
|
};
|
223
237
|
|
224
238
|
/**
|
225
|
-
* @param {string|number} id the module id
|
226
239
|
* @param {string|string[]} moduleAndSpecifiers the module request
|
227
240
|
* @param {ExportsInfo} exportsInfo exports info of this module
|
228
241
|
* @param {RuntimeSpec} runtime the runtime
|
242
|
+
* @param {string | HashConstructor=} hashFunction the hash function to use
|
229
243
|
* @returns {SourceData} the generated source
|
230
244
|
*/
|
231
245
|
const getSourceForModuleExternal = (
|
232
|
-
id,
|
233
246
|
moduleAndSpecifiers,
|
234
247
|
exportsInfo,
|
235
|
-
runtime
|
248
|
+
runtime,
|
249
|
+
hashFunction
|
236
250
|
) => {
|
237
251
|
if (!Array.isArray(moduleAndSpecifiers))
|
238
252
|
moduleAndSpecifiers = [moduleAndSpecifiers];
|
239
253
|
const initFragment = new ModuleExternalInitFragment(
|
240
|
-
|
241
|
-
|
254
|
+
moduleAndSpecifiers[0],
|
255
|
+
undefined,
|
256
|
+
hashFunction
|
242
257
|
);
|
243
258
|
const baseAccess = `${initFragment.getNamespaceIdentifier()}${propertyAccess(
|
244
259
|
moduleAndSpecifiers,
|
@@ -400,7 +415,7 @@ class ExternalModule extends Module {
|
|
400
415
|
* @returns {string} a unique identifier of the module
|
401
416
|
*/
|
402
417
|
identifier() {
|
403
|
-
return
|
418
|
+
return `external ${this.externalType} ${JSON.stringify(this.request)}`;
|
404
419
|
}
|
405
420
|
|
406
421
|
/**
|
@@ -531,18 +546,20 @@ class ExternalModule extends Module {
|
|
531
546
|
case "umd":
|
532
547
|
case "umd2":
|
533
548
|
case "system":
|
534
|
-
case "jsonp":
|
549
|
+
case "jsonp": {
|
550
|
+
const id = chunkGraph.getModuleId(this);
|
535
551
|
return getSourceForAmdOrUmdExternal(
|
536
|
-
|
552
|
+
id !== null ? id : this.identifier(),
|
537
553
|
this.isOptional(moduleGraph),
|
538
554
|
request,
|
539
555
|
runtimeTemplate
|
540
556
|
);
|
557
|
+
}
|
541
558
|
case "import":
|
542
559
|
return getSourceForImportExternal(request, runtimeTemplate);
|
543
560
|
case "script":
|
544
561
|
return getSourceForScriptExternal(request, runtimeTemplate);
|
545
|
-
case "module":
|
562
|
+
case "module": {
|
546
563
|
if (!this.buildInfo.module) {
|
547
564
|
if (!runtimeTemplate.supportsDynamicImport()) {
|
548
565
|
throw new Error(
|
@@ -560,11 +577,12 @@ class ExternalModule extends Module {
|
|
560
577
|
);
|
561
578
|
}
|
562
579
|
return getSourceForModuleExternal(
|
563
|
-
chunkGraph.getModuleId(this),
|
564
580
|
request,
|
565
581
|
moduleGraph.getExportsInfo(this),
|
566
|
-
runtime
|
582
|
+
runtime,
|
583
|
+
runtimeTemplate.outputOptions.hashFunction
|
567
584
|
);
|
585
|
+
}
|
568
586
|
case "var":
|
569
587
|
case "promise":
|
570
588
|
case "const":
|