webpack 5.37.0 → 5.39.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/README.md +5 -8
- package/bin/webpack.js +20 -5
- package/lib/AsyncDependencyToInitialChunkError.js +0 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +0 -2
- package/lib/Chunk.js +8 -5
- package/lib/ChunkRenderError.js +0 -2
- package/lib/CodeGenerationError.js +0 -2
- package/lib/CommentCompilationWarning.js +0 -2
- package/lib/Compilation.js +43 -55
- package/lib/Compiler.js +7 -4
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +0 -2
- package/lib/ContextModule.js +5 -4
- package/lib/ContextModuleFactory.js +3 -1
- package/lib/ContextReplacementPlugin.js +4 -3
- package/lib/DefinePlugin.js +16 -12
- package/lib/DllReferencePlugin.js +0 -2
- package/lib/EntryPlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/ExportsInfo.js +20 -13
- package/lib/FileSystemInfo.js +24 -30
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HarmonyLinkingError.js +0 -2
- package/lib/HookWebpackError.js +0 -1
- package/lib/HotModuleReplacementPlugin.js +27 -32
- package/lib/InvalidDependenciesModuleWarning.js +0 -2
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleBuildError.js +0 -2
- package/lib/ModuleDependencyError.js +0 -2
- package/lib/ModuleDependencyWarning.js +0 -2
- package/lib/ModuleError.js +0 -2
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/ModuleNotFoundError.js +0 -2
- package/lib/ModuleParseError.js +0 -2
- package/lib/ModuleRestoreError.js +0 -2
- package/lib/ModuleStoreError.js +0 -2
- package/lib/ModuleWarning.js +0 -2
- package/lib/MultiCompiler.js +31 -27
- package/lib/NoModeWarning.js +0 -2
- package/lib/NormalModule.js +26 -8
- package/lib/NormalModuleFactory.js +2 -0
- package/lib/RecordIdsPlugin.js +5 -4
- package/lib/ResolverFactory.js +10 -7
- package/lib/SourceMapDevToolPlugin.js +13 -14
- package/lib/Template.js +4 -2
- package/lib/UnsupportedFeatureWarning.js +0 -2
- package/lib/WarnDeprecatedOptionPlugin.js +0 -2
- package/lib/Watching.js +91 -47
- package/lib/WebpackError.js +0 -2
- package/lib/asset/AssetGenerator.js +46 -29
- package/lib/asset/AssetModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +21 -21
- package/lib/cache/PackFileCacheStrategy.js +12 -9
- package/lib/config/defaults.js +21 -10
- package/lib/config/normalization.js +8 -7
- package/lib/config/target.js +7 -2
- package/lib/debug/ProfilingPlugin.js +4 -3
- package/lib/dependencies/AMDRequireDependency.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -3
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -4
- package/lib/dependencies/CommonJsPlugin.js +8 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +10 -8
- package/lib/dependencies/ContextElementDependency.js +6 -1
- package/lib/dependencies/CriticalDependencyWarning.js +0 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -13
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +2 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -11
- package/lib/dependencies/ImportDependency.js +3 -3
- package/lib/dependencies/ImportParserPlugin.js +3 -4
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
- package/lib/dependencies/RequireEnsureDependency.js +3 -3
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +0 -2
- package/lib/dependencies/SystemPlugin.js +0 -2
- package/lib/dependencies/WorkerDependency.js +6 -6
- package/lib/dependencies/WorkerPlugin.js +18 -19
- package/lib/errors/BuildCycleError.js +0 -1
- package/lib/hmr/LazyCompilationPlugin.js +9 -5
- package/lib/ids/HashedModuleIdsPlugin.js +3 -3
- package/lib/ids/OccurrenceModuleIdsPlugin.js +2 -3
- package/lib/index.js +5 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -6
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -3
- package/lib/javascript/JavascriptGenerator.js +3 -1
- package/lib/javascript/JavascriptModulesPlugin.js +15 -23
- package/lib/javascript/JavascriptParser.js +10 -8
- package/lib/library/AssignLibraryPlugin.js +4 -2
- package/lib/node/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +19 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -4
- package/lib/optimize/ConcatenatedModule.js +31 -27
- package/lib/optimize/FlagIncludedChunksPlugin.js +4 -6
- package/lib/optimize/InnerGraph.js +9 -11
- package/lib/optimize/InnerGraphPlugin.js +3 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +7 -10
- package/lib/optimize/RealContentHashPlugin.js +14 -16
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -5
- package/lib/optimize/SplitChunksPlugin.js +13 -15
- package/lib/performance/AssetsOverSizeLimitWarning.js +0 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +0 -2
- package/lib/performance/NoAsyncChunksWarning.js +0 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -3
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +38 -37
- package/lib/schemes/DataUriPlugin.js +21 -2
- package/lib/serialization/BinaryMiddleware.js +5 -3
- package/lib/serialization/FileMiddleware.js +3 -1
- package/lib/serialization/ObjectMiddleware.js +11 -7
- package/lib/stats/DefaultStatsFactoryPlugin.js +7 -7
- package/lib/stats/DefaultStatsPrinterPlugin.js +11 -9
- package/lib/stats/StatsFactory.js +2 -1
- package/lib/stats/StatsPrinter.js +3 -3
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/cleverMerge.js +3 -1
- package/lib/util/comparators.js +13 -13
- package/lib/util/createHash.js +5 -4
- package/lib/util/identifier.js +2 -1
- package/lib/util/serialization.js +108 -59
- package/lib/validateSchema.js +5 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +4 -4
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +0 -2
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +0 -2
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyParser.js +6 -5
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -4
- package/lib/webpack.js +11 -7
- package/package.json +9 -6
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +76 -60
- package/types.d.ts +112 -262
- package/lib/util/DataURI.js +0 -32
@@ -194,24 +194,22 @@ class RealContentHashPlugin {
|
|
194
194
|
cacheAnalyse.getLazyHashedEtag(source),
|
195
195
|
Array.from(hashes).join("|")
|
196
196
|
);
|
197
|
-
[
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
197
|
+
[asset.referencedHashes, asset.ownHashes] =
|
198
|
+
await cacheAnalyse.providePromise(name, etag, () => {
|
199
|
+
const referencedHashes = new Set();
|
200
|
+
let ownHashes = new Set();
|
201
|
+
const inContent = content.match(hashRegExp);
|
202
|
+
if (inContent) {
|
203
|
+
for (const hash of inContent) {
|
204
|
+
if (hashes.has(hash)) {
|
205
|
+
ownHashes.add(hash);
|
206
|
+
continue;
|
207
|
+
}
|
208
|
+
referencedHashes.add(hash);
|
209
209
|
}
|
210
|
-
referencedHashes.add(hash);
|
211
210
|
}
|
212
|
-
|
213
|
-
|
214
|
-
});
|
211
|
+
return [referencedHashes, ownHashes];
|
212
|
+
});
|
215
213
|
})
|
216
214
|
);
|
217
215
|
const getDependencies = hash => {
|
@@ -86,11 +86,12 @@ class SideEffectsFlagPlugin {
|
|
86
86
|
if (module.factoryMeta === undefined) {
|
87
87
|
module.factoryMeta = {};
|
88
88
|
}
|
89
|
-
const hasSideEffects =
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
const hasSideEffects =
|
90
|
+
SideEffectsFlagPlugin.moduleHasSideEffects(
|
91
|
+
resolveData.relativePath,
|
92
|
+
sideEffects,
|
93
|
+
cache
|
94
|
+
);
|
94
95
|
module.factoryMeta.sideEffectFree = !hasSideEffects;
|
95
96
|
}
|
96
97
|
}
|
@@ -162,7 +162,10 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
162
162
|
|
163
163
|
const defaultGetName = /** @type {GetName} */ (() => {});
|
164
164
|
|
165
|
-
const deterministicGroupingForModules =
|
165
|
+
const deterministicGroupingForModules =
|
166
|
+
/** @type {function(DeterministicGroupingOptionsForModule): DeterministicGroupingGroupedItemsForModule[]} */ (
|
167
|
+
deterministicGrouping
|
168
|
+
);
|
166
169
|
|
167
170
|
/** @type {WeakMap<Module, string>} */
|
168
171
|
const getKeyCache = new WeakMap();
|
@@ -173,9 +176,11 @@ const getKeyCache = new WeakMap();
|
|
173
176
|
* @returns {string} hashed filename
|
174
177
|
*/
|
175
178
|
const hashFilename = (name, outputOptions) => {
|
176
|
-
const digest = /** @type {string} */ (
|
177
|
-
.
|
178
|
-
|
179
|
+
const digest = /** @type {string} */ (
|
180
|
+
createHash(outputOptions.hashFunction)
|
181
|
+
.update(name)
|
182
|
+
.digest(outputOptions.hashDigest)
|
183
|
+
);
|
179
184
|
return digest.slice(0, 8);
|
180
185
|
};
|
181
186
|
|
@@ -939,10 +944,8 @@ module.exports = class SplitChunksPlugin {
|
|
939
944
|
const getCombinations = key => getCombinationsFactory()(key);
|
940
945
|
|
941
946
|
const getExportsCombinationsFactory = memoize(() => {
|
942
|
-
const {
|
943
|
-
|
944
|
-
singleChunkSets
|
945
|
-
} = getExportsChunkSetsInGraph();
|
947
|
+
const { chunkSetsInGraph, singleChunkSets } =
|
948
|
+
getExportsChunkSetsInGraph();
|
946
949
|
return createGetCombinations(
|
947
950
|
chunkSetsInGraph,
|
948
951
|
singleChunkSets,
|
@@ -1182,13 +1185,8 @@ module.exports = class SplitChunksPlugin {
|
|
1182
1185
|
chunkCombination instanceof Chunk ? 1 : chunkCombination.size;
|
1183
1186
|
if (count < cacheGroup.minChunks) continue;
|
1184
1187
|
// Select chunks by configuration
|
1185
|
-
const {
|
1186
|
-
|
1187
|
-
key: selectedChunksKey
|
1188
|
-
} = getSelectedChunks(
|
1189
|
-
chunkCombination,
|
1190
|
-
cacheGroup.chunksFilter
|
1191
|
-
);
|
1188
|
+
const { chunks: selectedChunks, key: selectedChunksKey } =
|
1189
|
+
getSelectedChunks(chunkCombination, cacheGroup.chunksFilter);
|
1192
1190
|
|
1193
1191
|
addModuleToChunksInfoMap(
|
1194
1192
|
cacheGroup,
|
@@ -26,14 +26,15 @@ class EnsureChunkRuntimeModule extends RuntimeModule {
|
|
26
26
|
`${handlers} = {};`,
|
27
27
|
"// This file contains only the entry chunk.",
|
28
28
|
"// The chunk loading function for additional chunks",
|
29
|
-
`${
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
`${RuntimeGlobals.ensureChunk} = ${runtimeTemplate.basicFunction(
|
30
|
+
"chunkId",
|
31
|
+
[
|
32
|
+
`return Promise.all(Object.keys(${handlers}).reduce(${runtimeTemplate.basicFunction(
|
33
|
+
"promises, key",
|
34
|
+
[`${handlers}[key](chunkId, promises);`, "return promises;"]
|
35
|
+
)}, []));`
|
36
|
+
]
|
37
|
+
)};`
|
37
38
|
]);
|
38
39
|
} else {
|
39
40
|
// There ensureChunk is used somewhere in the tree, so we need an empty requireEnsure
|
@@ -65,9 +65,8 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|
65
65
|
} = outputOptions;
|
66
66
|
const fn = RuntimeGlobals.loadScript;
|
67
67
|
|
68
|
-
const { createScript } =
|
69
|
-
compilation
|
70
|
-
);
|
68
|
+
const { createScript } =
|
69
|
+
LoadScriptRuntimeModule.getCompilationHooks(compilation);
|
71
70
|
|
72
71
|
const code = Template.asString([
|
73
72
|
"script = document.createElement('script');",
|
@@ -21,49 +21,50 @@ class OnChunksLoadedRuntimeModule extends RuntimeModule {
|
|
21
21
|
const { runtimeTemplate } = compilation;
|
22
22
|
return Template.asString([
|
23
23
|
"var deferred = [];",
|
24
|
-
`${
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Template.indent([
|
29
|
-
"priority = priority || 0;",
|
30
|
-
"for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];",
|
31
|
-
"deferred[i] = [chunkIds, fn, priority];",
|
32
|
-
"return;"
|
33
|
-
]),
|
34
|
-
"}",
|
35
|
-
"var notFulfilled = Infinity;",
|
36
|
-
"for (var i = 0; i < deferred.length; i++) {",
|
37
|
-
Template.indent([
|
38
|
-
runtimeTemplate.destructureArray(
|
39
|
-
["chunkIds", "fn", "priority"],
|
40
|
-
"deferred[i]"
|
41
|
-
),
|
42
|
-
"var fulfilled = true;",
|
43
|
-
"for (var j = 0; j < chunkIds.length; j++) {",
|
24
|
+
`${RuntimeGlobals.onChunksLoaded} = ${runtimeTemplate.basicFunction(
|
25
|
+
"result, chunkIds, fn, priority",
|
26
|
+
[
|
27
|
+
"if(chunkIds) {",
|
44
28
|
Template.indent([
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
29
|
+
"priority = priority || 0;",
|
30
|
+
"for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];",
|
31
|
+
"deferred[i] = [chunkIds, fn, priority];",
|
32
|
+
"return;"
|
33
|
+
]),
|
34
|
+
"}",
|
35
|
+
"var notFulfilled = Infinity;",
|
36
|
+
"for (var i = 0; i < deferred.length; i++) {",
|
37
|
+
Template.indent([
|
38
|
+
runtimeTemplate.destructureArray(
|
39
|
+
["chunkIds", "fn", "priority"],
|
40
|
+
"deferred[i]"
|
41
|
+
),
|
42
|
+
"var fulfilled = true;",
|
43
|
+
"for (var j = 0; j < chunkIds.length; j++) {",
|
53
44
|
Template.indent([
|
54
|
-
|
55
|
-
|
45
|
+
`if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(${
|
46
|
+
RuntimeGlobals.onChunksLoaded
|
47
|
+
}).every(${runtimeTemplate.returningFunction(
|
48
|
+
`${RuntimeGlobals.onChunksLoaded}[key](chunkIds[j])`,
|
49
|
+
"key"
|
50
|
+
)})) {`,
|
51
|
+
Template.indent(["chunkIds.splice(j--, 1);"]),
|
52
|
+
"} else {",
|
53
|
+
Template.indent([
|
54
|
+
"fulfilled = false;",
|
55
|
+
"if(priority < notFulfilled) notFulfilled = priority;"
|
56
|
+
]),
|
57
|
+
"}"
|
56
58
|
]),
|
59
|
+
"}",
|
60
|
+
"if(fulfilled) {",
|
61
|
+
Template.indent(["deferred.splice(i--, 1)", "result = fn();"]),
|
57
62
|
"}"
|
58
63
|
]),
|
59
64
|
"}",
|
60
|
-
"
|
61
|
-
|
62
|
-
|
63
|
-
]),
|
64
|
-
"}",
|
65
|
-
"return result;"
|
66
|
-
])};`
|
65
|
+
"return result;"
|
66
|
+
]
|
67
|
+
)};`
|
67
68
|
]);
|
68
69
|
}
|
69
70
|
}
|
@@ -6,10 +6,25 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const NormalModule = require("../NormalModule");
|
9
|
-
const { getMimetype, decodeDataURI } = require("../util/DataURI");
|
10
9
|
|
11
10
|
/** @typedef {import("../Compiler")} Compiler */
|
12
11
|
|
12
|
+
// data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string"
|
13
|
+
// http://www.ietf.org/rfc/rfc2397.txt
|
14
|
+
const URIRegEx = /^data:(?:[^;,]+)?(?:(?:;[^;,]+)*?)(;base64)?,(.*)$/i;
|
15
|
+
const URIMetaRegEx = /^data:([^;,]+)?(?:(?:;[^;,]+)*?)(?:;(base64))?,/i;
|
16
|
+
|
17
|
+
const decodeDataURI = uri => {
|
18
|
+
const match = URIRegEx.exec(uri);
|
19
|
+
if (!match) return null;
|
20
|
+
|
21
|
+
const isBase64 = match[1];
|
22
|
+
const body = match[2];
|
23
|
+
return isBase64
|
24
|
+
? Buffer.from(body, "base64")
|
25
|
+
: Buffer.from(decodeURIComponent(body), "ascii");
|
26
|
+
};
|
27
|
+
|
13
28
|
class DataUriPlugin {
|
14
29
|
/**
|
15
30
|
* Apply the plugin
|
@@ -23,7 +38,11 @@ class DataUriPlugin {
|
|
23
38
|
normalModuleFactory.hooks.resolveForScheme
|
24
39
|
.for("data")
|
25
40
|
.tap("DataUriPlugin", resourceData => {
|
26
|
-
|
41
|
+
const match = URIMetaRegEx.exec(resourceData.resource);
|
42
|
+
if (match) {
|
43
|
+
resourceData.data.mimetype = match[1] || "";
|
44
|
+
resourceData.data.encoding = match[2] || false;
|
45
|
+
}
|
27
46
|
});
|
28
47
|
NormalModule.getCompilationHooks(compilation)
|
29
48
|
.readResourceForScheme.for("data")
|
@@ -100,6 +100,9 @@ const F64_SIZE = 8;
|
|
100
100
|
const MEASURE_START_OPERATION = Symbol("MEASURE_START_OPERATION");
|
101
101
|
const MEASURE_END_OPERATION = Symbol("MEASURE_END_OPERATION");
|
102
102
|
|
103
|
+
/** @typedef {typeof MEASURE_START_OPERATION} MEASURE_START_OPERATION_TYPE */
|
104
|
+
/** @typedef {typeof MEASURE_END_OPERATION} MEASURE_END_OPERATION_TYPE */
|
105
|
+
|
103
106
|
const identifyNumber = n => {
|
104
107
|
if (n === (n | 0)) {
|
105
108
|
if (n <= 127 && n >= -128) return 0;
|
@@ -201,9 +204,8 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
201
204
|
if (!SerializerMiddleware.isLazy(thing))
|
202
205
|
throw new Error("Unexpected function " + thing);
|
203
206
|
/** @type {SerializedType | (() => SerializedType)} */
|
204
|
-
let serializedData =
|
205
|
-
thing
|
206
|
-
);
|
207
|
+
let serializedData =
|
208
|
+
SerializerMiddleware.getLazySerializedValue(thing);
|
207
209
|
if (serializedData === undefined) {
|
208
210
|
if (SerializerMiddleware.isLazy(thing, this)) {
|
209
211
|
const data = this._serialize(thing(), context);
|
@@ -135,7 +135,9 @@ const serialize = async (middleware, data, name, writeFile) => {
|
|
135
135
|
const backgroundJobs = [];
|
136
136
|
const resolvedData = (
|
137
137
|
await Promise.all(
|
138
|
-
/** @type {Promise<Buffer[] | Buffer | SerializeResult>[]} */ (
|
138
|
+
/** @type {Promise<Buffer[] | Buffer | SerializeResult>[]} */ (
|
139
|
+
processedData
|
140
|
+
)
|
139
141
|
)
|
140
142
|
).map(item => {
|
141
143
|
if (Array.isArray(item) || Buffer.isBuffer(item)) return item;
|
@@ -450,9 +450,8 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
450
450
|
);
|
451
451
|
}
|
452
452
|
|
453
|
-
const { request, name, serializer } =
|
454
|
-
item
|
455
|
-
);
|
453
|
+
const { request, name, serializer } =
|
454
|
+
ObjectMiddleware.getSerializerFor(item);
|
456
455
|
const key = `${request}/${name}`;
|
457
456
|
const lastIndex = objectTypeLookup.get(key);
|
458
457
|
|
@@ -500,9 +499,8 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
500
499
|
if (!SerializerMiddleware.isLazy(item))
|
501
500
|
throw new Error("Unexpected function " + item);
|
502
501
|
/** @type {SerializedType} */
|
503
|
-
const serializedData =
|
504
|
-
item
|
505
|
-
);
|
502
|
+
const serializedData =
|
503
|
+
SerializerMiddleware.getLazySerializedValue(item);
|
506
504
|
if (serializedData !== undefined) {
|
507
505
|
if (typeof serializedData === "function") {
|
508
506
|
result.push(serializedData);
|
@@ -539,7 +537,13 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
539
537
|
// This happens because the optimized code v8 generates
|
540
538
|
// is optimized for our "ctx.write" method so it will reference
|
541
539
|
// it from e. g. Dependency.prototype.serialize -(IC)-> ctx.write
|
542
|
-
data =
|
540
|
+
data =
|
541
|
+
result =
|
542
|
+
referenceable =
|
543
|
+
bufferDedupeMap =
|
544
|
+
objectTypeLookup =
|
545
|
+
ctx =
|
546
|
+
undefined;
|
543
547
|
}
|
544
548
|
}
|
545
549
|
|
@@ -10,7 +10,6 @@ const ModuleDependency = require("../dependencies/ModuleDependency");
|
|
10
10
|
const formatLocation = require("../formatLocation");
|
11
11
|
const { LogType } = require("../logging/Logger");
|
12
12
|
const AggressiveSplittingPlugin = require("../optimize/AggressiveSplittingPlugin");
|
13
|
-
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
14
13
|
const SizeLimitsPlugin = require("../performance/SizeLimitsPlugin");
|
15
14
|
const { countIterable } = require("../util/IterableHelpers");
|
16
15
|
const {
|
@@ -1078,9 +1077,8 @@ const SIMPLE_EXTRACTORS = {
|
|
1078
1077
|
const { compilation, type } = context;
|
1079
1078
|
const built = compilation.builtModules.has(module);
|
1080
1079
|
const codeGenerated = compilation.codeGeneratedModules.has(module);
|
1081
|
-
const buildTimeExecuted =
|
1082
|
-
module
|
1083
|
-
);
|
1080
|
+
const buildTimeExecuted =
|
1081
|
+
compilation.buildTimeExecutedModules.has(module);
|
1084
1082
|
/** @type {{[x: string]: number}} */
|
1085
1083
|
const sizes = {};
|
1086
1084
|
for (const sourceType of module.getSourceTypes()) {
|
@@ -1228,11 +1226,13 @@ const SIMPLE_EXTRACTORS = {
|
|
1228
1226
|
},
|
1229
1227
|
nestedModules: (object, module, context, options, factory) => {
|
1230
1228
|
const { type } = context;
|
1231
|
-
|
1232
|
-
|
1229
|
+
const innerModules = /** @type {Module & { modules?: Module[] }} */ (
|
1230
|
+
module
|
1231
|
+
).modules;
|
1232
|
+
if (Array.isArray(innerModules)) {
|
1233
1233
|
const groupedModules = factory.create(
|
1234
1234
|
`${type.slice(0, -8)}.modules`,
|
1235
|
-
|
1235
|
+
innerModules,
|
1236
1236
|
context
|
1237
1237
|
);
|
1238
1238
|
const limited = spaceLimited(
|
@@ -818,9 +818,8 @@ const SIMPLE_ITEMS_JOINER = {
|
|
818
818
|
"asset.chunkNames": itemsJoinCommaBracketsWithName("name"),
|
819
819
|
"asset.auxiliaryChunkNames": itemsJoinCommaBracketsWithName("auxiliary name"),
|
820
820
|
"asset.chunkIdHints": itemsJoinCommaBracketsWithName("id hint"),
|
821
|
-
"asset.auxiliaryChunkIdHints":
|
822
|
-
"auxiliary id hint"
|
823
|
-
),
|
821
|
+
"asset.auxiliaryChunkIdHints":
|
822
|
+
itemsJoinCommaBracketsWithName("auxiliary id hint"),
|
824
823
|
"module.chunks": itemsJoinOneLine,
|
825
824
|
"module.issuerPath": items =>
|
826
825
|
items
|
@@ -912,11 +911,13 @@ const joinExplicitNewLine = (items, indenter) => {
|
|
912
911
|
.trim();
|
913
912
|
};
|
914
913
|
|
915
|
-
const joinError =
|
916
|
-
|
917
|
-
|
918
|
-
""
|
919
|
-
|
914
|
+
const joinError =
|
915
|
+
error =>
|
916
|
+
(items, { red, yellow }) =>
|
917
|
+
`${error ? red("ERROR") : yellow("WARNING")} in ${joinExplicitNewLine(
|
918
|
+
items,
|
919
|
+
""
|
920
|
+
)}`;
|
920
921
|
|
921
922
|
/** @type {Record<string, (items: ({ element: string, content: string })[], context: StatsPrinterContext) => string>} */
|
922
923
|
const SIMPLE_ELEMENT_JOINERS = {
|
@@ -1130,7 +1131,8 @@ const AVAILABLE_FORMATS = {
|
|
1130
1131
|
format: red
|
1131
1132
|
},
|
1132
1133
|
{
|
1133
|
-
regExp:
|
1134
|
+
regExp:
|
1135
|
+
/\b(error|failed|unexpected|invalid|not found|not supported|not available|not possible|not implemented|doesn't support|conflict|conflicting|not existing|duplicate)\b/gi,
|
1134
1136
|
format: red
|
1135
1137
|
}
|
1136
1138
|
];
|
@@ -71,7 +71,8 @@ class StatsFactory {
|
|
71
71
|
getItemFactory: new HookMap(() => new SyncBailHook(["item", "context"]))
|
72
72
|
});
|
73
73
|
const hooks = this.hooks;
|
74
|
-
this._caches =
|
74
|
+
this._caches =
|
75
|
+
/** @type {Record<keyof typeof hooks, Map<string, SyncBailHook<[any[], StatsFactoryContext]>[]>>} */ ({});
|
75
76
|
for (const key of Object.keys(hooks)) {
|
76
77
|
this._caches[key] = new Map();
|
77
78
|
}
|
@@ -87,9 +87,9 @@ class StatsPrinter {
|
|
87
87
|
* @returns {T[]} hooks
|
88
88
|
*/
|
89
89
|
_getAllLevelHooks(hookMap, type) {
|
90
|
-
let cache = /** @type {Map<string, T[]>} */ (
|
91
|
-
hookMap
|
92
|
-
)
|
90
|
+
let cache = /** @type {Map<string, T[]>} */ (
|
91
|
+
this._levelHookCache.get(hookMap)
|
92
|
+
);
|
93
93
|
if (cache === undefined) {
|
94
94
|
cache = new Map();
|
95
95
|
this._levelHookCache.set(hookMap, cache);
|
@@ -164,9 +164,9 @@ class LazyBucketSortedSet {
|
|
164
164
|
}
|
165
165
|
};
|
166
166
|
} else {
|
167
|
-
const oldEntry = /** @type {LazyBucketSortedSet<T, any>} */ (
|
168
|
-
key
|
169
|
-
)
|
167
|
+
const oldEntry = /** @type {LazyBucketSortedSet<T, any>} */ (
|
168
|
+
this._map.get(key)
|
169
|
+
);
|
170
170
|
const finishUpdate = oldEntry.startUpdate(item);
|
171
171
|
return remove => {
|
172
172
|
if (remove) {
|
package/lib/util/cleverMerge.js
CHANGED
@@ -539,7 +539,9 @@ const resolveByProperty = (obj, byProperty, ...values) => {
|
|
539
539
|
}
|
540
540
|
const { [byProperty]: _byValue, ..._remaining } = /** @type {object} */ (obj);
|
541
541
|
const remaining = /** @type {T} */ (_remaining);
|
542
|
-
const byValue = /** @type {Record<string, T> | function(...any[]): T} */ (
|
542
|
+
const byValue = /** @type {Record<string, T> | function(...any[]): T} */ (
|
543
|
+
_byValue
|
544
|
+
);
|
543
545
|
if (typeof byValue === "object") {
|
544
546
|
const key = values[0];
|
545
547
|
if (key in byValue) {
|
package/lib/util/comparators.js
CHANGED
@@ -68,9 +68,8 @@ const compareModulesById = (chunkGraph, a, b) => {
|
|
68
68
|
return compareIds(chunkGraph.getModuleId(a), chunkGraph.getModuleId(b));
|
69
69
|
};
|
70
70
|
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
71
|
-
exports.compareModulesById =
|
72
|
-
compareModulesById
|
73
|
-
);
|
71
|
+
exports.compareModulesById =
|
72
|
+
createCachedParameterizedComparator(compareModulesById);
|
74
73
|
|
75
74
|
/**
|
76
75
|
* @param {number} a number
|
@@ -138,9 +137,10 @@ const compareModulesByPostOrderIndexOrIdentifier = (moduleGraph, a, b) => {
|
|
138
137
|
return compareIds(a.identifier(), b.identifier());
|
139
138
|
};
|
140
139
|
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
141
|
-
exports.compareModulesByPostOrderIndexOrIdentifier =
|
142
|
-
|
143
|
-
|
140
|
+
exports.compareModulesByPostOrderIndexOrIdentifier =
|
141
|
+
createCachedParameterizedComparator(
|
142
|
+
compareModulesByPostOrderIndexOrIdentifier
|
143
|
+
);
|
144
144
|
|
145
145
|
/**
|
146
146
|
* @param {ModuleGraph} moduleGraph the module graph
|
@@ -157,9 +157,10 @@ const compareModulesByPreOrderIndexOrIdentifier = (moduleGraph, a, b) => {
|
|
157
157
|
return compareIds(a.identifier(), b.identifier());
|
158
158
|
};
|
159
159
|
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
160
|
-
exports.compareModulesByPreOrderIndexOrIdentifier =
|
161
|
-
|
162
|
-
|
160
|
+
exports.compareModulesByPreOrderIndexOrIdentifier =
|
161
|
+
createCachedParameterizedComparator(
|
162
|
+
compareModulesByPreOrderIndexOrIdentifier
|
163
|
+
);
|
163
164
|
|
164
165
|
/**
|
165
166
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
@@ -284,10 +285,9 @@ const concatComparators = (c1, c2, ...cRest) => {
|
|
284
285
|
const [c3, ...cRest2] = cRest;
|
285
286
|
return concatComparators(c1, concatComparators(c2, c3, ...cRest2));
|
286
287
|
}
|
287
|
-
const cacheEntry = /** @type {Comparator<T>} */ (
|
288
|
-
c1,
|
289
|
-
|
290
|
-
));
|
288
|
+
const cacheEntry = /** @type {Comparator<T>} */ (
|
289
|
+
concatComparatorsCache.get(c1, c2)
|
290
|
+
);
|
291
291
|
if (cacheEntry !== undefined) return cacheEntry;
|
292
292
|
/**
|
293
293
|
* @param {T} a first value
|
package/lib/util/createHash.js
CHANGED
@@ -67,6 +67,7 @@ class BulkUpdateDecorator extends Hash {
|
|
67
67
|
*/
|
68
68
|
digest(encoding) {
|
69
69
|
let digestCache;
|
70
|
+
const buffer = this.buffer;
|
70
71
|
if (this.hash === undefined) {
|
71
72
|
// short data for hash, we can use caching
|
72
73
|
const cacheKey = `${this.hashKey}-${encoding}`;
|
@@ -74,18 +75,18 @@ class BulkUpdateDecorator extends Hash {
|
|
74
75
|
if (digestCache === undefined) {
|
75
76
|
digestCache = digestCaches[cacheKey] = new Map();
|
76
77
|
}
|
77
|
-
const cacheEntry = digestCache.get(
|
78
|
+
const cacheEntry = digestCache.get(buffer);
|
78
79
|
if (cacheEntry !== undefined) return cacheEntry;
|
79
80
|
this.hash = this.hashFactory();
|
80
81
|
}
|
81
|
-
if (
|
82
|
-
this.hash.update(
|
82
|
+
if (buffer.length > 0) {
|
83
|
+
this.hash.update(buffer);
|
83
84
|
}
|
84
85
|
const digestResult = this.hash.digest(encoding);
|
85
86
|
const result =
|
86
87
|
typeof digestResult === "string" ? digestResult : digestResult.toString();
|
87
88
|
if (digestCache !== undefined) {
|
88
|
-
digestCache.set(
|
89
|
+
digestCache.set(buffer, result);
|
89
90
|
}
|
90
91
|
return result;
|
91
92
|
}
|
package/lib/util/identifier.js
CHANGED
@@ -244,7 +244,8 @@ const _absolutify = (context, request) => {
|
|
244
244
|
const absolutify = makeCacheable(_absolutify);
|
245
245
|
exports.absolutify = absolutify;
|
246
246
|
|
247
|
-
const PATH_QUERY_FRAGMENT_REGEXP =
|
247
|
+
const PATH_QUERY_FRAGMENT_REGEXP =
|
248
|
+
/^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
248
249
|
|
249
250
|
/** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
|
250
251
|
|