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.
- package/bin/webpack.js +12 -0
- package/lib/ChunkGraph.js +17 -15
- package/lib/CompatibilityPlugin.js +31 -0
- package/lib/Compilation.js +9 -2
- package/lib/DefinePlugin.js +37 -11
- package/lib/ExportsInfo.js +22 -5
- package/lib/FileSystemInfo.js +126 -26
- package/lib/FlagDependencyUsagePlugin.js +33 -12
- package/lib/InitFragment.js +20 -32
- package/lib/NormalModule.js +6 -0
- package/lib/RuntimePlugin.js +40 -113
- package/lib/Template.js +23 -3
- package/lib/container/HoistContainerReferencesPlugin.js +47 -55
- package/lib/css/CssParser.js +135 -50
- package/lib/css/syntax.js +862 -765
- package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +17 -9
- package/lib/dependencies/HarmonyImportDependency.js +1 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -7
- package/lib/hmr/lazyCompilationBackend.js +19 -4
- package/lib/html/HtmlGenerator.js +23 -3
- package/lib/html/syntax.js +2485 -2399
- package/lib/ids/IdHelpers.js +24 -10
- package/lib/javascript/JavascriptParser.js +5 -2
- package/lib/javascript/syntax.js +700 -43
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +10 -2
- package/lib/optimize/AggressiveMergingPlugin.js +19 -15
- package/lib/optimize/ConcatenatedModule.js +19 -15
- package/lib/optimize/ModuleConcatenationPlugin.js +73 -24
- package/lib/optimize/SplitChunksPlugin.js +146 -44
- package/lib/prefetch/ResourceHintPlugin.js +96 -72
- package/lib/serialization/BinaryMiddleware.js +270 -938
- package/lib/stats/DefaultStatsFactoryPlugin.js +204 -198
- package/lib/stats/DefaultStatsPrinterPlugin.js +24 -166
- package/lib/stats/StatsFactory.js +31 -9
- package/package.json +2 -2
- package/types.d.ts +0 -4
package/lib/ids/IdHelpers.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 <
|
|
82
|
+
if (string.length < MAX_SHORTENED_STRING_LENGTH) return string;
|
|
74
83
|
return (
|
|
75
|
-
string.slice(
|
|
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,
|
|
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
|
|
5629
|
-
* comments
|
|
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 ||
|