webpack 5.66.0 → 5.69.1
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 +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +2 -2
- package/lib/ChunkGraph.js +1 -2
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +14 -9
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +21 -17
- package/lib/DelegatedModule.js +1 -1
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +18 -1
- package/lib/ExportsInfo.js +4 -4
- package/lib/ExternalModule.js +1 -1
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +29 -25
- package/lib/HookWebpackError.js +1 -1
- package/lib/Module.js +1 -3
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +6 -4
- package/lib/NormalModuleFactory.js +25 -27
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +18 -0
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +28 -3
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/Watching.js +1 -1
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +65 -26
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +8 -5
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +1 -1
- package/lib/cache/ResolverCachePlugin.js +1 -1
- package/lib/cli.js +44 -3
- package/lib/config/defaults.js +30 -7
- package/lib/config/normalization.js +5 -0
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/RemoteModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +3 -0
- package/lib/css/CssLoadingRuntimeModule.js +201 -154
- package/lib/css/CssModulesPlugin.js +22 -4
- package/lib/debug/ProfilingPlugin.js +15 -14
- package/lib/dependencies/ContextElementDependency.js +8 -2
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/hmr/LazyCompilationPlugin.js +45 -21
- package/lib/hmr/lazyCompilationBackend.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +9 -12
- package/lib/ids/IdHelpers.js +24 -10
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/StartupHelpers.js +3 -2
- package/lib/library/AssignLibraryPlugin.js +8 -2
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +11 -5
- package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/schemes/HttpUriPlugin.js +32 -11
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
- package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
- package/lib/util/ArrayHelpers.js +18 -4
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/identifier.js +65 -44
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/package.json +14 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +47 -6
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/types.d.ts +207 -60
@@ -9,6 +9,8 @@
|
|
9
9
|
/** @typedef {import("./StatsPrinter")} StatsPrinter */
|
10
10
|
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
11
11
|
|
12
|
+
const DATA_URI_CONTENT_LENGTH = 16;
|
13
|
+
|
12
14
|
const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
13
15
|
|
14
16
|
/**
|
@@ -26,6 +28,23 @@ const printSizes = (sizes, { formatSize = n => `${n}` }) => {
|
|
26
28
|
}
|
27
29
|
};
|
28
30
|
|
31
|
+
const getResourceName = resource => {
|
32
|
+
const dataUrl = /^data:[^,]+,/.exec(resource);
|
33
|
+
if (!dataUrl) return resource;
|
34
|
+
|
35
|
+
const len = dataUrl[0].length + DATA_URI_CONTENT_LENGTH;
|
36
|
+
if (resource.length < len) return resource;
|
37
|
+
return `${resource.slice(
|
38
|
+
0,
|
39
|
+
Math.min(resource.length - /* '..'.length */ 2, len)
|
40
|
+
)}..`;
|
41
|
+
};
|
42
|
+
|
43
|
+
const getModuleName = name => {
|
44
|
+
const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
|
45
|
+
return [prefix, getResourceName(resource)];
|
46
|
+
};
|
47
|
+
|
29
48
|
const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
|
30
49
|
|
31
50
|
/**
|
@@ -38,6 +57,10 @@ const isValidId = id => {
|
|
38
57
|
return typeof id === "number" || id;
|
39
58
|
};
|
40
59
|
|
60
|
+
const moreCount = (list, count) => {
|
61
|
+
return list && list.length > 0 ? `+ ${count}` : `${count}`;
|
62
|
+
};
|
63
|
+
|
41
64
|
/** @type {Record<string, (thing: any, context: StatsPrinterContext, printer: StatsPrinter) => string | void>} */
|
42
65
|
const SIMPLE_PRINTERS = {
|
43
66
|
"compilation.summary!": (
|
@@ -163,13 +186,24 @@ const SIMPLE_PRINTERS = {
|
|
163
186
|
},
|
164
187
|
"compilation.assetsByChunkName": () => "",
|
165
188
|
|
166
|
-
"compilation.filteredModules":
|
189
|
+
"compilation.filteredModules": (
|
190
|
+
filteredModules,
|
191
|
+
{ compilation: { modules } }
|
192
|
+
) =>
|
167
193
|
filteredModules > 0
|
168
|
-
? `${filteredModules} ${plural(
|
194
|
+
? `${moreCount(modules, filteredModules)} ${plural(
|
195
|
+
filteredModules,
|
196
|
+
"module",
|
197
|
+
"modules"
|
198
|
+
)}`
|
169
199
|
: undefined,
|
170
200
|
"compilation.filteredAssets": (filteredAssets, { compilation: { assets } }) =>
|
171
201
|
filteredAssets > 0
|
172
|
-
? `${filteredAssets} ${plural(
|
202
|
+
? `${moreCount(assets, filteredAssets)} ${plural(
|
203
|
+
filteredAssets,
|
204
|
+
"asset",
|
205
|
+
"assets"
|
206
|
+
)}`
|
173
207
|
: undefined,
|
174
208
|
"compilation.logging": (logging, context, printer) =>
|
175
209
|
Array.isArray(logging)
|
@@ -262,15 +296,19 @@ const SIMPLE_PRINTERS = {
|
|
262
296
|
"asset.separator!": () => "\n",
|
263
297
|
"asset.filteredRelated": (filteredRelated, { asset: { related } }) =>
|
264
298
|
filteredRelated > 0
|
265
|
-
? `${filteredRelated} related ${plural(
|
299
|
+
? `${moreCount(related, filteredRelated)} related ${plural(
|
266
300
|
filteredRelated,
|
267
301
|
"asset",
|
268
302
|
"assets"
|
269
303
|
)}`
|
270
304
|
: undefined,
|
271
|
-
"asset.filteredChildren": filteredChildren =>
|
305
|
+
"asset.filteredChildren": (filteredChildren, { asset: { children } }) =>
|
272
306
|
filteredChildren > 0
|
273
|
-
? `${filteredChildren} ${plural(
|
307
|
+
? `${moreCount(children, filteredChildren)} ${plural(
|
308
|
+
filteredChildren,
|
309
|
+
"asset",
|
310
|
+
"assets"
|
311
|
+
)}`
|
274
312
|
: undefined,
|
275
313
|
|
276
314
|
assetChunk: (id, { formatChunkId }) => formatChunkId(id),
|
@@ -282,8 +320,8 @@ const SIMPLE_PRINTERS = {
|
|
282
320
|
"module.id": (id, { formatModuleId }) =>
|
283
321
|
isValidId(id) ? formatModuleId(id) : undefined,
|
284
322
|
"module.name": (name, { bold }) => {
|
285
|
-
const [
|
286
|
-
return
|
323
|
+
const [prefix, resource] = getModuleName(name);
|
324
|
+
return `${prefix || ""}${bold(resource || "")}`;
|
287
325
|
},
|
288
326
|
"module.identifier": identifier => undefined,
|
289
327
|
"module.layer": (layer, { formatLayer }) =>
|
@@ -366,21 +404,29 @@ const SIMPLE_PRINTERS = {
|
|
366
404
|
"module.issuerPath": (issuerPath, { module }) =>
|
367
405
|
module.profile ? undefined : "",
|
368
406
|
"module.profile": profile => undefined,
|
369
|
-
"module.filteredModules": filteredModules =>
|
407
|
+
"module.filteredModules": (filteredModules, { module: { modules } }) =>
|
370
408
|
filteredModules > 0
|
371
|
-
? `${filteredModules} nested ${plural(
|
409
|
+
? `${moreCount(modules, filteredModules)} nested ${plural(
|
372
410
|
filteredModules,
|
373
411
|
"module",
|
374
412
|
"modules"
|
375
413
|
)}`
|
376
414
|
: undefined,
|
377
|
-
"module.filteredReasons": filteredReasons =>
|
415
|
+
"module.filteredReasons": (filteredReasons, { module: { reasons } }) =>
|
378
416
|
filteredReasons > 0
|
379
|
-
? `${filteredReasons} ${plural(
|
417
|
+
? `${moreCount(reasons, filteredReasons)} ${plural(
|
418
|
+
filteredReasons,
|
419
|
+
"reason",
|
420
|
+
"reasons"
|
421
|
+
)}`
|
380
422
|
: undefined,
|
381
|
-
"module.filteredChildren": filteredChildren =>
|
423
|
+
"module.filteredChildren": (filteredChildren, { module: { children } }) =>
|
382
424
|
filteredChildren > 0
|
383
|
-
? `${filteredChildren} ${plural(
|
425
|
+
? `${moreCount(children, filteredChildren)} ${plural(
|
426
|
+
filteredChildren,
|
427
|
+
"module",
|
428
|
+
"modules"
|
429
|
+
)}`
|
384
430
|
: undefined,
|
385
431
|
"module.separator!": () => "\n",
|
386
432
|
|
@@ -388,7 +434,8 @@ const SIMPLE_PRINTERS = {
|
|
388
434
|
"moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value),
|
389
435
|
|
390
436
|
"moduleReason.type": type => type,
|
391
|
-
"moduleReason.userRequest": (userRequest, { cyan }) =>
|
437
|
+
"moduleReason.userRequest": (userRequest, { cyan }) =>
|
438
|
+
cyan(getResourceName(userRequest)),
|
392
439
|
"moduleReason.moduleId": (moduleId, { formatModuleId }) =>
|
393
440
|
isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
|
394
441
|
"moduleReason.module": (module, { magenta }) => magenta(module),
|
@@ -397,9 +444,16 @@ const SIMPLE_PRINTERS = {
|
|
397
444
|
"moduleReason.active": (active, { formatFlag }) =>
|
398
445
|
active ? undefined : formatFlag("inactive"),
|
399
446
|
"moduleReason.resolvedModule": (module, { magenta }) => magenta(module),
|
400
|
-
"moduleReason.filteredChildren":
|
447
|
+
"moduleReason.filteredChildren": (
|
448
|
+
filteredChildren,
|
449
|
+
{ moduleReason: { children } }
|
450
|
+
) =>
|
401
451
|
filteredChildren > 0
|
402
|
-
? `${filteredChildren} ${plural(
|
452
|
+
? `${moreCount(children, filteredChildren)} ${plural(
|
453
|
+
filteredChildren,
|
454
|
+
"reason",
|
455
|
+
"reasons"
|
456
|
+
)}`
|
403
457
|
: undefined,
|
404
458
|
|
405
459
|
"module.profile.total": (value, { formatTime }) => formatTime(value),
|
@@ -427,10 +481,21 @@ const SIMPLE_PRINTERS = {
|
|
427
481
|
size ? formatSize(size) : undefined,
|
428
482
|
"chunkGroup.auxiliaryAssetsSize": (size, { formatSize }) =>
|
429
483
|
size ? `(${formatSize(size)})` : undefined,
|
430
|
-
"chunkGroup.filteredAssets": n =>
|
431
|
-
n > 0
|
432
|
-
|
433
|
-
|
484
|
+
"chunkGroup.filteredAssets": (n, { chunkGroup: { assets } }) =>
|
485
|
+
n > 0
|
486
|
+
? `${moreCount(assets, n)} ${plural(n, "asset", "assets")}`
|
487
|
+
: undefined,
|
488
|
+
"chunkGroup.filteredAuxiliaryAssets": (
|
489
|
+
n,
|
490
|
+
{ chunkGroup: { auxiliaryAssets } }
|
491
|
+
) =>
|
492
|
+
n > 0
|
493
|
+
? `${moreCount(auxiliaryAssets, n)} auxiliary ${plural(
|
494
|
+
n,
|
495
|
+
"asset",
|
496
|
+
"assets"
|
497
|
+
)}`
|
498
|
+
: undefined,
|
434
499
|
"chunkGroup.is!": () => "=",
|
435
500
|
"chunkGroupAsset.name": (asset, { green }) => green(asset),
|
436
501
|
"chunkGroupAsset.size": (size, { formatSize, chunkGroup }) =>
|
@@ -490,9 +555,9 @@ const SIMPLE_PRINTERS = {
|
|
490
555
|
"chunk.recorded": (recorded, { formatFlag, green }) =>
|
491
556
|
recorded ? green(formatFlag("recorded")) : undefined,
|
492
557
|
"chunk.reason": (reason, { yellow }) => (reason ? yellow(reason) : undefined),
|
493
|
-
"chunk.filteredModules": filteredModules =>
|
558
|
+
"chunk.filteredModules": (filteredModules, { chunk: { modules } }) =>
|
494
559
|
filteredModules > 0
|
495
|
-
? `${filteredModules} chunk ${plural(
|
560
|
+
? `${moreCount(modules, filteredModules)} chunk ${plural(
|
496
561
|
filteredModules,
|
497
562
|
"module",
|
498
563
|
"modules"
|
package/lib/util/ArrayHelpers.js
CHANGED
@@ -5,6 +5,14 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
/**
|
9
|
+
* Compare two arrays or strings by performing strict equality check for each value.
|
10
|
+
* @template T [T=any]
|
11
|
+
* @param {ArrayLike<T>} a Array of values to be compared
|
12
|
+
* @param {ArrayLike<T>} b Array of values to be compared
|
13
|
+
* @returns {boolean} returns true if all the elements of passed arrays are strictly equal.
|
14
|
+
*/
|
15
|
+
|
8
16
|
exports.equals = (a, b) => {
|
9
17
|
if (a.length !== b.length) return false;
|
10
18
|
for (let i = 0; i < a.length; i++) {
|
@@ -14,13 +22,19 @@ exports.equals = (a, b) => {
|
|
14
22
|
};
|
15
23
|
|
16
24
|
/**
|
17
|
-
*
|
18
|
-
* @
|
19
|
-
* @param {
|
20
|
-
* @
|
25
|
+
* Partition an array by calling a predicate function on each value.
|
26
|
+
* @template T [T=any]
|
27
|
+
* @param {Array<T>} arr Array of values to be partitioned
|
28
|
+
* @param {(value: T) => boolean} fn Partition function which partitions based on truthiness of result.
|
29
|
+
* @returns {[Array<T>, Array<T>]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
|
21
30
|
*/
|
22
31
|
exports.groupBy = (arr = [], fn) => {
|
23
32
|
return arr.reduce(
|
33
|
+
/**
|
34
|
+
* @param {[Array<T>, Array<T>]} groups An accumulator storing already partitioned values returned from previous call.
|
35
|
+
* @param {T} value The value of the current element
|
36
|
+
* @returns {[Array<T>, Array<T>]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value.
|
37
|
+
*/
|
24
38
|
(groups, value) => {
|
25
39
|
groups[fn(value) ? 0 : 1].push(value);
|
26
40
|
return groups;
|
package/lib/util/AsyncQueue.js
CHANGED
@@ -18,7 +18,7 @@ const toSimpleString = str => {
|
|
18
18
|
|
19
19
|
/**
|
20
20
|
* @param {Record<string|number, boolean>} map value map
|
21
|
-
* @returns {
|
21
|
+
* @returns {boolean|(function(string): string)} true/false, when unconditionally true/false, or a template function to determine the value at runtime
|
22
22
|
*/
|
23
23
|
const compileBooleanMatcher = map => {
|
24
24
|
const positiveItems = Object.keys(map).filter(i => map[i]);
|
@@ -498,7 +498,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
498
498
|
|
499
499
|
// return the results
|
500
500
|
return result.map(group => {
|
501
|
-
/** @type {GroupedItems} */
|
501
|
+
/** @type {GroupedItems<T>} */
|
502
502
|
return {
|
503
503
|
key: group.key,
|
504
504
|
items: group.nodes.map(node => node.item),
|
package/lib/util/identifier.js
CHANGED
@@ -81,7 +81,49 @@ const requestToAbsolute = (context, relativePath) => {
|
|
81
81
|
return relativePath;
|
82
82
|
};
|
83
83
|
|
84
|
-
const makeCacheable =
|
84
|
+
const makeCacheable = realFn => {
|
85
|
+
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
|
86
|
+
const cache = new WeakMap();
|
87
|
+
|
88
|
+
const getCache = associatedObjectForCache => {
|
89
|
+
const entry = cache.get(associatedObjectForCache);
|
90
|
+
if (entry !== undefined) return entry;
|
91
|
+
/** @type {Map<string, ParsedResource>} */
|
92
|
+
const map = new Map();
|
93
|
+
cache.set(associatedObjectForCache, map);
|
94
|
+
return map;
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* @param {string} str the path with query and fragment
|
99
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
100
|
+
* @returns {ParsedResource} parsed parts
|
101
|
+
*/
|
102
|
+
const fn = (str, associatedObjectForCache) => {
|
103
|
+
if (!associatedObjectForCache) return realFn(str);
|
104
|
+
const cache = getCache(associatedObjectForCache);
|
105
|
+
const entry = cache.get(str);
|
106
|
+
if (entry !== undefined) return entry;
|
107
|
+
const result = realFn(str);
|
108
|
+
cache.set(str, result);
|
109
|
+
return result;
|
110
|
+
};
|
111
|
+
|
112
|
+
fn.bindCache = associatedObjectForCache => {
|
113
|
+
const cache = getCache(associatedObjectForCache);
|
114
|
+
return str => {
|
115
|
+
const entry = cache.get(str);
|
116
|
+
if (entry !== undefined) return entry;
|
117
|
+
const result = realFn(str);
|
118
|
+
cache.set(str, result);
|
119
|
+
return result;
|
120
|
+
};
|
121
|
+
};
|
122
|
+
|
123
|
+
return fn;
|
124
|
+
};
|
125
|
+
|
126
|
+
const makeCacheableWithContext = fn => {
|
85
127
|
/** @type {WeakMap<object, Map<string, Map<string, string>>>} */
|
86
128
|
const cache = new WeakMap();
|
87
129
|
|
@@ -215,7 +257,7 @@ const _makePathsRelative = (context, identifier) => {
|
|
215
257
|
.join("");
|
216
258
|
};
|
217
259
|
|
218
|
-
exports.makePathsRelative =
|
260
|
+
exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
|
219
261
|
|
220
262
|
/**
|
221
263
|
*
|
@@ -230,7 +272,7 @@ const _makePathsAbsolute = (context, identifier) => {
|
|
230
272
|
.join("");
|
231
273
|
};
|
232
274
|
|
233
|
-
exports.makePathsAbsolute =
|
275
|
+
exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
|
234
276
|
|
235
277
|
/**
|
236
278
|
* @param {string} context absolute context path
|
@@ -244,7 +286,7 @@ const _contextify = (context, request) => {
|
|
244
286
|
.join("!");
|
245
287
|
};
|
246
288
|
|
247
|
-
const contextify =
|
289
|
+
const contextify = makeCacheableWithContext(_contextify);
|
248
290
|
exports.contextify = contextify;
|
249
291
|
|
250
292
|
/**
|
@@ -259,13 +301,15 @@ const _absolutify = (context, request) => {
|
|
259
301
|
.join("!");
|
260
302
|
};
|
261
303
|
|
262
|
-
const absolutify =
|
304
|
+
const absolutify = makeCacheableWithContext(_absolutify);
|
263
305
|
exports.absolutify = absolutify;
|
264
306
|
|
265
307
|
const PATH_QUERY_FRAGMENT_REGEXP =
|
266
308
|
/^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
309
|
+
const PATH_QUERY_REGEXP = /^((?:\0.|[^?\0])*)(\?.*)?$/;
|
267
310
|
|
268
311
|
/** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
|
312
|
+
/** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
|
269
313
|
|
270
314
|
/**
|
271
315
|
* @param {string} str the path with query and fragment
|
@@ -280,47 +324,24 @@ const _parseResource = str => {
|
|
280
324
|
fragment: match[3] || ""
|
281
325
|
};
|
282
326
|
};
|
283
|
-
exports.parseResource = (
|
284
|
-
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
|
285
|
-
const cache = new WeakMap();
|
327
|
+
exports.parseResource = makeCacheable(_parseResource);
|
286
328
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
299
|
-
* @returns {ParsedResource} parsed parts
|
300
|
-
*/
|
301
|
-
const fn = (str, associatedObjectForCache) => {
|
302
|
-
if (!associatedObjectForCache) return realFn(str);
|
303
|
-
const cache = getCache(associatedObjectForCache);
|
304
|
-
const entry = cache.get(str);
|
305
|
-
if (entry !== undefined) return entry;
|
306
|
-
const result = realFn(str);
|
307
|
-
cache.set(str, result);
|
308
|
-
return result;
|
309
|
-
};
|
310
|
-
|
311
|
-
fn.bindCache = associatedObjectForCache => {
|
312
|
-
const cache = getCache(associatedObjectForCache);
|
313
|
-
return str => {
|
314
|
-
const entry = cache.get(str);
|
315
|
-
if (entry !== undefined) return entry;
|
316
|
-
const result = realFn(str);
|
317
|
-
cache.set(str, result);
|
318
|
-
return result;
|
319
|
-
};
|
329
|
+
/**
|
330
|
+
* Parse resource, skips fragment part
|
331
|
+
* @param {string} str the path with query and fragment
|
332
|
+
* @returns {ParsedResourceWithoutFragment} parsed parts
|
333
|
+
*/
|
334
|
+
const _parseResourceWithoutFragment = str => {
|
335
|
+
const match = PATH_QUERY_REGEXP.exec(str);
|
336
|
+
return {
|
337
|
+
resource: str,
|
338
|
+
path: match[1].replace(/\0(.)/g, "$1"),
|
339
|
+
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : ""
|
320
340
|
};
|
321
|
-
|
322
|
-
|
323
|
-
|
341
|
+
};
|
342
|
+
exports.parseResourceWithoutFragment = makeCacheable(
|
343
|
+
_parseResourceWithoutFragment
|
344
|
+
);
|
324
345
|
|
325
346
|
/**
|
326
347
|
* @param {string} filename the filename which should be undone
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Ivan Kopeykin @vankop
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const A_CODE = "a".charCodeAt(0);
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @param {string} hash hash
|
12
|
+
* @param {number} hashLength hash length
|
13
|
+
* @returns {string} returns hash that has at least one non numeric char
|
14
|
+
*/
|
15
|
+
module.exports = (hash, hashLength) => {
|
16
|
+
if (hashLength < 1) return "";
|
17
|
+
const slice = hash.slice(0, hashLength);
|
18
|
+
if (slice.match(/[^\d]/)) return slice;
|
19
|
+
return `${String.fromCharCode(
|
20
|
+
A_CODE + (parseInt(hash[0], 10) % 6)
|
21
|
+
)}${slice.slice(1)}`;
|
22
|
+
};
|
package/lib/util/semver.js
CHANGED
@@ -89,7 +89,9 @@ exports.versionLt = versionLt;
|
|
89
89
|
*/
|
90
90
|
exports.parseRange = str => {
|
91
91
|
const splitAndConvert = str => {
|
92
|
-
return str
|
92
|
+
return str
|
93
|
+
.split(".")
|
94
|
+
.map(item => (item !== "NaN" && `${+item}` === item ? +item : item));
|
93
95
|
};
|
94
96
|
// see https://docs.npmjs.com/misc/semver#range-grammar for grammar
|
95
97
|
const parsePartial = str => {
|
@@ -131,13 +133,15 @@ exports.parseRange = str => {
|
|
131
133
|
return [-range[0] - 1, ...range.slice(1)];
|
132
134
|
};
|
133
135
|
const parseSimple = str => {
|
134
|
-
// simple
|
135
|
-
// primitive
|
136
|
-
// tilde
|
137
|
-
// caret
|
136
|
+
// simple ::= primitive | partial | tilde | caret
|
137
|
+
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | '!' ) ( ' ' ) * partial
|
138
|
+
// tilde ::= '~' ( ' ' ) * partial
|
139
|
+
// caret ::= '^' ( ' ' ) * partial
|
138
140
|
const match = /^(\^|~|<=|<|>=|>|=|v|!)/.exec(str);
|
139
141
|
const start = match ? match[0] : "";
|
140
|
-
const remainder = parsePartial(
|
142
|
+
const remainder = parsePartial(
|
143
|
+
start.length ? str.slice(start.length).trim() : str.trim()
|
144
|
+
);
|
141
145
|
switch (start) {
|
142
146
|
case "^":
|
143
147
|
if (remainder.length > 1 && remainder[1] === 0) {
|
@@ -191,11 +195,14 @@ exports.parseRange = str => {
|
|
191
195
|
return [, ...arr, ...items.slice(1).map(() => fn)];
|
192
196
|
};
|
193
197
|
const parseRange = str => {
|
194
|
-
// range ::= hyphen | simple ( ' ' simple ) * | ''
|
195
|
-
// hyphen ::= partial ' - ' partial
|
196
|
-
const items = str.split(
|
198
|
+
// range ::= hyphen | simple ( ' ' ( ' ' ) * simple ) * | ''
|
199
|
+
// hyphen ::= partial ( ' ' ) * ' - ' ( ' ' ) * partial
|
200
|
+
const items = str.split(/\s+-\s+/);
|
197
201
|
if (items.length === 1) {
|
198
|
-
const items = str
|
202
|
+
const items = str
|
203
|
+
.trim()
|
204
|
+
.split(/(?<=[-0-9A-Za-z])\s+/g)
|
205
|
+
.map(parseSimple);
|
199
206
|
return combine(items, 2);
|
200
207
|
}
|
201
208
|
const a = parsePartial(items[0]);
|
@@ -167,14 +167,20 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
167
167
|
)}`,
|
168
168
|
`${RuntimeGlobals.asyncModule}(${
|
169
169
|
module.moduleArgument
|
170
|
-
}, ${runtimeTemplate.basicFunction(
|
171
|
-
"__webpack_handle_async_dependencies__",
|
170
|
+
}, async ${runtimeTemplate.basicFunction(
|
171
|
+
"__webpack_handle_async_dependencies__, __webpack_async_result__",
|
172
172
|
[
|
173
|
+
"try {",
|
173
174
|
importsCode,
|
174
175
|
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${promises.join(
|
175
176
|
", "
|
176
177
|
)}]);`,
|
177
|
-
|
178
|
+
`var [${promises.join(
|
179
|
+
", "
|
180
|
+
)}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__;`,
|
181
|
+
`${importsCompatCode}await ${instantiateCall};`,
|
182
|
+
"__webpack_async_result__();",
|
183
|
+
"} catch(e) { __webpack_async_result__(e); }"
|
178
184
|
]
|
179
185
|
)}, 1);`
|
180
186
|
])
|
@@ -6,7 +6,6 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
|
-
const CreateScriptUrlRuntimeModule = require("../runtime/CreateScriptUrlRuntimeModule");
|
10
9
|
const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenciesPlugin");
|
11
10
|
const ImportScriptsChunkLoadingRuntimeModule = require("./ImportScriptsChunkLoadingRuntimeModule");
|
12
11
|
|
@@ -43,7 +42,9 @@ class ImportScriptsChunkLoadingPlugin {
|
|
43
42
|
const withCreateScriptUrl = !!compilation.outputOptions.trustedTypes;
|
44
43
|
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
45
44
|
set.add(RuntimeGlobals.hasOwnProperty);
|
46
|
-
if (withCreateScriptUrl)
|
45
|
+
if (withCreateScriptUrl) {
|
46
|
+
set.add(RuntimeGlobals.createScriptUrl);
|
47
|
+
}
|
47
48
|
compilation.addRuntimeModule(
|
48
49
|
chunk,
|
49
50
|
new ImportScriptsChunkLoadingRuntimeModule(set, withCreateScriptUrl)
|
@@ -61,15 +62,6 @@ class ImportScriptsChunkLoadingPlugin {
|
|
61
62
|
compilation.hooks.runtimeRequirementInTree
|
62
63
|
.for(RuntimeGlobals.baseURI)
|
63
64
|
.tap("ImportScriptsChunkLoadingPlugin", handler);
|
64
|
-
compilation.hooks.runtimeRequirementInTree
|
65
|
-
.for(RuntimeGlobals.createScriptUrl)
|
66
|
-
.tap("RuntimePlugin", (chunk, set) => {
|
67
|
-
compilation.addRuntimeModule(
|
68
|
-
chunk,
|
69
|
-
new CreateScriptUrlRuntimeModule()
|
70
|
-
);
|
71
|
-
return true;
|
72
|
-
});
|
73
65
|
|
74
66
|
compilation.hooks.runtimeRequirementInTree
|
75
67
|
.for(RuntimeGlobals.ensureChunkHandlers)
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.69.1",
|
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",
|
7
7
|
"dependencies": {
|
8
|
-
"@types/eslint-scope": "^3.7.
|
9
|
-
"@types/estree": "^0.0.
|
8
|
+
"@types/eslint-scope": "^3.7.3",
|
9
|
+
"@types/estree": "^0.0.51",
|
10
10
|
"@webassemblyjs/ast": "1.11.1",
|
11
11
|
"@webassemblyjs/wasm-edit": "1.11.1",
|
12
12
|
"@webassemblyjs/wasm-parser": "1.11.1",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"tapable": "^2.1.1",
|
29
29
|
"terser-webpack-plugin": "^5.1.3",
|
30
30
|
"watchpack": "^2.3.1",
|
31
|
-
"webpack-sources": "^3.2.
|
31
|
+
"webpack-sources": "^3.2.3"
|
32
32
|
},
|
33
33
|
"peerDependenciesMeta": {
|
34
34
|
"webpack-cli": {
|
@@ -39,8 +39,8 @@
|
|
39
39
|
"@babel/core": "^7.11.1",
|
40
40
|
"@babel/preset-react": "^7.10.4",
|
41
41
|
"@types/es-module-lexer": "^0.4.1",
|
42
|
-
"@types/jest": "^27.0
|
43
|
-
"@types/node": "^
|
42
|
+
"@types/jest": "^27.4.0",
|
43
|
+
"@types/node": "^17.0.16",
|
44
44
|
"assemblyscript": "^0.19.16",
|
45
45
|
"babel-loader": "^8.1.0",
|
46
46
|
"benchmark": "^2.1.4",
|
@@ -56,7 +56,7 @@
|
|
56
56
|
"es6-promise-polyfill": "^1.2.0",
|
57
57
|
"eslint": "^7.14.0",
|
58
58
|
"eslint-config-prettier": "^8.1.0",
|
59
|
-
"eslint-plugin-jest": "^24.
|
59
|
+
"eslint-plugin-jest": "^24.7.0",
|
60
60
|
"eslint-plugin-jsdoc": "^33.0.0",
|
61
61
|
"eslint-plugin-node": "^11.0.0",
|
62
62
|
"eslint-plugin-prettier": "^4.0.0",
|
@@ -66,10 +66,10 @@
|
|
66
66
|
"husky": "^6.0.0",
|
67
67
|
"is-ci": "^3.0.0",
|
68
68
|
"istanbul": "^0.4.5",
|
69
|
-
"jest": "^27.
|
70
|
-
"jest-circus": "^27.
|
71
|
-
"jest-cli": "^27.
|
72
|
-
"jest-diff": "^27.
|
69
|
+
"jest": "^27.5.0",
|
70
|
+
"jest-circus": "^27.5.0",
|
71
|
+
"jest-cli": "^27.5.0",
|
72
|
+
"jest-diff": "^27.5.0",
|
73
73
|
"jest-junit": "^13.0.0",
|
74
74
|
"json-loader": "^0.5.7",
|
75
75
|
"json5": "^2.1.3",
|
@@ -98,9 +98,9 @@
|
|
98
98
|
"style-loader": "^2.0.0",
|
99
99
|
"terser": "^5.7.0",
|
100
100
|
"toml": "^3.0.0",
|
101
|
-
"tooling": "webpack/tooling#v1.
|
101
|
+
"tooling": "webpack/tooling#v1.21.0",
|
102
102
|
"ts-loader": "^8.0.2",
|
103
|
-
"typescript": "^4.
|
103
|
+
"typescript": "^4.5.5",
|
104
104
|
"url-loader": "^4.1.0",
|
105
105
|
"wast-loader": "^1.11.0",
|
106
106
|
"webassembly-feature": "1.3.0",
|
@@ -143,13 +143,6 @@
|
|
143
143
|
"test:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
|
144
144
|
"test:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\"",
|
145
145
|
"test:unit": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
|
146
|
-
"travis:integration": "yarn cover:integration --ci $JEST",
|
147
|
-
"travis:basic": "yarn cover:basic --ci $JEST",
|
148
|
-
"travis:lintunit": "yarn lint && yarn cover:unit --ci $JEST",
|
149
|
-
"travis:benchmark": "yarn benchmark --ci",
|
150
|
-
"appveyor:integration": "yarn cover:integration --ci %JEST%",
|
151
|
-
"appveyor:unit": "yarn cover:unit --ci %JEST%",
|
152
|
-
"appveyor:benchmark": "yarn benchmark --ci",
|
153
146
|
"build:examples": "cd examples && node buildAll.js",
|
154
147
|
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
|
155
148
|
"pretest": "yarn lint",
|
@@ -159,7 +152,7 @@
|
|
159
152
|
"type-lint": "tsc",
|
160
153
|
"typings-test": "tsc -p tsconfig.types.test.json",
|
161
154
|
"module-typings-test": "tsc -p tsconfig.module.test.json",
|
162
|
-
"spellcheck": "cspell \"
|
155
|
+
"spellcheck": "cspell \"**/*\"",
|
163
156
|
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
|
164
157
|
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
|
165
158
|
"fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
|