webpack 5.65.0 → 5.69.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.

Files changed (134) hide show
  1. package/README.md +1 -1
  2. package/lib/APIPlugin.js +33 -0
  3. package/lib/Cache.js +1 -1
  4. package/lib/CacheFacade.js +4 -11
  5. package/lib/Chunk.js +2 -0
  6. package/lib/ChunkGraph.js +1 -2
  7. package/lib/CleanPlugin.js +1 -1
  8. package/lib/Compilation.js +93 -47
  9. package/lib/Compiler.js +57 -3
  10. package/lib/ContextModule.js +100 -41
  11. package/lib/ContextModuleFactory.js +60 -21
  12. package/lib/DelegatedModule.js +1 -1
  13. package/lib/Dependency.js +10 -0
  14. package/lib/DependencyTemplate.js +9 -0
  15. package/lib/DependencyTemplates.js +1 -1
  16. package/lib/DllModule.js +1 -1
  17. package/lib/EvalDevToolModulePlugin.js +16 -1
  18. package/lib/EvalSourceMapDevToolPlugin.js +18 -1
  19. package/lib/ExportsInfo.js +4 -4
  20. package/lib/ExternalModule.js +93 -53
  21. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  22. package/lib/FileSystemInfo.js +29 -25
  23. package/lib/Generator.js +2 -0
  24. package/lib/HookWebpackError.js +1 -1
  25. package/lib/Module.js +25 -4
  26. package/lib/ModuleFilenameHelpers.js +5 -1
  27. package/lib/MultiCompiler.js +1 -1
  28. package/lib/MultiWatching.js +1 -1
  29. package/lib/NormalModule.js +9 -5
  30. package/lib/NormalModuleFactory.js +25 -27
  31. package/lib/ProgressPlugin.js +1 -1
  32. package/lib/RawModule.js +1 -1
  33. package/lib/RuntimeGlobals.js +29 -1
  34. package/lib/RuntimeModule.js +1 -1
  35. package/lib/RuntimePlugin.js +50 -0
  36. package/lib/RuntimeTemplate.js +21 -0
  37. package/lib/Template.js +2 -1
  38. package/lib/TemplatedPathPlugin.js +48 -23
  39. package/lib/Watching.js +2 -2
  40. package/lib/WebpackOptionsApply.js +43 -2
  41. package/lib/asset/AssetGenerator.js +67 -26
  42. package/lib/asset/AssetModulesPlugin.js +3 -0
  43. package/lib/asset/RawDataUrlModule.js +148 -0
  44. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
  45. package/lib/buildChunkGraph.js +1 -1
  46. package/lib/cache/ResolverCachePlugin.js +81 -29
  47. package/lib/cli.js +44 -3
  48. package/lib/config/defaults.js +86 -7
  49. package/lib/config/normalization.js +5 -0
  50. package/lib/container/ContainerEntryModule.js +4 -2
  51. package/lib/container/FallbackModule.js +4 -4
  52. package/lib/container/RemoteModule.js +4 -2
  53. package/lib/css/CssExportsGenerator.js +139 -0
  54. package/lib/css/CssGenerator.js +109 -0
  55. package/lib/css/CssLoadingRuntimeModule.js +440 -0
  56. package/lib/css/CssModulesPlugin.js +462 -0
  57. package/lib/css/CssParser.js +618 -0
  58. package/lib/css/walkCssTokens.js +659 -0
  59. package/lib/debug/ProfilingPlugin.js +15 -14
  60. package/lib/dependencies/ContextElementDependency.js +8 -2
  61. package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
  62. package/lib/dependencies/CssExportDependency.js +85 -0
  63. package/lib/dependencies/CssImportDependency.js +75 -0
  64. package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
  65. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
  66. package/lib/dependencies/CssUrlDependency.js +132 -0
  67. package/lib/dependencies/ExportsInfoDependency.js +6 -0
  68. package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
  69. package/lib/dependencies/ImportMetaPlugin.js +22 -3
  70. package/lib/dependencies/LoaderPlugin.js +2 -2
  71. package/lib/dependencies/URLDependency.js +3 -8
  72. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
  73. package/lib/hmr/LazyCompilationPlugin.js +45 -21
  74. package/lib/hmr/lazyCompilationBackend.js +4 -2
  75. package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
  76. package/lib/ids/HashedModuleIdsPlugin.js +9 -12
  77. package/lib/ids/IdHelpers.js +24 -10
  78. package/lib/ids/NamedModuleIdsPlugin.js +6 -9
  79. package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
  80. package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
  81. package/lib/ids/SyncModuleIdsPlugin.js +140 -0
  82. package/lib/index.js +10 -0
  83. package/lib/javascript/JavascriptGenerator.js +1 -0
  84. package/lib/javascript/JavascriptModulesPlugin.js +27 -2
  85. package/lib/javascript/StartupHelpers.js +6 -5
  86. package/lib/library/AssignLibraryPlugin.js +34 -5
  87. package/lib/library/EnableLibraryPlugin.js +11 -0
  88. package/lib/node/NodeTargetPlugin.js +1 -0
  89. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
  90. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
  91. package/lib/optimize/ConcatenatedModule.js +21 -9
  92. package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
  93. package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
  94. package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
  95. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
  96. package/lib/schemes/HttpUriPlugin.js +32 -11
  97. package/lib/serialization/FileMiddleware.js +44 -9
  98. package/lib/sharing/ConsumeSharedModule.js +4 -2
  99. package/lib/sharing/ProvideSharedModule.js +4 -2
  100. package/lib/sharing/utils.js +1 -1
  101. package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
  102. package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
  103. package/lib/util/ArrayHelpers.js +18 -4
  104. package/lib/util/AsyncQueue.js +1 -1
  105. package/lib/util/compileBooleanMatcher.js +1 -1
  106. package/lib/util/deterministicGrouping.js +1 -1
  107. package/lib/util/hash/xxhash64.js +2 -2
  108. package/lib/util/identifier.js +65 -44
  109. package/lib/util/internalSerializables.js +11 -0
  110. package/lib/util/nonNumericOnlyHash.js +22 -0
  111. package/lib/util/semver.js +17 -10
  112. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
  113. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -2
  114. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
  115. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  116. package/package.json +16 -23
  117. package/schemas/WebpackOptions.check.js +1 -1
  118. package/schemas/WebpackOptions.json +96 -1
  119. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  120. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  121. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  122. package/schemas/plugins/container/ContainerPlugin.json +2 -1
  123. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  124. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  125. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  126. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  127. package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
  128. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  129. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  130. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  131. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  132. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  133. package/schemas/plugins/css/CssParserOptions.json +3 -0
  134. package/types.d.ts +295 -59
