webpack 5.78.0 → 5.79.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/lib/CompatibilityPlugin.js +27 -10
- package/lib/Compiler.js +7 -4
- package/lib/DefinePlugin.js +18 -6
- package/lib/LibManifestPlugin.js +2 -1
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +1 -1
- package/lib/css/CssParser.js +6 -6
- package/lib/css/walkCssTokens.js +6 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +28 -3
- package/lib/index.js +5 -0
- package/lib/javascript/JavascriptParser.js +88 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -0
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/webpack.js +1 -1
- package/package.json +41 -36
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +142 -122
@@ -15,7 +15,7 @@ const ConstDependency = require("./dependencies/ConstDependency");
|
|
15
15
|
/** @typedef {import("./Compiler")} Compiler */
|
16
16
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
17
17
|
|
18
|
-
const
|
18
|
+
const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
|
19
19
|
const PLUGIN_NAME = "CompatibilityPlugin";
|
20
20
|
|
21
21
|
class CompatibilityPlugin {
|
@@ -82,14 +82,18 @@ class CompatibilityPlugin {
|
|
82
82
|
statement.id.name === "__webpack_require__"
|
83
83
|
) {
|
84
84
|
const newName = `__nested_webpack_require_${statement.range[0]}__`;
|
85
|
-
parser.tagVariable(
|
86
|
-
name
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
parser.tagVariable(
|
86
|
+
statement.id.name,
|
87
|
+
nestedWebpackIdentifierTag,
|
88
|
+
{
|
89
|
+
name: newName,
|
90
|
+
declaration: {
|
91
|
+
updated: false,
|
92
|
+
loc: statement.id.loc,
|
93
|
+
range: statement.id.range
|
94
|
+
}
|
91
95
|
}
|
92
|
-
|
96
|
+
);
|
93
97
|
return true;
|
94
98
|
}
|
95
99
|
});
|
@@ -97,7 +101,7 @@ class CompatibilityPlugin {
|
|
97
101
|
.for("__webpack_require__")
|
98
102
|
.tap(PLUGIN_NAME, pattern => {
|
99
103
|
const newName = `__nested_webpack_require_${pattern.range[0]}__`;
|
100
|
-
parser.tagVariable(pattern.name,
|
104
|
+
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
|
101
105
|
name: newName,
|
102
106
|
declaration: {
|
103
107
|
updated: false,
|
@@ -107,8 +111,21 @@ class CompatibilityPlugin {
|
|
107
111
|
});
|
108
112
|
return true;
|
109
113
|
});
|
114
|
+
parser.hooks.pattern
|
115
|
+
.for("__webpack_exports__")
|
116
|
+
.tap(PLUGIN_NAME, pattern => {
|
117
|
+
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
|
118
|
+
name: "__nested_webpack_exports__",
|
119
|
+
declaration: {
|
120
|
+
updated: false,
|
121
|
+
loc: pattern.loc,
|
122
|
+
range: pattern.range
|
123
|
+
}
|
124
|
+
});
|
125
|
+
return true;
|
126
|
+
});
|
110
127
|
parser.hooks.expression
|
111
|
-
.for(
|
128
|
+
.for(nestedWebpackIdentifierTag)
|
112
129
|
.tap(PLUGIN_NAME, expr => {
|
113
130
|
const { name, declaration } = parser.currentTagData;
|
114
131
|
if (!declaration.updated) {
|
package/lib/Compiler.js
CHANGED
@@ -970,10 +970,13 @@ ${other}`);
|
|
970
970
|
readRecords(callback) {
|
971
971
|
if (this.hooks.readRecords.isUsed()) {
|
972
972
|
if (this.recordsInputPath) {
|
973
|
-
asyncLib.parallel(
|
974
|
-
|
975
|
-
|
976
|
-
|
973
|
+
asyncLib.parallel(
|
974
|
+
[
|
975
|
+
cb => this.hooks.readRecords.callAsync(cb),
|
976
|
+
this._readRecords.bind(this)
|
977
|
+
],
|
978
|
+
err => callback(err)
|
979
|
+
);
|
977
980
|
} else {
|
978
981
|
this.records = {};
|
979
982
|
this.hooks.readRecords.callAsync(callback);
|
package/lib/DefinePlugin.js
CHANGED
@@ -118,6 +118,7 @@ class RuntimeValue {
|
|
118
118
|
* @param {string} key the defined key
|
119
119
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
120
120
|
* @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
121
|
+
* @param {Set<string>|undefined=} objKeys used keys
|
121
122
|
* @returns {string} code converted to string that evaluates
|
122
123
|
*/
|
123
124
|
const stringifyObj = (
|
@@ -126,7 +127,8 @@ const stringifyObj = (
|
|
126
127
|
valueCacheVersions,
|
127
128
|
key,
|
128
129
|
runtimeTemplate,
|
129
|
-
asiSafe
|
130
|
+
asiSafe,
|
131
|
+
objKeys
|
130
132
|
) => {
|
131
133
|
let code;
|
132
134
|
let arr = Array.isArray(obj);
|
@@ -137,7 +139,12 @@ const stringifyObj = (
|
|
137
139
|
)
|
138
140
|
.join(",")}]`;
|
139
141
|
} else {
|
140
|
-
|
142
|
+
let keys = Object.keys(obj);
|
143
|
+
if (objKeys) {
|
144
|
+
if (objKeys.size === 0) keys = [];
|
145
|
+
else keys = keys.filter(k => objKeys.has(k));
|
146
|
+
}
|
147
|
+
code = `{${keys
|
141
148
|
.map(key => {
|
142
149
|
const code = obj[key];
|
143
150
|
return (
|
@@ -169,6 +176,7 @@ const stringifyObj = (
|
|
169
176
|
* @param {string} key the defined key
|
170
177
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
171
178
|
* @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
179
|
+
* @param {Set<string>|undefined=} objKeys used keys
|
172
180
|
* @returns {string} code converted to string that evaluates
|
173
181
|
*/
|
174
182
|
const toCode = (
|
@@ -177,7 +185,8 @@ const toCode = (
|
|
177
185
|
valueCacheVersions,
|
178
186
|
key,
|
179
187
|
runtimeTemplate,
|
180
|
-
asiSafe
|
188
|
+
asiSafe,
|
189
|
+
objKeys
|
181
190
|
) => {
|
182
191
|
if (code === null) {
|
183
192
|
return "null";
|
@@ -211,7 +220,8 @@ const toCode = (
|
|
211
220
|
valueCacheVersions,
|
212
221
|
key,
|
213
222
|
runtimeTemplate,
|
214
|
-
asiSafe
|
223
|
+
asiSafe,
|
224
|
+
objKeys
|
215
225
|
);
|
216
226
|
}
|
217
227
|
if (typeof code === "bigint") {
|
@@ -426,7 +436,8 @@ class DefinePlugin {
|
|
426
436
|
compilation.valueCacheVersions,
|
427
437
|
originalKey,
|
428
438
|
runtimeTemplate,
|
429
|
-
!parser.isAsiPosition(expr.range[0])
|
439
|
+
!parser.isAsiPosition(expr.range[0]),
|
440
|
+
parser.destructuringAssignmentPropertiesFor(expr)
|
430
441
|
);
|
431
442
|
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
|
432
443
|
return toConstantDependency(parser, strCode, [
|
@@ -523,7 +534,8 @@ class DefinePlugin {
|
|
523
534
|
compilation.valueCacheVersions,
|
524
535
|
key,
|
525
536
|
runtimeTemplate,
|
526
|
-
!parser.isAsiPosition(expr.range[0])
|
537
|
+
!parser.isAsiPosition(expr.range[0]),
|
538
|
+
parser.destructuringAssignmentPropertiesFor(expr)
|
527
539
|
);
|
528
540
|
|
529
541
|
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
|
package/lib/LibManifestPlugin.js
CHANGED
@@ -49,7 +49,8 @@ class LibManifestPlugin {
|
|
49
49
|
const name =
|
50
50
|
this.options.name &&
|
51
51
|
compilation.getPath(this.options.name, {
|
52
|
-
chunk
|
52
|
+
chunk,
|
53
|
+
contentHashType: "javascript"
|
53
54
|
});
|
54
55
|
const content = Object.create(null);
|
55
56
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
@@ -8,7 +8,7 @@
|
|
8
8
|
const { join, dirname } = require("./util/fs");
|
9
9
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
|
-
/** @typedef {function(
|
11
|
+
/** @typedef {function(import("./NormalModuleFactory").ResolveData): void} ModuleReplacer */
|
12
12
|
|
13
13
|
class NormalModuleReplacementPlugin {
|
14
14
|
/**
|
@@ -111,7 +111,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
111
111
|
? crossOriginLoading === "use-credentials"
|
112
112
|
? 'link.crossOrigin = "use-credentials";'
|
113
113
|
: Template.asString([
|
114
|
-
"if (link.
|
114
|
+
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
|
115
115
|
Template.indent(
|
116
116
|
`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
117
117
|
),
|
package/lib/css/CssParser.js
CHANGED
@@ -279,8 +279,8 @@ class CssParser extends Parser {
|
|
279
279
|
module.addDependency(dep);
|
280
280
|
declaredCssVariables.add(name);
|
281
281
|
} else if (
|
282
|
-
propertyName === "animation-name" ||
|
283
|
-
propertyName === "animation"
|
282
|
+
propertyName.toLowerCase() === "animation-name" ||
|
283
|
+
propertyName.toLowerCase() === "animation"
|
284
284
|
) {
|
285
285
|
modeData = "animation";
|
286
286
|
lastIdentifier = undefined;
|
@@ -343,7 +343,7 @@ class CssParser extends Parser {
|
|
343
343
|
return end;
|
344
344
|
},
|
345
345
|
atKeyword: (input, start, end) => {
|
346
|
-
const name = input.slice(start, end);
|
346
|
+
const name = input.slice(start, end).toLowerCase();
|
347
347
|
if (name === "@namespace") {
|
348
348
|
throw new Error("@namespace is not supported in bundled CSS");
|
349
349
|
}
|
@@ -543,7 +543,7 @@ class CssParser extends Parser {
|
|
543
543
|
singleClassSelector = false;
|
544
544
|
switch (mode) {
|
545
545
|
case CSS_MODE_TOP_LEVEL: {
|
546
|
-
const name = input.slice(start, end);
|
546
|
+
const name = input.slice(start, end).toLowerCase();
|
547
547
|
if (this.allowModeSwitch && name === ":global") {
|
548
548
|
modeData = "global";
|
549
549
|
const dep = new ConstDependency("", [start, end]);
|
@@ -566,7 +566,7 @@ class CssParser extends Parser {
|
|
566
566
|
pseudoFunction: (input, start, end) => {
|
567
567
|
switch (mode) {
|
568
568
|
case CSS_MODE_TOP_LEVEL: {
|
569
|
-
const name = input.slice(start, end - 1);
|
569
|
+
const name = input.slice(start, end - 1).toLowerCase();
|
570
570
|
if (this.allowModeSwitch && name === ":global") {
|
571
571
|
modeStack.push(modeData);
|
572
572
|
modeData = "global";
|
@@ -589,7 +589,7 @@ class CssParser extends Parser {
|
|
589
589
|
function: (input, start, end) => {
|
590
590
|
switch (mode) {
|
591
591
|
case CSS_MODE_IN_LOCAL_RULE: {
|
592
|
-
const name = input.slice(start, end - 1);
|
592
|
+
const name = input.slice(start, end - 1).toLowerCase();
|
593
593
|
if (name === "var") {
|
594
594
|
let pos = walkCssTokens.eatWhitespaceAndComments(input, end);
|
595
595
|
if (pos === input.length) return pos;
|
package/lib/css/walkCssTokens.js
CHANGED
@@ -62,6 +62,7 @@ const CC_LOWER_E = "e".charCodeAt(0);
|
|
62
62
|
const CC_LOWER_Z = "z".charCodeAt(0);
|
63
63
|
const CC_UPPER_A = "A".charCodeAt(0);
|
64
64
|
const CC_UPPER_E = "E".charCodeAt(0);
|
65
|
+
const CC_UPPER_U = "U".charCodeAt(0);
|
65
66
|
const CC_UPPER_Z = "Z".charCodeAt(0);
|
66
67
|
const CC_0 = "0".charCodeAt(0);
|
67
68
|
const CC_9 = "9".charCodeAt(0);
|
@@ -288,7 +289,10 @@ const consumeOtherIdentifier = (input, pos, callbacks) => {
|
|
288
289
|
const consumePotentialUrl = (input, pos, callbacks) => {
|
289
290
|
const start = pos;
|
290
291
|
pos = _consumeIdentifier(input, pos);
|
291
|
-
if (
|
292
|
+
if (
|
293
|
+
pos === start + 3 &&
|
294
|
+
input.slice(start, pos + 1).toLowerCase() === "url("
|
295
|
+
) {
|
292
296
|
pos++;
|
293
297
|
let cc = input.charCodeAt(pos);
|
294
298
|
while (_isWhiteSpace(cc)) {
|
@@ -569,6 +573,7 @@ const CHAR_MAP = Array.from({ length: 0x80 }, (_, cc) => {
|
|
569
573
|
case CC_AT_SIGN:
|
570
574
|
return consumeAt;
|
571
575
|
case CC_LOWER_U:
|
576
|
+
case CC_UPPER_U:
|
572
577
|
return consumePotentialUrl;
|
573
578
|
case CC_LOW_LINE:
|
574
579
|
return consumeOtherIdentifier;
|
@@ -196,6 +196,8 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
196
196
|
exportPresenceMode,
|
197
197
|
settings.assertions
|
198
198
|
);
|
199
|
+
dep.referencedPropertiesInDestructuring =
|
200
|
+
parser.destructuringAssignmentPropertiesFor(expr);
|
199
201
|
dep.shorthand = parser.scope.inShorthand;
|
200
202
|
dep.directImport = true;
|
201
203
|
dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
|
@@ -233,6 +235,8 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
233
235
|
exportPresenceMode,
|
234
236
|
settings.assertions
|
235
237
|
);
|
238
|
+
dep.referencedPropertiesInDestructuring =
|
239
|
+
parser.destructuringAssignmentPropertiesFor(expr);
|
236
240
|
dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
|
237
241
|
dep.loc = expr.loc;
|
238
242
|
parser.state.module.addDependency(dep);
|
@@ -52,6 +52,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
52
52
|
this.asiSafe = undefined;
|
53
53
|
/** @type {Set<string> | boolean} */
|
54
54
|
this.usedByExports = undefined;
|
55
|
+
/** @type {Set<string>} */
|
56
|
+
this.referencedPropertiesInDestructuring = undefined;
|
55
57
|
}
|
56
58
|
|
57
59
|
// TODO webpack 6 remove
|
@@ -121,7 +123,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
121
123
|
*/
|
122
124
|
getReferencedExports(moduleGraph, runtime) {
|
123
125
|
let ids = this.getIds(moduleGraph);
|
124
|
-
if (ids.length === 0) return
|
126
|
+
if (ids.length === 0) return this._getReferencedExportsInDestructuring();
|
125
127
|
let namespaceObjectAsContext = this.namespaceObjectAsContext;
|
126
128
|
if (ids[0] === "default") {
|
127
129
|
const selfModule = moduleGraph.getParentModule(this);
|
@@ -134,7 +136,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
134
136
|
) {
|
135
137
|
case "default-only":
|
136
138
|
case "default-with-named":
|
137
|
-
if (ids.length === 1)
|
139
|
+
if (ids.length === 1)
|
140
|
+
return this._getReferencedExportsInDestructuring();
|
138
141
|
ids = ids.slice(1);
|
139
142
|
namespaceObjectAsContext = true;
|
140
143
|
break;
|
@@ -152,7 +155,27 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
152
155
|
ids = ids.slice(0, -1);
|
153
156
|
}
|
154
157
|
|
155
|
-
return
|
158
|
+
return this._getReferencedExportsInDestructuring(ids);
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* @param {string[]=} ids ids
|
163
|
+
* @returns {(string[] | ReferencedExport)[]} referenced exports
|
164
|
+
*/
|
165
|
+
_getReferencedExportsInDestructuring(ids) {
|
166
|
+
if (this.referencedPropertiesInDestructuring) {
|
167
|
+
/** @type {ReferencedExport[]} */
|
168
|
+
const refs = [];
|
169
|
+
for (const key of this.referencedPropertiesInDestructuring) {
|
170
|
+
refs.push({
|
171
|
+
name: ids ? ids.concat([key]) : [key],
|
172
|
+
canMangle: false
|
173
|
+
});
|
174
|
+
}
|
175
|
+
return refs;
|
176
|
+
} else {
|
177
|
+
return ids ? [ids] : Dependency.EXPORTS_OBJECT_REFERENCED;
|
178
|
+
}
|
156
179
|
}
|
157
180
|
|
158
181
|
/**
|
@@ -226,6 +249,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
226
249
|
write(this.shorthand);
|
227
250
|
write(this.asiSafe);
|
228
251
|
write(this.usedByExports);
|
252
|
+
write(this.referencedPropertiesInDestructuring);
|
229
253
|
super.serialize(context);
|
230
254
|
}
|
231
255
|
|
@@ -241,6 +265,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
241
265
|
this.shorthand = read();
|
242
266
|
this.asiSafe = read();
|
243
267
|
this.usedByExports = read();
|
268
|
+
this.referencedPropertiesInDestructuring = read();
|
244
269
|
super.deserialize(context);
|
245
270
|
}
|
246
271
|
}
|
package/lib/index.js
CHANGED
@@ -11,6 +11,11 @@ const memoize = require("./util/memoize");
|
|
11
11
|
/** @typedef {import("../declarations/WebpackOptions").Entry} Entry */
|
12
12
|
/** @typedef {import("../declarations/WebpackOptions").EntryNormalized} EntryNormalized */
|
13
13
|
/** @typedef {import("../declarations/WebpackOptions").EntryObject} EntryObject */
|
14
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionData} ExternalItemFunctionData */
|
15
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
16
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
17
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */
|
18
|
+
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
14
19
|
/** @typedef {import("../declarations/WebpackOptions").FileCacheOptions} FileCacheOptions */
|
15
20
|
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
16
21
|
/** @typedef {import("../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
|
@@ -331,6 +331,8 @@ class JavascriptParser extends Parser {
|
|
331
331
|
/** @type {(StatementNode|ExpressionNode)[]} */
|
332
332
|
this.statementPath = undefined;
|
333
333
|
this.prevStatement = undefined;
|
334
|
+
/** @type {WeakMap<ExpressionNode, Set<string>>} */
|
335
|
+
this.destructuringAssignmentProperties = undefined;
|
334
336
|
this.currentTagData = undefined;
|
335
337
|
this._initializeEvaluating();
|
336
338
|
}
|
@@ -1411,6 +1413,15 @@ class JavascriptParser extends Parser {
|
|
1411
1413
|
});
|
1412
1414
|
}
|
1413
1415
|
|
1416
|
+
/**
|
1417
|
+
* @param {ExpressionNode} node node
|
1418
|
+
* @returns {Set<string>|undefined} destructured identifiers
|
1419
|
+
*/
|
1420
|
+
destructuringAssignmentPropertiesFor(node) {
|
1421
|
+
if (!this.destructuringAssignmentProperties) return undefined;
|
1422
|
+
return this.destructuringAssignmentProperties.get(node);
|
1423
|
+
}
|
1424
|
+
|
1414
1425
|
getRenameIdentifier(expr) {
|
1415
1426
|
const result = this.evaluateExpression(expr);
|
1416
1427
|
if (result.isIdentifier()) {
|
@@ -1557,6 +1568,8 @@ class JavascriptParser extends Parser {
|
|
1557
1568
|
case "ClassDeclaration":
|
1558
1569
|
this.blockPreWalkClassDeclaration(statement);
|
1559
1570
|
break;
|
1571
|
+
case "ExpressionStatement":
|
1572
|
+
this.blockPreWalkExpressionStatement(statement);
|
1560
1573
|
}
|
1561
1574
|
this.prevStatement = this.statementPath.pop();
|
1562
1575
|
}
|
@@ -1890,6 +1903,37 @@ class JavascriptParser extends Parser {
|
|
1890
1903
|
this.scope.topLevelScope = wasTopLevel;
|
1891
1904
|
}
|
1892
1905
|
|
1906
|
+
blockPreWalkExpressionStatement(statement) {
|
1907
|
+
const expression = statement.expression;
|
1908
|
+
switch (expression.type) {
|
1909
|
+
case "AssignmentExpression":
|
1910
|
+
this.preWalkAssignmentExpression(expression);
|
1911
|
+
}
|
1912
|
+
}
|
1913
|
+
|
1914
|
+
preWalkAssignmentExpression(expression) {
|
1915
|
+
if (
|
1916
|
+
expression.left.type !== "ObjectPattern" ||
|
1917
|
+
!this.destructuringAssignmentProperties
|
1918
|
+
)
|
1919
|
+
return;
|
1920
|
+
const keys = this._preWalkObjectPattern(expression.left);
|
1921
|
+
if (!keys) return;
|
1922
|
+
|
1923
|
+
// check multiple assignments
|
1924
|
+
if (this.destructuringAssignmentProperties.has(expression)) {
|
1925
|
+
const set = this.destructuringAssignmentProperties.get(expression);
|
1926
|
+
this.destructuringAssignmentProperties.delete(expression);
|
1927
|
+
for (const id of set) keys.add(id);
|
1928
|
+
}
|
1929
|
+
|
1930
|
+
this.destructuringAssignmentProperties.set(expression.right, keys);
|
1931
|
+
|
1932
|
+
if (expression.right.type === "AssignmentExpression") {
|
1933
|
+
this.preWalkAssignmentExpression(expression.right);
|
1934
|
+
}
|
1935
|
+
}
|
1936
|
+
|
1893
1937
|
blockPreWalkImportDeclaration(statement) {
|
1894
1938
|
const source = statement.source.value;
|
1895
1939
|
this.hooks.import.call(statement, source);
|
@@ -2087,6 +2131,7 @@ class JavascriptParser extends Parser {
|
|
2087
2131
|
for (const declarator of statement.declarations) {
|
2088
2132
|
switch (declarator.type) {
|
2089
2133
|
case "VariableDeclarator": {
|
2134
|
+
this.preWalkVariableDeclarator(declarator);
|
2090
2135
|
if (!this.hooks.preDeclarator.call(declarator, statement)) {
|
2091
2136
|
this.enterPattern(declarator.id, (name, decl) => {
|
2092
2137
|
let hook = hookMap.get(name);
|
@@ -2104,6 +2149,47 @@ class JavascriptParser extends Parser {
|
|
2104
2149
|
}
|
2105
2150
|
}
|
2106
2151
|
|
2152
|
+
_preWalkObjectPattern(objectPattern) {
|
2153
|
+
const ids = new Set();
|
2154
|
+
const properties = objectPattern.properties;
|
2155
|
+
for (let i = 0; i < properties.length; i++) {
|
2156
|
+
const property = properties[i];
|
2157
|
+
if (property.type !== "Property") return;
|
2158
|
+
const key = property.key;
|
2159
|
+
if (key.type === "Identifier") {
|
2160
|
+
ids.add(key.name);
|
2161
|
+
} else {
|
2162
|
+
const id = this.evaluateExpression(key);
|
2163
|
+
const str = id.asString();
|
2164
|
+
if (str) {
|
2165
|
+
ids.add(str);
|
2166
|
+
} else {
|
2167
|
+
// could not evaluate key
|
2168
|
+
return;
|
2169
|
+
}
|
2170
|
+
}
|
2171
|
+
}
|
2172
|
+
|
2173
|
+
return ids;
|
2174
|
+
}
|
2175
|
+
|
2176
|
+
preWalkVariableDeclarator(declarator) {
|
2177
|
+
if (
|
2178
|
+
!declarator.init ||
|
2179
|
+
declarator.id.type !== "ObjectPattern" ||
|
2180
|
+
!this.destructuringAssignmentProperties
|
2181
|
+
)
|
2182
|
+
return;
|
2183
|
+
const keys = this._preWalkObjectPattern(declarator.id);
|
2184
|
+
|
2185
|
+
if (!keys) return;
|
2186
|
+
this.destructuringAssignmentProperties.set(declarator.init, keys);
|
2187
|
+
|
2188
|
+
if (declarator.init.type === "AssignmentExpression") {
|
2189
|
+
this.preWalkAssignmentExpression(declarator.init);
|
2190
|
+
}
|
2191
|
+
}
|
2192
|
+
|
2107
2193
|
walkVariableDeclaration(statement) {
|
2108
2194
|
for (const declarator of statement.declarations) {
|
2109
2195
|
switch (declarator.type) {
|
@@ -3367,12 +3453,14 @@ class JavascriptParser extends Parser {
|
|
3367
3453
|
this.statementPath = [];
|
3368
3454
|
this.prevStatement = undefined;
|
3369
3455
|
if (this.hooks.program.call(ast, comments) === undefined) {
|
3456
|
+
this.destructuringAssignmentProperties = new WeakMap();
|
3370
3457
|
this.detectMode(ast.body);
|
3371
3458
|
this.preWalkStatements(ast.body);
|
3372
3459
|
this.prevStatement = undefined;
|
3373
3460
|
this.blockPreWalkStatements(ast.body);
|
3374
3461
|
this.prevStatement = undefined;
|
3375
3462
|
this.walkStatements(ast.body);
|
3463
|
+
this.destructuringAssignmentProperties = undefined;
|
3376
3464
|
}
|
3377
3465
|
this.hooks.finish.call(ast, comments);
|
3378
3466
|
this.scope = oldScope;
|
@@ -10,6 +10,7 @@
|
|
10
10
|
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
11
11
|
|
12
12
|
const DATA_URI_CONTENT_LENGTH = 16;
|
13
|
+
const MAX_MODULE_IDENTIFIER_LENGTH = 80;
|
13
14
|
|
14
15
|
const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
15
16
|
|
@@ -42,6 +43,19 @@ const getResourceName = resource => {
|
|
42
43
|
|
43
44
|
const getModuleName = name => {
|
44
45
|
const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
|
46
|
+
|
47
|
+
if (resource.length > MAX_MODULE_IDENTIFIER_LENGTH) {
|
48
|
+
const truncatedResource = `${resource.slice(
|
49
|
+
0,
|
50
|
+
Math.min(
|
51
|
+
resource.length - /* '...(truncated)'.length */ 14,
|
52
|
+
MAX_MODULE_IDENTIFIER_LENGTH
|
53
|
+
)
|
54
|
+
)}...(truncated)`;
|
55
|
+
|
56
|
+
return [prefix, getResourceName(truncatedResource)];
|
57
|
+
}
|
58
|
+
|
45
59
|
return [prefix, getResourceName(resource)];
|
46
60
|
};
|
47
61
|
|
package/lib/util/hash/md4.js
CHANGED
@@ -10,8 +10,8 @@ const create = require("./wasm-hash");
|
|
10
10
|
//#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
11
11
|
const md4 = new WebAssembly.Module(
|
12
12
|
Buffer.from(
|
13
|
-
//
|
14
|
-
"AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/
|
13
|
+
// 2154 bytes
|
14
|
+
"AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqJEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvQCgEZfyMBIQUjAiECIwMhAyMEIQQDQCAAIAFLBEAgASgCBCIOIAQgAyABKAIAIg8gBSAEIAIgAyAEc3FzampBA3ciCCACIANzcXNqakEHdyEJIAEoAgwiBiACIAggASgCCCIQIAMgAiAJIAIgCHNxc2pqQQt3IgogCCAJc3FzampBE3chCyAB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4NCEIaEIgRC/4GAgPAfgyAEQoD+g4CA4D+DQgiGhCIEQo+AvIDwgcAHg0IIhiAEQvCBwIeAnoD4AINCBIiEIgRChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IARCsODAgYOGjJgwhHw3AwBBGCMErSIEQv//A4MgBEKAgPz/D4NCEIaEIgRC/4GAgPAfgyAEQoD+g4CA4D+DQgiGhCIEQo+AvIDwgcAHg0IIhiAEQvCBwIeAnoD4AINCBIiEIgRChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IARCsODAgYOGjJgwhHw3AwAL",
|
15
15
|
"base64"
|
16
16
|
)
|
17
17
|
);
|
@@ -11,7 +11,7 @@ const create = require("./wasm-hash");
|
|
11
11
|
const xxhash64 = new WebAssembly.Module(
|
12
12
|
Buffer.from(
|
13
13
|
// 1170 bytes
|
14
|
-
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrIIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/
|
14
|
+
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrIIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJo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vCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
|
15
15
|
"base64"
|
16
16
|
)
|
17
17
|
);
|
package/lib/webpack.js
CHANGED
@@ -103,7 +103,7 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
|
103
103
|
/**
|
104
104
|
* @param {WebpackOptions | (ReadonlyArray<WebpackOptions> & MultiCompilerOptions)} options options
|
105
105
|
* @param {Callback<Stats> & Callback<MultiStats>=} callback callback
|
106
|
-
* @returns {Compiler | MultiCompiler}
|
106
|
+
* @returns {Compiler | MultiCompiler} Compiler or MultiCompiler
|
107
107
|
*/
|
108
108
|
(options, callback) => {
|
109
109
|
const create = () => {
|