webpack 5.109.0 → 5.109.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.
Files changed (39) hide show
  1. package/bin/webpack.js +12 -0
  2. package/lib/ChunkGraph.js +17 -15
  3. package/lib/CompatibilityPlugin.js +31 -0
  4. package/lib/Compilation.js +9 -2
  5. package/lib/DefinePlugin.js +37 -11
  6. package/lib/ExportsInfo.js +22 -5
  7. package/lib/FileSystemInfo.js +126 -26
  8. package/lib/FlagDependencyUsagePlugin.js +33 -12
  9. package/lib/InitFragment.js +20 -32
  10. package/lib/NormalModule.js +6 -0
  11. package/lib/RuntimePlugin.js +40 -113
  12. package/lib/Template.js +23 -3
  13. package/lib/container/HoistContainerReferencesPlugin.js +47 -55
  14. package/lib/css/CssParser.js +135 -50
  15. package/lib/css/syntax.js +862 -765
  16. package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
  17. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
  18. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +17 -9
  19. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  20. package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -7
  21. package/lib/hmr/lazyCompilationBackend.js +19 -4
  22. package/lib/html/HtmlGenerator.js +23 -3
  23. package/lib/html/syntax.js +2485 -2399
  24. package/lib/ids/IdHelpers.js +24 -10
  25. package/lib/javascript/JavascriptParser.js +5 -2
  26. package/lib/javascript/syntax.js +700 -43
  27. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -2
  28. package/lib/node/ReadFileCompileWasmPlugin.js +10 -2
  29. package/lib/optimize/AggressiveMergingPlugin.js +19 -15
  30. package/lib/optimize/ConcatenatedModule.js +19 -15
  31. package/lib/optimize/ModuleConcatenationPlugin.js +73 -24
  32. package/lib/optimize/SplitChunksPlugin.js +146 -44
  33. package/lib/prefetch/ResourceHintPlugin.js +96 -72
  34. package/lib/serialization/BinaryMiddleware.js +270 -938
  35. package/lib/stats/DefaultStatsFactoryPlugin.js +204 -198
  36. package/lib/stats/DefaultStatsPrinterPlugin.js +24 -166
  37. package/lib/stats/StatsFactory.js +31 -9
  38. package/package.json +2 -2
  39. package/types.d.ts +0 -4
@@ -18,6 +18,17 @@ const numberHash = require("../util/numberHash");
18
18
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
19
19
  /** @typedef {import("../css/CssModule").CssModuleBuildMeta} CssModuleBuildMeta */
20
20
 
21
+ // Numbers longer than this are written in exponential form ("...e+xx"), so a
22
+ // longer string can't be a plain integer id.
23
+ const MAX_NUMERIC_STRING_LENGTH = 21;
24
+ // Char codes bounding the "looks like a plain number" fast check in `avoidNumber`.
25
+ const CC_HYPHEN_MINUS = 45;
26
+ const CC_DIGIT_ONE = 49;
27
+ const CC_DIGIT_NINE = 57;
28
+ // Long ids are truncated to this length and disambiguated with a short hash.
29
+ const MAX_SHORTENED_STRING_LENGTH = 100;
30
+ const SHORTENED_STRING_HASH_LENGTH = 6;
31
+
21
32
  /**
22
33
  * Returns hash.
23
34
  * @param {string} str string to hash
@@ -38,14 +49,12 @@ const getHash = (str, len, hashFunction) => {
38
49
  * @returns {string} string prefixed by an underscore if it is a number
39
50
  */
40
51
  const avoidNumber = (str) => {
41
- // max length of a number is 21 chars, bigger numbers a written as "...e+xx"
42
- if (str.length > 21) return str;
52
+ if (str.length > MAX_NUMERIC_STRING_LENGTH) return str;
43
53
  const firstChar = str.charCodeAt(0);
44
- // skip everything that doesn't look like a number
45
- // charCodes: "-": 45, "1": 49, "9": 57
46
- if (firstChar < 49) {
47
- if (firstChar !== 45) return str;
48
- } else if (firstChar > 57) {
54
+ // Skip everything that doesn't start like a number ("-" or a digit).
55
+ if (firstChar < CC_DIGIT_ONE) {
56
+ if (firstChar !== CC_HYPHEN_MINUS) return str;
57
+ } else if (firstChar > CC_DIGIT_NINE) {
49
58
  return str;
50
59
  }
51
60
  if (str === String(Number(str))) {
@@ -70,11 +79,16 @@ const requestToId = (request) =>
70
79
  * @returns {string} string with limited max length to 100 chars
71
80
  */
72
81
  const shortenLongString = (string, delimiter, hashFunction) => {
73
- if (string.length < 100) return string;
82
+ if (string.length < MAX_SHORTENED_STRING_LENGTH) return string;
74
83
  return (
75
- string.slice(0, 100 - 6 - delimiter.length) +
84
+ string.slice(
85
+ 0,
86
+ MAX_SHORTENED_STRING_LENGTH -
87
+ SHORTENED_STRING_HASH_LENGTH -
88
+ delimiter.length
89
+ ) +
76
90
  delimiter +
77
- getHash(string, 6, hashFunction)
91
+ getHash(string, SHORTENED_STRING_HASH_LENGTH, hashFunction)
78
92
  );
79
93
  };
80
94
 
@@ -5625,8 +5625,10 @@ class JavascriptParser extends Parser {
5625
5625
  }
5626
5626
 
5627
5627
  /**
5628
- * First significant char code at or after `pos`, skipping whitespace and
5629
- * comments, or -1 at end of source.
5628
+ * First significant char code at or after `pos`, skipping whitespace,
5629
+ * comments and grouping `)` (a parenthesized node's range excludes its
5630
+ * wrapping parens, so a `,`/`;` separator can sit behind them), or -1 at
5631
+ * end of source.
5630
5632
  * @param {string} source source text
5631
5633
  * @param {number} pos start offset
5632
5634
  * @returns {number} char code of the next token, or -1
@@ -5643,6 +5645,7 @@ class JavascriptParser extends Parser {
5643
5645
  c === 13 ||
5644
5646
  c === 11 ||
5645
5647
  c === 12 ||
5648
+ c === 41 /* ) */ ||
5646
5649
  c === 0xa0 ||
5647
5650
  c === 0xfeff ||
5648
5651
  c === 0x2028 ||