@@ -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": filteredModules =>
189
+ "compilation.filteredModules": (
190
+ filteredModules,
191
+ { compilation: { modules } }
192
+ ) =>
167
193
  filteredModules > 0
168
- ? `${filteredModules} ${plural(filteredModules, "module", "modules")}`
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(filteredAssets, "asset", "assets")}`
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(filteredChildren, "asset", "assets")}`
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 [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
286
- return (prefix || "") + bold(resource);
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(filteredReasons, "reason", "reasons")}`
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(filteredChildren, "module", "modules")}`
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 }) => cyan(userRequest),
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": filteredChildren =>
447
+ "moduleReason.filteredChildren": (
448
+ filteredChildren,
449
+ { moduleReason: { children } }
450
+ ) =>
401
451
  filteredChildren > 0
402
- ? `${filteredChildren} ${plural(filteredChildren, "reason", "reasons")}`
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 ? `${n} ${plural(n, "asset", "assets")}` : undefined,
432
- "chunkGroup.filteredAuxiliaryAssets": n =>
433
- n > 0 ? `${n} auxiliary ${plural(n, "asset", "assets")}` : undefined,
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"
@@ -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
- * @param {Array} arr Array of values to be partitioned
19
- * @param {(value: any) => boolean} fn Partition function which partitions based on truthiness of result.
20
- * @returns {[Array, Array]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
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;
@@ -19,7 +19,7 @@ let inHandleResult = 0;
19
19
  /**
20
20
  * @template T
21
21
  * @callback Callback
22
- * @param {WebpackError=} err
22
+ * @param {(WebpackError | null)=} err
23
23
  * @param {T=} result
24
24
  */
25
25
 
@@ -18,7 +18,7 @@ const toSimpleString = str => {
18
18
 
19
19
  /**
20
20
  * @param {Record<string|number, boolean>} map value map
21
- * @returns {true|false|function(string): string} true/false, when unconditionally true/false, or a template function to determine the value at runtime
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),
@@ -10,8 +10,8 @@ const create = require("./wasm-hash");
10
10
  //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
11
11
  const xxhash64 = new WebAssembly.Module(
12
12
  Buffer.from(
13
- // 1173 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrUIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLqwYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gA0LP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAEQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IAVCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhq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iEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
15
15
  "base64"
16
16
  )
17
17
  );
@@ -81,7 +81,49 @@ const requestToAbsolute = (context, relativePath) => {
81
81
  return relativePath;
82
82
  };
83
83
 
84
- const makeCacheable = fn => {
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 = makeCacheable(_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 = makeCacheable(_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 = makeCacheable(_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 = makeCacheable(_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 = (realFn => {
284
- /** @type {WeakMap<object, Map<string, ParsedResource>>} */
285
- const cache = new WeakMap();
327
+ exports.parseResource = makeCacheable(_parseResource);
286
328
 
287
- const getCache = associatedObjectForCache => {
288
- const entry = cache.get(associatedObjectForCache);
289
- if (entry !== undefined) return entry;
290
- /** @type {Map<string, ParsedResource>} */
291
- const map = new Map();
292
- cache.set(associatedObjectForCache, map);
293
- return map;
294
- };
295
-
296
- /**
297
- * @param {string} str the path with query and fragment
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
- return fn;
323
- })(_parseResource);
341
+ };
342
+ exports.parseResourceWithoutFragment = makeCacheable(
343
+ _parseResourceWithoutFragment
344
+ );
324
345
 
325
346
  /**
326
347
  * @param {string} filename the filename which should be undone
@@ -67,6 +67,16 @@ module.exports = {
67
67
  require("../dependencies/ContextElementDependency"),
68
68
  "dependencies/CriticalDependencyWarning": () =>
69
69
  require("../dependencies/CriticalDependencyWarning"),
70
+ "dependencies/CssImportDependency": () =>
71
+ require("../dependencies/CssImportDependency"),
72
+ "dependencies/CssLocalIdentifierDependency": () =>
73
+ require("../dependencies/CssLocalIdentifierDependency"),
74
+ "dependencies/CssSelfLocalIdentifierDependency": () =>
75
+ require("../dependencies/CssSelfLocalIdentifierDependency"),
76
+ "dependencies/CssExportDependency": () =>
77
+ require("../dependencies/CssExportDependency"),
78
+ "dependencies/CssUrlDependency": () =>
79
+ require("../dependencies/CssUrlDependency"),
70
80
  "dependencies/DelegatedSourceDependency": () =>
71
81
  require("../dependencies/DelegatedSourceDependency"),
72
82
  "dependencies/DllEntryDependency": () =>
@@ -175,6 +185,7 @@ module.exports = {
175
185
  ModuleParseError: () => require("../ModuleParseError"),
176
186
  ModuleWarning: () => require("../ModuleWarning"),
177
187
  NormalModule: () => require("../NormalModule"),
188
+ RawDataUrlModule: () => require("../asset/RawDataUrlModule"),
178
189
  RawModule: () => require("../RawModule"),
179
190
  "sharing/ConsumeSharedModule": () =>
180
191
  require("../sharing/ConsumeSharedModule"),
@@ -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
+ };
@@ -89,7 +89,9 @@ exports.versionLt = versionLt;
89
89
  */
90
90
  exports.parseRange = str => {
91
91
  const splitAndConvert = str => {
92
- return str.split(".").map(item => (`${+item}` === item ? +item : item));
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 ::= primitive | partial | tilde | caret
135
- // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
136
- // tilde ::= '~' partial
137
- // caret ::= '^' partial
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(str.slice(start.length));
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.trim().split(/\s+/g).map(parseSimple);
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
- "return __webpack_async_dependencies__.then ? __webpack_async_dependencies__.then(__webpack_instantiate__) : __webpack_instantiate__(__webpack_async_dependencies__);"
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
  ])
@@ -96,7 +96,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
96
96
  )}]`;
97
97
  const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
98
98
  const hasJsMatcher = compileBooleanMatcher(conditionMap);
99
- const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
99
+ const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
100
100
 
101
101
  const stateExpression = withHmr
102
102
  ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_jsonp`
@@ -419,7 +419,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
419
419
  `if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId]) {`,
420
420
  Template.indent("installedChunks[chunkId][0]();"),
421
421
  "}",
422
- "installedChunks[chunkIds[i]] = 0;"
422
+ "installedChunks[chunkId] = 0;"
423
423
  ]),
424
424
  "}",
425
425
  withOnChunkLoad
@@ -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) set.add(RuntimeGlobals.createScriptUrl);
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)
@@ -53,7 +53,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
53
53
  const hasJsMatcher = compileBooleanMatcher(
54
54
  chunkGraph.getChunkConditionMap(chunk, chunkHasJs)
55
55
  );
56
- const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
56
+ const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
57
57
 
58
58
  const outputName = this.compilation.getPath(
59
59
  getChunkFilenameTemplate(chunk, this.compilation.outputOptions),