webpack 5.52.0 → 5.55.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/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 +549 -144
- package/lib/Compiler.js +12 -4
- package/lib/Dependency.js +11 -0
- package/lib/DependencyTemplates.js +8 -2
- package/lib/EvalDevToolModulePlugin.js +2 -1
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/ExternalModule.js +18 -9
- package/lib/FileSystemInfo.js +101 -170
- package/lib/FlagDependencyExportsPlugin.js +25 -16
- package/lib/JavascriptMetaInfoPlugin.js +6 -1
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleFilenameHelpers.js +21 -7
- package/lib/ModuleGraph.js +90 -21
- package/lib/NodeStuffInWebError.js +34 -0
- package/lib/NodeStuffPlugin.js +59 -16
- package/lib/NormalModuleFactory.js +8 -43
- package/lib/SourceMapDevToolPlugin.js +7 -3
- package/lib/WebpackOptionsApply.js +19 -1
- package/lib/cache/PackFileCacheStrategy.js +183 -53
- package/lib/cache/getLazyHashedEtag.js +35 -8
- package/lib/config/defaults.js +32 -12
- package/lib/dependencies/CachedConstDependency.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +19 -9
- package/lib/dependencies/CommonJsFullRequireDependency.js +11 -9
- package/lib/dependencies/ConstDependency.js +12 -4
- package/lib/dependencies/ContextDependency.js +8 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +179 -163
- package/lib/dependencies/HarmonyImportDependency.js +4 -1
- package/lib/dependencies/JsonExportsDependency.js +7 -1
- package/lib/dependencies/ModuleDecoratorDependency.js +5 -2
- package/lib/dependencies/ModuleDependency.js +8 -0
- package/lib/dependencies/NullDependency.js +8 -4
- package/lib/dependencies/ProvidedDependency.js +6 -2
- package/lib/dependencies/PureExpressionDependency.js +5 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +9 -0
- 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/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/WeakTupleMap.js +95 -92
- 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 +1 -0
- package/lib/util/serialization.js +10 -6
- package/package.json +11 -7
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +19 -3
- 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 +211 -25
package/lib/Compiler.js
CHANGED
@@ -42,6 +42,7 @@ const { isSourceEqual } = require("./util/source");
|
|
42
42
|
/** @typedef {import("./Chunk")} Chunk */
|
43
43
|
/** @typedef {import("./FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
|
44
44
|
/** @typedef {import("./Module")} Module */
|
45
|
+
/** @typedef {import("./util/WeakTupleMap")} WeakTupleMap */
|
45
46
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
46
47
|
/** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
47
48
|
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
@@ -247,6 +248,9 @@ class Compiler {
|
|
247
248
|
|
248
249
|
this.cache = new Cache();
|
249
250
|
|
251
|
+
/** @type {WeakMap<Module, { hash: string, memCache: WeakTupleMap }> | undefined} */
|
252
|
+
this.moduleMemCaches = undefined;
|
253
|
+
|
250
254
|
this.compilerPath = "";
|
251
255
|
|
252
256
|
/** @type {boolean} */
|
@@ -276,7 +280,11 @@ class Compiler {
|
|
276
280
|
* @returns {CacheFacade} the cache facade instance
|
277
281
|
*/
|
278
282
|
getCache(name) {
|
279
|
-
return new CacheFacade(
|
283
|
+
return new CacheFacade(
|
284
|
+
this.cache,
|
285
|
+
`${this.compilerPath}${name}`,
|
286
|
+
this.options.output.hashFunction
|
287
|
+
);
|
280
288
|
}
|
281
289
|
|
282
290
|
/**
|
@@ -1027,9 +1035,9 @@ ${other}`);
|
|
1027
1035
|
return !!this.parentCompilation;
|
1028
1036
|
}
|
1029
1037
|
|
1030
|
-
createCompilation() {
|
1038
|
+
createCompilation(params) {
|
1031
1039
|
this._cleanupLastCompilation();
|
1032
|
-
return (this._lastCompilation = new Compilation(this));
|
1040
|
+
return (this._lastCompilation = new Compilation(this, params));
|
1033
1041
|
}
|
1034
1042
|
|
1035
1043
|
/**
|
@@ -1037,7 +1045,7 @@ ${other}`);
|
|
1037
1045
|
* @returns {Compilation} the created compilation
|
1038
1046
|
*/
|
1039
1047
|
newCompilation(params) {
|
1040
|
-
const compilation = this.createCompilation();
|
1048
|
+
const compilation = this.createCompilation(params);
|
1041
1049
|
compilation.name = this.name;
|
1042
1050
|
compilation.records = this.records;
|
1043
1051
|
this.hooks.thisCompilation.call(compilation, params);
|
package/lib/Dependency.js
CHANGED
@@ -78,6 +78,8 @@ const memoize = require("./util/memoize");
|
|
78
78
|
* @property {boolean=} canMangle when false, referenced export can not be mangled, defaults to true
|
79
79
|
*/
|
80
80
|
|
81
|
+
const TRANSITIVE = Symbol("transitive");
|
82
|
+
|
81
83
|
const getIgnoredModule = memoize(() => {
|
82
84
|
const RawModule = require("./RawModule");
|
83
85
|
return new RawModule("/* (ignored) */", `ignored`, `(ignored)`);
|
@@ -175,6 +177,13 @@ class Dependency {
|
|
175
177
|
return null;
|
176
178
|
}
|
177
179
|
|
180
|
+
/**
|
181
|
+
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
182
|
+
*/
|
183
|
+
couldAffectReferencingModule() {
|
184
|
+
return TRANSITIVE;
|
185
|
+
}
|
186
|
+
|
178
187
|
/**
|
179
188
|
* Returns the referenced module and export
|
180
189
|
* @deprecated
|
@@ -322,4 +331,6 @@ Object.defineProperty(Dependency.prototype, "disconnect", {
|
|
322
331
|
}
|
323
332
|
});
|
324
333
|
|
334
|
+
Dependency.TRANSITIVE = TRANSITIVE;
|
335
|
+
|
325
336
|
module.exports = Dependency;
|
@@ -9,14 +9,20 @@ const createHash = require("./util/createHash");
|
|
9
9
|
|
10
10
|
/** @typedef {import("./Dependency")} Dependency */
|
11
11
|
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
12
|
+
/** @typedef {typeof import("./util/Hash")} Hash */
|
13
|
+
|
12
14
|
/** @typedef {new (...args: any[]) => Dependency} DependencyConstructor */
|
13
15
|
|
14
16
|
class DependencyTemplates {
|
15
|
-
|
17
|
+
/**
|
18
|
+
* @param {string | Hash} hashFunction the hash function to use
|
19
|
+
*/
|
20
|
+
constructor(hashFunction = "md4") {
|
16
21
|
/** @type {Map<Function, DependencyTemplate>} */
|
17
22
|
this._map = new Map();
|
18
23
|
/** @type {string} */
|
19
24
|
this._hash = "31d6cfe0d16ae931b73c59d7e0c089c0";
|
25
|
+
this._hashFunction = hashFunction;
|
20
26
|
}
|
21
27
|
|
22
28
|
/**
|
@@ -41,7 +47,7 @@ class DependencyTemplates {
|
|
41
47
|
* @returns {void}
|
42
48
|
*/
|
43
49
|
updateHash(part) {
|
44
|
-
const hash = createHash(
|
50
|
+
const hash = createHash(this._hashFunction);
|
45
51
|
hash.update(this._hash);
|
46
52
|
hash.update(part);
|
47
53
|
this._hash = /** @type {string} */ (hash.digest("hex"));
|
package/lib/ExternalModule.js
CHANGED
@@ -38,6 +38,7 @@ const { register } = require("./util/serialization");
|
|
38
38
|
/** @typedef {import("./WebpackError")} WebpackError */
|
39
39
|
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
40
40
|
/** @typedef {import("./util/Hash")} Hash */
|
41
|
+
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
41
42
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
42
43
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
43
44
|
|
@@ -160,11 +161,16 @@ const getSourceForImportExternal = (moduleAndSpecifiers, runtimeTemplate) => {
|
|
160
161
|
};
|
161
162
|
|
162
163
|
class ModuleExternalInitFragment extends InitFragment {
|
163
|
-
|
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") {
|
164
170
|
if (ident === undefined) {
|
165
171
|
ident = Template.toIdentifier(request);
|
166
172
|
if (ident !== request) {
|
167
|
-
ident += `_${createHash(
|
173
|
+
ident += `_${createHash(hashFunction)
|
168
174
|
.update(request)
|
169
175
|
.digest("hex")
|
170
176
|
.slice(0, 8)}`;
|
@@ -230,21 +236,25 @@ const generateModuleRemapping = (input, exportsInfo, runtime) => {
|
|
230
236
|
};
|
231
237
|
|
232
238
|
/**
|
233
|
-
* @param {string|number} id the module id
|
234
239
|
* @param {string|string[]} moduleAndSpecifiers the module request
|
235
240
|
* @param {ExportsInfo} exportsInfo exports info of this module
|
236
241
|
* @param {RuntimeSpec} runtime the runtime
|
242
|
+
* @param {string | HashConstructor=} hashFunction the hash function to use
|
237
243
|
* @returns {SourceData} the generated source
|
238
244
|
*/
|
239
245
|
const getSourceForModuleExternal = (
|
240
|
-
id,
|
241
246
|
moduleAndSpecifiers,
|
242
247
|
exportsInfo,
|
243
|
-
runtime
|
248
|
+
runtime,
|
249
|
+
hashFunction
|
244
250
|
) => {
|
245
251
|
if (!Array.isArray(moduleAndSpecifiers))
|
246
252
|
moduleAndSpecifiers = [moduleAndSpecifiers];
|
247
|
-
const initFragment = new ModuleExternalInitFragment(
|
253
|
+
const initFragment = new ModuleExternalInitFragment(
|
254
|
+
moduleAndSpecifiers[0],
|
255
|
+
undefined,
|
256
|
+
hashFunction
|
257
|
+
);
|
248
258
|
const baseAccess = `${initFragment.getNamespaceIdentifier()}${propertyAccess(
|
249
259
|
moduleAndSpecifiers,
|
250
260
|
1
|
@@ -566,12 +576,11 @@ class ExternalModule extends Module {
|
|
566
576
|
"The target environment doesn't support EcmaScriptModule syntax so it's not possible to use external type 'module'"
|
567
577
|
);
|
568
578
|
}
|
569
|
-
const id = chunkGraph.getModuleId(this);
|
570
579
|
return getSourceForModuleExternal(
|
571
|
-
id !== null ? id : this.identifier(),
|
572
580
|
request,
|
573
581
|
moduleGraph.getExportsInfo(this),
|
574
|
-
runtime
|
582
|
+
runtime,
|
583
|
+
runtimeTemplate.outputOptions.hashFunction
|
575
584
|
);
|
576
585
|
}
|
577
586
|
case "var":
|