webpack 5.58.2 → 5.61.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/hot/lazy-compilation-node.js +3 -1
- package/lib/Compilation.js +11 -14
- package/lib/Compiler.js +2 -2
- package/lib/DefinePlugin.js +1 -1
- package/lib/FileSystemInfo.js +50 -7
- package/lib/NormalModule.js +40 -14
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/WebpackOptionsApply.js +12 -11
- package/lib/cache/AddManagedPathsPlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -3
- package/lib/config/defaults.js +65 -43
- package/lib/config/normalization.js +6 -1
- package/lib/hmr/LazyCompilationPlugin.js +9 -5
- package/lib/hmr/lazyCompilationBackend.js +42 -10
- package/lib/node/NodeTargetPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/SplitChunksPlugin.js +49 -1
- package/lib/schemes/HttpUriPlugin.js +108 -31
- package/lib/util/createHash.js +12 -0
- package/lib/util/fs.js +2 -0
- package/lib/util/hash/BatchedHash.js +3 -4
- package/lib/util/hash/md4.js +20 -0
- package/lib/util/hash/wasm-hash.js +163 -0
- package/lib/util/hash/xxhash64.js +5 -139
- package/lib/util/propertyAccess.js +2 -2
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +324 -55
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +28 -0
- package/types.d.ts +135 -83
@@ -0,0 +1,163 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
// 65536 is the size of a wasm memory page
|
9
|
+
// 64 is the maximum chunk size for every possible wasm hash implementation
|
10
|
+
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
11
|
+
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
12
|
+
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
13
|
+
|
14
|
+
class WasmHash {
|
15
|
+
/**
|
16
|
+
* @param {WebAssembly.Instance} instance wasm instance
|
17
|
+
* @param {WebAssembly.Instance[]} instancesPool pool of instances
|
18
|
+
* @param {number} chunkSize size of data chunks passed to wasm
|
19
|
+
* @param {number} digestSize size of digest returned by wasm
|
20
|
+
*/
|
21
|
+
constructor(instance, instancesPool, chunkSize, digestSize) {
|
22
|
+
const exports = /** @type {any} */ (instance.exports);
|
23
|
+
exports.init();
|
24
|
+
this.exports = exports;
|
25
|
+
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
26
|
+
this.buffered = 0;
|
27
|
+
this.instancesPool = instancesPool;
|
28
|
+
this.chunkSize = chunkSize;
|
29
|
+
this.digestSize = digestSize;
|
30
|
+
}
|
31
|
+
|
32
|
+
reset() {
|
33
|
+
this.buffered = 0;
|
34
|
+
this.exports.init();
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @param {Buffer | string} data data
|
39
|
+
* @param {BufferEncoding=} encoding encoding
|
40
|
+
* @returns {this} itself
|
41
|
+
*/
|
42
|
+
update(data, encoding) {
|
43
|
+
if (typeof data === "string") {
|
44
|
+
while (data.length > MAX_SHORT_STRING) {
|
45
|
+
this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
|
46
|
+
data = data.slice(MAX_SHORT_STRING);
|
47
|
+
}
|
48
|
+
this._updateWithShortString(data, encoding);
|
49
|
+
return this;
|
50
|
+
}
|
51
|
+
this._updateWithBuffer(data);
|
52
|
+
return this;
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @param {string} data data
|
57
|
+
* @param {BufferEncoding=} encoding encoding
|
58
|
+
* @returns {void}
|
59
|
+
*/
|
60
|
+
_updateWithShortString(data, encoding) {
|
61
|
+
const { exports, buffered, mem, chunkSize } = this;
|
62
|
+
let endPos;
|
63
|
+
if (data.length < 70) {
|
64
|
+
if (!encoding || encoding === "utf-8" || encoding === "utf8") {
|
65
|
+
endPos = buffered;
|
66
|
+
for (let i = 0; i < data.length; i++) {
|
67
|
+
const cc = data.charCodeAt(i);
|
68
|
+
if (cc < 0x80) mem[endPos++] = cc;
|
69
|
+
else if (cc < 0x800) {
|
70
|
+
mem[endPos] = (cc >> 6) | 0xc0;
|
71
|
+
mem[endPos + 1] = (cc & 0x3f) | 0x80;
|
72
|
+
endPos += 2;
|
73
|
+
} else {
|
74
|
+
// bail-out for weird chars
|
75
|
+
endPos += mem.write(data.slice(endPos), endPos, encoding);
|
76
|
+
break;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
} else if (encoding === "latin1") {
|
80
|
+
endPos = buffered;
|
81
|
+
for (let i = 0; i < data.length; i++) {
|
82
|
+
const cc = data.charCodeAt(i);
|
83
|
+
mem[endPos++] = cc;
|
84
|
+
}
|
85
|
+
} else {
|
86
|
+
endPos = buffered + mem.write(data, buffered, encoding);
|
87
|
+
}
|
88
|
+
} else {
|
89
|
+
endPos = buffered + mem.write(data, buffered, encoding);
|
90
|
+
}
|
91
|
+
if (endPos < chunkSize) {
|
92
|
+
this.buffered = endPos;
|
93
|
+
} else {
|
94
|
+
const l = endPos & ~(this.chunkSize - 1);
|
95
|
+
exports.update(l);
|
96
|
+
const newBuffered = endPos - l;
|
97
|
+
this.buffered = newBuffered;
|
98
|
+
if (newBuffered > 0) mem.copyWithin(0, l, endPos);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* @param {Buffer} data data
|
104
|
+
* @returns {void}
|
105
|
+
*/
|
106
|
+
_updateWithBuffer(data) {
|
107
|
+
const { exports, buffered, mem } = this;
|
108
|
+
const length = data.length;
|
109
|
+
if (buffered + length < this.chunkSize) {
|
110
|
+
data.copy(mem, buffered, 0, length);
|
111
|
+
this.buffered += length;
|
112
|
+
} else {
|
113
|
+
const l = (buffered + length) & ~(this.chunkSize - 1);
|
114
|
+
if (l > 65536) {
|
115
|
+
let i = 65536 - buffered;
|
116
|
+
data.copy(mem, buffered, 0, i);
|
117
|
+
exports.update(65536);
|
118
|
+
const stop = l - buffered - 65536;
|
119
|
+
while (i < stop) {
|
120
|
+
data.copy(mem, 0, i, i + 65536);
|
121
|
+
exports.update(65536);
|
122
|
+
i += 65536;
|
123
|
+
}
|
124
|
+
data.copy(mem, 0, i, l - buffered);
|
125
|
+
exports.update(l - buffered - i);
|
126
|
+
} else {
|
127
|
+
data.copy(mem, buffered, 0, l - buffered);
|
128
|
+
exports.update(l);
|
129
|
+
}
|
130
|
+
const newBuffered = length + buffered - l;
|
131
|
+
this.buffered = newBuffered;
|
132
|
+
if (newBuffered > 0) data.copy(mem, 0, length - newBuffered, length);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
digest(type) {
|
137
|
+
const { exports, buffered, mem, digestSize } = this;
|
138
|
+
exports.final(buffered);
|
139
|
+
this.instancesPool.push(this);
|
140
|
+
const hex = mem.toString("latin1", 0, digestSize);
|
141
|
+
if (type === "hex") return hex;
|
142
|
+
if (type === "binary" || !type) return Buffer.from(hex, "hex");
|
143
|
+
return Buffer.from(hex, "hex").toString(type);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
148
|
+
if (instancesPool.length > 0) {
|
149
|
+
const old = instancesPool.pop();
|
150
|
+
old.reset();
|
151
|
+
return old;
|
152
|
+
} else {
|
153
|
+
return new WasmHash(
|
154
|
+
new WebAssembly.Instance(wasmModule),
|
155
|
+
instancesPool,
|
156
|
+
chunkSize,
|
157
|
+
digestSize
|
158
|
+
);
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
module.exports = create;
|
163
|
+
module.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
|
@@ -5,150 +5,16 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const create = require("./wasm-hash");
|
9
|
+
|
8
10
|
//#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
|
9
11
|
const xxhash64 = new WebAssembly.Module(
|
10
12
|
Buffer.from(
|
11
|
-
//
|
12
|
-
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+
|
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/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhqIABNBEAgAiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEACfyACIAE1AgBCh5Wvr5i23puef36FQheJQs/W077Sx6vZQn5C+fPd8Zn2masWfCECIAFBBGoLIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAiACQh2IhUL5893xmfaZqxZ+IgIgAkIgiIUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
|
13
15
|
"base64"
|
14
16
|
)
|
15
17
|
);
|
16
18
|
//#endregion
|
17
19
|
|
18
|
-
|
19
|
-
/**
|
20
|
-
* @param {WebAssembly.Instance} instance wasm instance
|
21
|
-
*/
|
22
|
-
constructor(instance) {
|
23
|
-
const exports = /** @type {any} */ (instance.exports);
|
24
|
-
exports.init();
|
25
|
-
this.exports = exports;
|
26
|
-
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
27
|
-
this.buffered = 0;
|
28
|
-
}
|
29
|
-
|
30
|
-
reset() {
|
31
|
-
this.buffered = 0;
|
32
|
-
this.exports.init();
|
33
|
-
}
|
34
|
-
|
35
|
-
/**
|
36
|
-
* @param {Buffer | string} data data
|
37
|
-
* @param {BufferEncoding=} encoding encoding
|
38
|
-
* @returns {this} itself
|
39
|
-
*/
|
40
|
-
update(data, encoding) {
|
41
|
-
if (typeof data === "string") {
|
42
|
-
if (data.length < 21845) {
|
43
|
-
this._updateWithShortString(data, encoding);
|
44
|
-
return this;
|
45
|
-
} else {
|
46
|
-
data = Buffer.from(data, encoding);
|
47
|
-
}
|
48
|
-
}
|
49
|
-
this._updateWithBuffer(data);
|
50
|
-
return this;
|
51
|
-
}
|
52
|
-
|
53
|
-
/**
|
54
|
-
* @param {string} data data
|
55
|
-
* @param {BufferEncoding=} encoding encoding
|
56
|
-
* @returns {void}
|
57
|
-
*/
|
58
|
-
_updateWithShortString(data, encoding) {
|
59
|
-
const { exports, buffered, mem } = this;
|
60
|
-
let endPos;
|
61
|
-
if (data.length < 70) {
|
62
|
-
if (!encoding || encoding === "utf-8" || encoding === "utf8") {
|
63
|
-
endPos = buffered;
|
64
|
-
for (let i = 0; i < data.length; i++) {
|
65
|
-
const cc = data.charCodeAt(i);
|
66
|
-
if (cc < 0x80) mem[endPos++] = cc;
|
67
|
-
else if (cc < 0x800) {
|
68
|
-
mem[endPos] = (cc >> 6) | 0xc0;
|
69
|
-
mem[endPos + 1] = (cc & 0x3f) | 0x80;
|
70
|
-
endPos += 2;
|
71
|
-
} else {
|
72
|
-
// bail-out for weird chars
|
73
|
-
endPos += mem.write(data.slice(endPos), endPos, encoding);
|
74
|
-
break;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
} else if (encoding === "latin1") {
|
78
|
-
endPos = buffered;
|
79
|
-
for (let i = 0; i < data.length; i++) {
|
80
|
-
const cc = data.charCodeAt(i);
|
81
|
-
mem[endPos++] = cc;
|
82
|
-
}
|
83
|
-
} else {
|
84
|
-
endPos = buffered + mem.write(data, buffered, encoding);
|
85
|
-
}
|
86
|
-
} else {
|
87
|
-
endPos = buffered + mem.write(data, buffered, encoding);
|
88
|
-
}
|
89
|
-
if (endPos < 32) {
|
90
|
-
this.buffered = endPos;
|
91
|
-
} else {
|
92
|
-
const l = (endPos >> 5) << 5;
|
93
|
-
exports.update(l);
|
94
|
-
const newBuffered = endPos - l;
|
95
|
-
this.buffered = newBuffered;
|
96
|
-
if (newBuffered > 0) mem.copyWithin(0, l, endPos);
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
/**
|
101
|
-
* @param {Buffer} data data
|
102
|
-
* @returns {void}
|
103
|
-
*/
|
104
|
-
_updateWithBuffer(data) {
|
105
|
-
const { exports, buffered, mem } = this;
|
106
|
-
const length = data.length;
|
107
|
-
if (buffered + length < 32) {
|
108
|
-
data.copy(mem, buffered, 0, length);
|
109
|
-
this.buffered += length;
|
110
|
-
} else {
|
111
|
-
const l = ((buffered + length) >> 5) << 5;
|
112
|
-
if (l > 65536) {
|
113
|
-
let i = 65536 - buffered;
|
114
|
-
data.copy(mem, buffered, 0, i);
|
115
|
-
exports.update(65536);
|
116
|
-
const stop = l - buffered - 65536;
|
117
|
-
while (i < stop) {
|
118
|
-
data.copy(mem, 0, i, i + 65536);
|
119
|
-
exports.update(65536);
|
120
|
-
i += 65536;
|
121
|
-
}
|
122
|
-
data.copy(mem, 0, i, l - buffered);
|
123
|
-
exports.update(l - buffered - i);
|
124
|
-
} else {
|
125
|
-
data.copy(mem, buffered, 0, l - buffered);
|
126
|
-
exports.update(l);
|
127
|
-
}
|
128
|
-
const newBuffered = length + buffered - l;
|
129
|
-
this.buffered = newBuffered;
|
130
|
-
if (newBuffered > 0) data.copy(mem, 0, length - newBuffered, length);
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
134
|
-
digest(type) {
|
135
|
-
const { exports, buffered, mem } = this;
|
136
|
-
exports.final(buffered);
|
137
|
-
instancesPool.push(this);
|
138
|
-
return mem.toString("latin1", 0, 16);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
const instancesPool = [];
|
143
|
-
|
144
|
-
const create = () => {
|
145
|
-
if (instancesPool.length > 0) {
|
146
|
-
const old = instancesPool.pop();
|
147
|
-
old.reset();
|
148
|
-
return old;
|
149
|
-
} else {
|
150
|
-
return new XxHash64(new WebAssembly.Instance(xxhash64));
|
151
|
-
}
|
152
|
-
};
|
153
|
-
|
154
|
-
module.exports = create;
|
20
|
+
module.exports = create.bind(null, xxhash64, [], 32, 16);
|
@@ -6,7 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const SAFE_IDENTIFIER = /^[_a-zA-Z$][_a-zA-Z$0-9]*$/;
|
9
|
-
const
|
9
|
+
const RESERVED_IDENTIFIER = new Set([
|
10
10
|
"break",
|
11
11
|
"case",
|
12
12
|
"catch",
|
@@ -66,7 +66,7 @@ const propertyAccess = (properties, start = 0) => {
|
|
66
66
|
const p = properties[i];
|
67
67
|
if (`${+p}` === p) {
|
68
68
|
str += `[${p}]`;
|
69
|
-
} else if (SAFE_IDENTIFIER.test(p) && !
|
69
|
+
} else if (SAFE_IDENTIFIER.test(p) && !RESERVED_IDENTIFIER.has(p)) {
|
70
70
|
str += `.${p}`;
|
71
71
|
} else {
|
72
72
|
str += `[${JSON.stringify(p)}]`;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.61.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",
|