webpack 5.52.0 → 5.55.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 +0 -0
- package/lib/AsyncDependenciesBlock.js +9 -2
- package/lib/CacheFacade.js +10 -3
- package/lib/ChunkGraph.js +19 -8
- package/lib/CodeGenerationResults.js +7 -2
- package/lib/Compilation.js +549 -144
- package/lib/Compiler.js +12 -4
- package/lib/Dependency.js +11 -0
- package/lib/DependencyTemplates.js +8 -2
- package/lib/EvalDevToolModulePlugin.js +2 -1
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/ExternalModule.js +18 -9
- package/lib/FileSystemInfo.js +101 -170
- package/lib/FlagDependencyExportsPlugin.js +25 -16
- package/lib/JavascriptMetaInfoPlugin.js +6 -1
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleFilenameHelpers.js +21 -7
- package/lib/ModuleGraph.js +90 -21
- package/lib/NodeStuffInWebError.js +34 -0
- package/lib/NodeStuffPlugin.js +59 -16
- package/lib/NormalModuleFactory.js +8 -43
- package/lib/SourceMapDevToolPlugin.js +7 -3
- package/lib/WebpackOptionsApply.js +19 -1
- package/lib/cache/PackFileCacheStrategy.js +183 -53
- package/lib/cache/getLazyHashedEtag.js +35 -8
- package/lib/config/defaults.js +32 -12
- package/lib/dependencies/CachedConstDependency.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +19 -9
- package/lib/dependencies/CommonJsFullRequireDependency.js +11 -9
- package/lib/dependencies/ConstDependency.js +12 -4
- package/lib/dependencies/ContextDependency.js +8 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +179 -163
- package/lib/dependencies/HarmonyImportDependency.js +4 -1
- package/lib/dependencies/JsonExportsDependency.js +7 -1
- package/lib/dependencies/ModuleDecoratorDependency.js +5 -2
- package/lib/dependencies/ModuleDependency.js +8 -0
- package/lib/dependencies/NullDependency.js +8 -4
- package/lib/dependencies/ProvidedDependency.js +6 -2
- package/lib/dependencies/PureExpressionDependency.js +5 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +9 -0
- package/lib/ids/IdHelpers.js +21 -8
- package/lib/ids/NamedChunkIdsPlugin.js +3 -0
- package/lib/ids/NamedModuleIdsPlugin.js +3 -1
- package/lib/index.js +6 -0
- package/lib/javascript/BasicEvaluatedExpression.js +3 -0
- package/lib/javascript/JavascriptParser.js +22 -4
- package/lib/javascript/JavascriptParserHelpers.js +0 -2
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +25 -4
- package/lib/optimize/InnerGraph.js +22 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +2 -1
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/serialization/BinaryMiddleware.js +11 -2
- package/lib/serialization/FileMiddleware.js +24 -7
- package/lib/serialization/ObjectMiddleware.js +23 -12
- package/lib/util/WeakTupleMap.js +95 -92
- package/lib/util/createHash.js +10 -0
- package/lib/util/hash/BatchedHash.js +65 -0
- package/lib/util/hash/xxhash64.js +154 -0
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/serialization.js +10 -6
- package/package.json +11 -7
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +19 -3
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.json +20 -2
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.json +4 -2
- package/types.d.ts +211 -25
package/lib/util/WeakTupleMap.js
CHANGED
@@ -7,87 +7,20 @@
|
|
7
7
|
|
8
8
|
const isWeakKey = thing => typeof thing === "object" && thing !== null;
|
9
9
|
|
10
|
-
class WeakTupleNode {
|
11
|
-
constructor() {
|
12
|
-
this.f = 0;
|
13
|
-
/** @type {any} */
|
14
|
-
this.v = undefined;
|
15
|
-
/** @type {Map<object, WeakTupleNode> | undefined} */
|
16
|
-
this.m = undefined;
|
17
|
-
/** @type {WeakMap<object, WeakTupleNode> | undefined} */
|
18
|
-
this.w = undefined;
|
19
|
-
}
|
20
|
-
|
21
|
-
getValue() {
|
22
|
-
return this.v;
|
23
|
-
}
|
24
|
-
|
25
|
-
hasValue() {
|
26
|
-
return (this.f & 1) === 1;
|
27
|
-
}
|
28
|
-
|
29
|
-
setValue(v) {
|
30
|
-
this.f |= 1;
|
31
|
-
this.v = v;
|
32
|
-
}
|
33
|
-
|
34
|
-
deleteValue() {
|
35
|
-
this.f &= 6;
|
36
|
-
this.v = undefined;
|
37
|
-
}
|
38
|
-
|
39
|
-
peek(thing) {
|
40
|
-
if (isWeakKey(thing)) {
|
41
|
-
if ((this.f & 4) !== 4) return undefined;
|
42
|
-
return this.w.get(thing);
|
43
|
-
} else {
|
44
|
-
if ((this.f & 2) !== 2) return undefined;
|
45
|
-
return this.m.get(thing);
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
get(thing) {
|
50
|
-
if (isWeakKey(thing)) {
|
51
|
-
if ((this.f & 4) !== 4) {
|
52
|
-
const newMap = new WeakMap();
|
53
|
-
this.f |= 4;
|
54
|
-
const newNode = new WeakTupleNode();
|
55
|
-
(this.w = newMap).set(thing, newNode);
|
56
|
-
return newNode;
|
57
|
-
}
|
58
|
-
const entry = this.w.get(thing);
|
59
|
-
if (entry !== undefined) {
|
60
|
-
return entry;
|
61
|
-
}
|
62
|
-
const newNode = new WeakTupleNode();
|
63
|
-
this.w.set(thing, newNode);
|
64
|
-
return newNode;
|
65
|
-
} else {
|
66
|
-
if ((this.f & 2) !== 2) {
|
67
|
-
const newMap = new Map();
|
68
|
-
this.f |= 2;
|
69
|
-
const newNode = new WeakTupleNode();
|
70
|
-
(this.m = newMap).set(thing, newNode);
|
71
|
-
return newNode;
|
72
|
-
}
|
73
|
-
const entry = this.m.get(thing);
|
74
|
-
if (entry !== undefined) {
|
75
|
-
return entry;
|
76
|
-
}
|
77
|
-
const newNode = new WeakTupleNode();
|
78
|
-
this.m.set(thing, newNode);
|
79
|
-
return newNode;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
10
|
/**
|
85
11
|
* @template {any[]} T
|
86
12
|
* @template V
|
87
13
|
*/
|
88
14
|
class WeakTupleMap {
|
89
15
|
constructor() {
|
90
|
-
|
16
|
+
/** @private */
|
17
|
+
this.f = 0;
|
18
|
+
/** @private @type {any} */
|
19
|
+
this.v = undefined;
|
20
|
+
/** @private @type {Map<object, WeakTupleMap<T, V>> | undefined} */
|
21
|
+
this.m = undefined;
|
22
|
+
/** @private @type {WeakMap<object, WeakTupleMap<T, V>> | undefined} */
|
23
|
+
this.w = undefined;
|
91
24
|
}
|
92
25
|
|
93
26
|
/**
|
@@ -95,11 +28,12 @@ class WeakTupleMap {
|
|
95
28
|
* @returns {void}
|
96
29
|
*/
|
97
30
|
set(...args) {
|
98
|
-
|
31
|
+
/** @type {WeakTupleMap<T, V>} */
|
32
|
+
let node = this;
|
99
33
|
for (let i = 0; i < args.length - 1; i++) {
|
100
|
-
node = node.
|
34
|
+
node = node._get(args[i]);
|
101
35
|
}
|
102
|
-
node.
|
36
|
+
node._setValue(args[args.length - 1]);
|
103
37
|
}
|
104
38
|
|
105
39
|
/**
|
@@ -107,12 +41,13 @@ class WeakTupleMap {
|
|
107
41
|
* @returns {boolean} true, if the tuple is in the Set
|
108
42
|
*/
|
109
43
|
has(...args) {
|
110
|
-
|
44
|
+
/** @type {WeakTupleMap<T, V>} */
|
45
|
+
let node = this;
|
111
46
|
for (let i = 0; i < args.length; i++) {
|
112
|
-
node = node.
|
47
|
+
node = node._peek(args[i]);
|
113
48
|
if (node === undefined) return false;
|
114
49
|
}
|
115
|
-
return node.
|
50
|
+
return node._hasValue();
|
116
51
|
}
|
117
52
|
|
118
53
|
/**
|
@@ -120,12 +55,13 @@ class WeakTupleMap {
|
|
120
55
|
* @returns {V} the value
|
121
56
|
*/
|
122
57
|
get(...args) {
|
123
|
-
|
58
|
+
/** @type {WeakTupleMap<T, V>} */
|
59
|
+
let node = this;
|
124
60
|
for (let i = 0; i < args.length; i++) {
|
125
|
-
node = node.
|
61
|
+
node = node._peek(args[i]);
|
126
62
|
if (node === undefined) return undefined;
|
127
63
|
}
|
128
|
-
return node.
|
64
|
+
return node._getValue();
|
129
65
|
}
|
130
66
|
|
131
67
|
/**
|
@@ -133,14 +69,15 @@ class WeakTupleMap {
|
|
133
69
|
* @returns {V} the value
|
134
70
|
*/
|
135
71
|
provide(...args) {
|
136
|
-
|
72
|
+
/** @type {WeakTupleMap<T, V>} */
|
73
|
+
let node = this;
|
137
74
|
for (let i = 0; i < args.length - 1; i++) {
|
138
|
-
node = node.
|
75
|
+
node = node._get(args[i]);
|
139
76
|
}
|
140
|
-
if (node.
|
77
|
+
if (node._hasValue()) return node._getValue();
|
141
78
|
const fn = args[args.length - 1];
|
142
79
|
const newValue = fn(...args.slice(0, -1));
|
143
|
-
node.
|
80
|
+
node._setValue(newValue);
|
144
81
|
return newValue;
|
145
82
|
}
|
146
83
|
|
@@ -149,19 +86,85 @@ class WeakTupleMap {
|
|
149
86
|
* @returns {void}
|
150
87
|
*/
|
151
88
|
delete(...args) {
|
152
|
-
|
89
|
+
/** @type {WeakTupleMap<T, V>} */
|
90
|
+
let node = this;
|
153
91
|
for (let i = 0; i < args.length; i++) {
|
154
|
-
node = node.
|
92
|
+
node = node._peek(args[i]);
|
155
93
|
if (node === undefined) return;
|
156
94
|
}
|
157
|
-
node.
|
95
|
+
node._deleteValue();
|
158
96
|
}
|
159
97
|
|
160
98
|
/**
|
161
99
|
* @returns {void}
|
162
100
|
*/
|
163
101
|
clear() {
|
164
|
-
this.
|
102
|
+
this.f = 0;
|
103
|
+
this.v = undefined;
|
104
|
+
this.w = undefined;
|
105
|
+
this.m = undefined;
|
106
|
+
}
|
107
|
+
|
108
|
+
_getValue() {
|
109
|
+
return this.v;
|
110
|
+
}
|
111
|
+
|
112
|
+
_hasValue() {
|
113
|
+
return (this.f & 1) === 1;
|
114
|
+
}
|
115
|
+
|
116
|
+
_setValue(v) {
|
117
|
+
this.f |= 1;
|
118
|
+
this.v = v;
|
119
|
+
}
|
120
|
+
|
121
|
+
_deleteValue() {
|
122
|
+
this.f &= 6;
|
123
|
+
this.v = undefined;
|
124
|
+
}
|
125
|
+
|
126
|
+
_peek(thing) {
|
127
|
+
if (isWeakKey(thing)) {
|
128
|
+
if ((this.f & 4) !== 4) return undefined;
|
129
|
+
return this.w.get(thing);
|
130
|
+
} else {
|
131
|
+
if ((this.f & 2) !== 2) return undefined;
|
132
|
+
return this.m.get(thing);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
_get(thing) {
|
137
|
+
if (isWeakKey(thing)) {
|
138
|
+
if ((this.f & 4) !== 4) {
|
139
|
+
const newMap = new WeakMap();
|
140
|
+
this.f |= 4;
|
141
|
+
const newNode = new WeakTupleMap();
|
142
|
+
(this.w = newMap).set(thing, newNode);
|
143
|
+
return newNode;
|
144
|
+
}
|
145
|
+
const entry = this.w.get(thing);
|
146
|
+
if (entry !== undefined) {
|
147
|
+
return entry;
|
148
|
+
}
|
149
|
+
const newNode = new WeakTupleMap();
|
150
|
+
this.w.set(thing, newNode);
|
151
|
+
return newNode;
|
152
|
+
} else {
|
153
|
+
if ((this.f & 2) !== 2) {
|
154
|
+
const newMap = new Map();
|
155
|
+
this.f |= 2;
|
156
|
+
const newNode = new WeakTupleMap();
|
157
|
+
(this.m = newMap).set(thing, newNode);
|
158
|
+
return newNode;
|
159
|
+
}
|
160
|
+
const entry = this.m.get(thing);
|
161
|
+
if (entry !== undefined) {
|
162
|
+
return entry;
|
163
|
+
}
|
164
|
+
const newNode = new WeakTupleMap();
|
165
|
+
this.m.set(thing, newNode);
|
166
|
+
return newNode;
|
167
|
+
}
|
165
168
|
}
|
166
169
|
}
|
167
170
|
|
package/lib/util/createHash.js
CHANGED
@@ -125,6 +125,8 @@ class DebugHash extends Hash {
|
|
125
125
|
}
|
126
126
|
|
127
127
|
let crypto = undefined;
|
128
|
+
let createXXHash64 = undefined;
|
129
|
+
let BatchedHash = undefined;
|
128
130
|
|
129
131
|
/**
|
130
132
|
* Creates a hash by name or function
|
@@ -139,6 +141,14 @@ module.exports = algorithm => {
|
|
139
141
|
// TODO add non-cryptographic algorithm here
|
140
142
|
case "debug":
|
141
143
|
return new DebugHash();
|
144
|
+
case "xxhash64":
|
145
|
+
if (createXXHash64 === undefined) {
|
146
|
+
createXXHash64 = require("./hash/xxhash64");
|
147
|
+
if (BatchedHash === undefined) {
|
148
|
+
BatchedHash = require("./hash/BatchedHash");
|
149
|
+
}
|
150
|
+
}
|
151
|
+
return new BatchedHash(createXXHash64());
|
142
152
|
default:
|
143
153
|
if (crypto === undefined) crypto = require("crypto");
|
144
154
|
return new BulkUpdateDecorator(
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const Hash = require("../Hash");
|
9
|
+
|
10
|
+
const MAX_STRING_LENGTH = 21845;
|
11
|
+
|
12
|
+
class BatchedHash extends Hash {
|
13
|
+
constructor(hash) {
|
14
|
+
super();
|
15
|
+
this.string = undefined;
|
16
|
+
this.encoding = undefined;
|
17
|
+
this.hash = hash;
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
22
|
+
* @param {string|Buffer} data data
|
23
|
+
* @param {string=} inputEncoding data encoding
|
24
|
+
* @returns {this} updated hash
|
25
|
+
*/
|
26
|
+
update(data, inputEncoding) {
|
27
|
+
if (this.string !== undefined) {
|
28
|
+
if (
|
29
|
+
typeof data === "string" &&
|
30
|
+
inputEncoding === this.encoding &&
|
31
|
+
this.string.length + data.length < MAX_STRING_LENGTH
|
32
|
+
) {
|
33
|
+
this.string += data;
|
34
|
+
return this;
|
35
|
+
}
|
36
|
+
this.hash.update(this.string, this.encoding);
|
37
|
+
this.string = undefined;
|
38
|
+
}
|
39
|
+
if (typeof data === "string") {
|
40
|
+
if (data.length < MAX_STRING_LENGTH) {
|
41
|
+
this.string = data;
|
42
|
+
this.encoding = inputEncoding;
|
43
|
+
} else {
|
44
|
+
this.hash.update(data, inputEncoding);
|
45
|
+
}
|
46
|
+
} else {
|
47
|
+
this.hash.update(data);
|
48
|
+
}
|
49
|
+
return this;
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
54
|
+
* @param {string=} encoding encoding of the return value
|
55
|
+
* @returns {string|Buffer} digest
|
56
|
+
*/
|
57
|
+
digest(encoding) {
|
58
|
+
if (this.string !== undefined) {
|
59
|
+
this.hash.update(this.string, this.encoding);
|
60
|
+
}
|
61
|
+
return this.hash.digest(encoding);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
module.exports = BatchedHash;
|
@@ -0,0 +1,154 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
//#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
|
9
|
+
const xxhash64 = new WebAssembly.Module(
|
10
|
+
Buffer.from(
|
11
|
+
// 1180 bytes
|
12
|
+
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrwIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLsgYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+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+IgIgAkIgiIUiAjcDAEEAIAJCIIgiA0L//wODQiCGIANCgID8/w+DQhCIhCIDQv+BgIDwH4NCEIYgA0KA/oOAgOA/g0IIiIQiA0KPgLyA8IHAB4NCCIYgA0LwgcCHgJ6A+ACDQgSIhCIDQoaMmLDgwIGDBnxCBIhCgYKEiJCgwIABg0InfiADQrDgwIGDhoyYMIR8NwMAQQggAkL/////D4MiAkL//wODQiCGIAJCgID8/w+DQhCIhCICQv+BgIDwH4NCEIYgAkKA/oOAgOA/g0IIiIQiAkKPgLyA8IHAB4NCCIYgAkLwgcCHgJ6A+ACDQgSIhCICQoaMmLDgwIGDBnxCBIhCgYKEiJCgwIABg0InfiACQrDgwIGDhoyYMIR8NwMACw==",
|
13
|
+
"base64"
|
14
|
+
)
|
15
|
+
);
|
16
|
+
//#endregion
|
17
|
+
|
18
|
+
class XxHash64 {
|
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;
|
@@ -189,6 +189,7 @@ module.exports = {
|
|
189
189
|
UnsupportedFeatureWarning: () => require("../UnsupportedFeatureWarning"),
|
190
190
|
"util/LazySet": () => require("../util/LazySet"),
|
191
191
|
UnhandledSchemeError: () => require("../UnhandledSchemeError"),
|
192
|
+
NodeStuffInWebError: () => require("../NodeStuffInWebError"),
|
192
193
|
WebpackError: () => require("../WebpackError"),
|
193
194
|
|
194
195
|
"util/registerExternalSerializer": () => {
|
@@ -89,15 +89,15 @@ module.exports = {
|
|
89
89
|
);
|
90
90
|
};
|
91
91
|
}
|
92
|
-
}),
|
92
|
+
}, "md4"),
|
93
93
|
binaryMiddleware
|
94
94
|
]));
|
95
95
|
},
|
96
|
-
createFileSerializer: fs => {
|
96
|
+
createFileSerializer: (fs, hashFunction) => {
|
97
97
|
registerSerializers();
|
98
98
|
const Serializer = getSerializer();
|
99
99
|
const FileMiddleware = require("../serialization/FileMiddleware");
|
100
|
-
const fileMiddleware = new FileMiddleware(fs);
|
100
|
+
const fileMiddleware = new FileMiddleware(fs, hashFunction);
|
101
101
|
const binaryMiddleware = getBinaryMiddlewareInstance();
|
102
102
|
const SerializerMiddleware = getSerializerMiddleware();
|
103
103
|
const SingleItemMiddleware = getSingleItemMiddleware();
|
@@ -111,12 +111,16 @@ module.exports = {
|
|
111
111
|
);
|
112
112
|
};
|
113
113
|
context.writeSeparate = (value, options) => {
|
114
|
-
|
115
|
-
|
114
|
+
const lazy = SerializerMiddleware.createLazy(
|
115
|
+
value,
|
116
|
+
fileMiddleware,
|
117
|
+
options
|
116
118
|
);
|
119
|
+
context.write(lazy);
|
120
|
+
return lazy;
|
117
121
|
};
|
118
122
|
}
|
119
|
-
}),
|
123
|
+
}, hashFunction),
|
120
124
|
binaryMiddleware,
|
121
125
|
fileMiddleware
|
122
126
|
]);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.55.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",
|
@@ -14,8 +14,8 @@
|
|
14
14
|
"acorn-import-assertions": "^1.7.6",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
17
|
-
"enhanced-resolve": "^5.8.
|
18
|
-
"es-module-lexer": "^0.
|
17
|
+
"enhanced-resolve": "^5.8.3",
|
18
|
+
"es-module-lexer": "^0.9.0",
|
19
19
|
"eslint-scope": "5.1.1",
|
20
20
|
"events": "^3.2.0",
|
21
21
|
"glob-to-regexp": "^0.4.1",
|
@@ -39,8 +39,9 @@
|
|
39
39
|
"@babel/core": "^7.11.1",
|
40
40
|
"@babel/preset-react": "^7.10.4",
|
41
41
|
"@types/es-module-lexer": "^0.4.1",
|
42
|
-
"@types/jest": "^
|
42
|
+
"@types/jest": "^27.0.1",
|
43
43
|
"@types/node": "^15.0.1",
|
44
|
+
"assemblyscript": "^0.19.16",
|
44
45
|
"babel-loader": "^8.1.0",
|
45
46
|
"benchmark": "^2.1.4",
|
46
47
|
"bundle-loader": "^0.5.6",
|
@@ -61,6 +62,7 @@
|
|
61
62
|
"eslint-plugin-prettier": "^4.0.0",
|
62
63
|
"file-loader": "^6.0.0",
|
63
64
|
"fork-ts-checker-webpack-plugin": "^6.0.5",
|
65
|
+
"hash-wasm": "^4.9.0",
|
64
66
|
"husky": "^6.0.0",
|
65
67
|
"is-ci": "^3.0.0",
|
66
68
|
"istanbul": "^0.4.5",
|
@@ -96,7 +98,7 @@
|
|
96
98
|
"style-loader": "^2.0.0",
|
97
99
|
"terser": "^5.7.0",
|
98
100
|
"toml": "^3.0.0",
|
99
|
-
"tooling": "webpack/tooling#v1.
|
101
|
+
"tooling": "webpack/tooling#v1.20.0",
|
100
102
|
"ts-loader": "^8.0.2",
|
101
103
|
"typescript": "^4.2.0-beta",
|
102
104
|
"url-loader": "^4.1.0",
|
@@ -156,8 +158,8 @@
|
|
156
158
|
"type-lint": "tsc",
|
157
159
|
"typings-lint": "tsc -p tsconfig.test.json",
|
158
160
|
"spellcheck": "cspell \"{.github,benchmark,bin,examples,hot,lib,schemas,setup,tooling}/**/*.{md,yml,yaml,js,json}\" \"*.md\"",
|
159
|
-
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
|
160
|
-
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
|
161
|
+
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
|
162
|
+
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
|
161
163
|
"fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
|
162
164
|
"prepare": "husky install",
|
163
165
|
"pretty-lint-base": "prettier \"*.{ts,json,yml,yaml,md}\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.json\" \"examples/*.md\"",
|
@@ -209,6 +211,8 @@
|
|
209
211
|
"<rootDir>/test/fixtures/temp-cache-fixture",
|
210
212
|
"<rootDir>/test/fixtures/temp-",
|
211
213
|
"<rootDir>/benchmark",
|
214
|
+
"<rootDir>/assembly",
|
215
|
+
"<rootDir>/tooling",
|
212
216
|
"<rootDir>/examples/*/dist",
|
213
217
|
"<rootDir>/coverage",
|
214
218
|
"<rootDir>/.eslintcache"
|