webpack 5.81.0 → 5.82.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/bin/webpack.js +13 -2
- package/lib/Compilation.js +2 -0
- package/lib/CssModule.js +39 -7
- package/lib/WebpackOptionsApply.js +33 -40
- package/lib/cache/MemoryWithGcCachePlugin.js +2 -0
- package/lib/config/defaults.js +1 -0
- package/lib/css/CssGenerator.js +4 -0
- package/lib/css/CssLoadingRuntimeModule.js +9 -2
- package/lib/css/CssModulesPlugin.js +136 -33
- package/lib/css/CssParser.js +144 -80
- package/lib/css/walkCssTokens.js +96 -20
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -0
- package/lib/javascript/BasicEvaluatedExpression.js +108 -1
- package/lib/javascript/JavascriptParser.js +132 -11
- package/lib/json/JsonData.js +25 -0
- package/lib/json/JsonGenerator.js +15 -3
- package/lib/json/JsonModulesPlugin.js +1 -0
- package/lib/json/JsonParser.js +2 -1
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +22 -3
- package/lib/schemes/DataUriPlugin.js +4 -0
- package/lib/schemes/HttpUriPlugin.js +38 -0
- package/lib/sharing/utils.js +293 -7
- package/lib/stats/DefaultStatsPrinterPlugin.js +25 -0
- package/lib/util/StackedCacheMap.js +6 -0
- package/lib/util/StringXor.js +51 -0
- package/lib/util/compileBooleanMatcher.js +31 -0
- package/lib/util/deprecation.js +8 -0
- package/lib/util/identifier.js +4 -0
- package/lib/util/numberHash.js +75 -21
- package/lib/util/propertyAccess.js +5 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +4 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +25 -0
- package/types.d.ts +121 -26
package/lib/util/deprecation.js
CHANGED
@@ -178,6 +178,14 @@ exports.createArrayToSetDeprecationSet = name => {
|
|
178
178
|
return SetDeprecatedArray;
|
179
179
|
};
|
180
180
|
|
181
|
+
/**
|
182
|
+
* @template T
|
183
|
+
* @param {Object} obj object
|
184
|
+
* @param {string} name property name
|
185
|
+
* @param {string} code deprecation code
|
186
|
+
* @param {string} note additional note
|
187
|
+
* @returns {Object} frozen object with deprecation when modifying
|
188
|
+
*/
|
181
189
|
exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
182
190
|
const message = `${name} will be frozen in future, all modifications are deprecated.${
|
183
191
|
note && `\n${note}`
|
package/lib/util/identifier.js
CHANGED
@@ -15,6 +15,10 @@ const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
15
15
|
* @property {Map<string, Map<string, string>>=} relativePaths
|
16
16
|
*/
|
17
17
|
|
18
|
+
/**
|
19
|
+
* @param {string} relativePath relative path
|
20
|
+
* @returns {string} request
|
21
|
+
*/
|
18
22
|
const relativePathToRequest = relativePath => {
|
19
23
|
if (relativePath === "") return "./.";
|
20
24
|
if (relativePath === "..") return "../.";
|
package/lib/util/numberHash.js
CHANGED
@@ -5,41 +5,95 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
/**
|
9
|
+
* The maximum safe integer value for 32-bit integers.
|
10
|
+
* @type {number}
|
11
|
+
*/
|
8
12
|
const SAFE_LIMIT = 0x80000000;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The maximum safe integer value for 32-bit integers minus one. This is used
|
16
|
+
* in the algorithm to ensure that intermediate hash values do not exceed the
|
17
|
+
* 32-bit integer limit.
|
18
|
+
* @type {number}
|
19
|
+
*/
|
9
20
|
const SAFE_PART = SAFE_LIMIT - 1;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* The number of 32-bit integers used to store intermediate hash values.
|
24
|
+
* @type {number}
|
25
|
+
*/
|
10
26
|
const COUNT = 4;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* An array used to store intermediate hash values during the calculation.
|
30
|
+
* @type {number[]}
|
31
|
+
*/
|
11
32
|
const arr = [0, 0, 0, 0, 0];
|
33
|
+
|
34
|
+
/**
|
35
|
+
* An array of prime numbers used in the hash calculation.
|
36
|
+
* @type {number[]}
|
37
|
+
*/
|
12
38
|
const primes = [3, 7, 17, 19];
|
13
39
|
|
40
|
+
/**
|
41
|
+
* Computes a hash value for the given string and range. This hashing algorithm is a modified
|
42
|
+
* version of the [FNV-1a algorithm](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function).
|
43
|
+
* It is optimized for speed and does **not** generate a cryptographic hash value.
|
44
|
+
*
|
45
|
+
* We use `numberHash` in `lib/ids/IdHelpers.js` to generate hash values for the module identifier. The generated
|
46
|
+
* hash is used as a prefix for the module id's to avoid collisions with other modules.
|
47
|
+
*
|
48
|
+
* @param {string} str The input string to hash.
|
49
|
+
* @param {number} range The range of the hash value (0 to range-1).
|
50
|
+
* @returns {number} - The computed hash value.
|
51
|
+
*
|
52
|
+
* @example
|
53
|
+
*
|
54
|
+
* ```js
|
55
|
+
* const numberHash = require("webpack/lib/util/numberHash");
|
56
|
+
* numberHash("hello", 1000); // 57
|
57
|
+
* numberHash("hello world"); // 990
|
58
|
+
* ```
|
59
|
+
*
|
60
|
+
*/
|
14
61
|
module.exports = (str, range) => {
|
62
|
+
/**
|
63
|
+
* Initialize the array with zeros before it is used
|
64
|
+
* to store intermediate hash values.
|
65
|
+
*/
|
15
66
|
arr.fill(0);
|
67
|
+
// For each character in the string
|
16
68
|
for (let i = 0; i < str.length; i++) {
|
69
|
+
// Get the character code.
|
17
70
|
const c = str.charCodeAt(i);
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
71
|
+
|
72
|
+
// For each 32-bit integer used to store the hash value
|
73
|
+
// add the character code to the current hash value and multiply by the prime number and
|
74
|
+
// add the previous 32-bit integer.
|
75
|
+
arr[0] = (arr[0] + c * primes[0] + arr[3]) & SAFE_PART;
|
76
|
+
arr[1] = (arr[1] + c * primes[1] + arr[0]) & SAFE_PART;
|
77
|
+
arr[2] = (arr[2] + c * primes[2] + arr[1]) & SAFE_PART;
|
78
|
+
arr[3] = (arr[3] + c * primes[3] + arr[2]) & SAFE_PART;
|
79
|
+
|
80
|
+
// For each 32-bit integer used to store the hash value
|
81
|
+
// XOR the current hash value with the value of the next 32-bit integer.
|
82
|
+
arr[0] = arr[0] ^ (arr[arr[0] % COUNT] >> 1);
|
83
|
+
arr[1] = arr[1] ^ (arr[arr[1] % COUNT] >> 1);
|
84
|
+
arr[2] = arr[2] ^ (arr[arr[2] % COUNT] >> 1);
|
85
|
+
arr[3] = arr[3] ^ (arr[arr[3] % COUNT] >> 1);
|
26
86
|
}
|
87
|
+
|
27
88
|
if (range <= SAFE_PART) {
|
28
|
-
|
29
|
-
for (let j = 0; j < COUNT; j++) {
|
30
|
-
sum = (sum + arr[j]) % range;
|
31
|
-
}
|
32
|
-
return sum;
|
89
|
+
return (arr[0] + arr[1] + arr[2] + arr[3]) % range;
|
33
90
|
} else {
|
34
|
-
|
35
|
-
let sum2 = 0;
|
91
|
+
// Calculate the range extension.
|
36
92
|
const rangeExt = Math.floor(range / SAFE_LIMIT);
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
sum2 = (sum2 + arr[j]) % rangeExt;
|
42
|
-
}
|
93
|
+
|
94
|
+
const sum1 = (arr[0] + arr[2]) & SAFE_PART;
|
95
|
+
const sum2 = (arr[0] + arr[2]) % rangeExt;
|
96
|
+
|
43
97
|
return (sum2 * SAFE_LIMIT + sum1) % range;
|
44
98
|
}
|
45
99
|
};
|
@@ -60,6 +60,11 @@ const RESERVED_IDENTIFIER = new Set([
|
|
60
60
|
"false"
|
61
61
|
]);
|
62
62
|
|
63
|
+
/**
|
64
|
+
* @param {ArrayLike<string>} properties properties
|
65
|
+
* @param {number} start start index
|
66
|
+
* @returns {string} chain of property accesses
|
67
|
+
*/
|
63
68
|
const propertyAccess = (properties, start = 0) => {
|
64
69
|
let str = "";
|
65
70
|
for (let i = start; i < properties.length; i++) {
|
@@ -12,6 +12,10 @@
|
|
12
12
|
/** @type {WeakMap<Compiler, Set<WasmLoadingType>>} */
|
13
13
|
const enabledTypes = new WeakMap();
|
14
14
|
|
15
|
+
/**
|
16
|
+
* @param {Compiler} compiler compiler instance
|
17
|
+
* @returns {Set<WasmLoadingType>} enabled types
|
18
|
+
*/
|
15
19
|
const getEnabledTypes = compiler => {
|
16
20
|
let set = enabledTypes.get(compiler);
|
17
21
|
if (set === undefined) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.82.0",
|
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",
|