terser 5.31.1 → 5.31.3
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/CHANGELOG.md +8 -0
- package/dist/bundle.min.js +16 -8
- package/lib/compress/drop-unused.js +13 -7
- package/lib/output.js +3 -1
- package/package.json +1 -1
- package/tools/domprops.js +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.31.3
|
4
|
+
- drop_unused: drop unused parameters from IIFEs in some more situations.
|
5
|
+
|
6
|
+
## v5.31.2
|
7
|
+
- drop_unused: scan variables in self-referential class declarations that contain side effects.
|
8
|
+
- Don't add parens to arrow function when it's the default for an argument (#1540)
|
9
|
+
- Update domprops (#1538)
|
10
|
+
|
3
11
|
## v5.31.1
|
4
12
|
- Allow drop-unused to drop the whole assignment (not just the assigned name) in more situations, in order to avoid duplication of long strings.
|
5
13
|
|
package/dist/bundle.min.js
CHANGED
@@ -10276,7 +10276,9 @@ function OutputStream(options) {
|
|
10276
10276
|
AST_Arrow.DEFMETHOD("_do_print", function(output) {
|
10277
10277
|
var self = this;
|
10278
10278
|
var parent = output.parent();
|
10279
|
-
var needs_parens = (parent instanceof AST_Binary &&
|
10279
|
+
var needs_parens = (parent instanceof AST_Binary &&
|
10280
|
+
!(parent instanceof AST_Assign) &&
|
10281
|
+
!(parent instanceof AST_DefaultAssign)) ||
|
10280
10282
|
parent instanceof AST_Unary ||
|
10281
10283
|
(parent instanceof AST_Call && self === parent.expression);
|
10282
10284
|
if (needs_parens) { output.print("("); }
|
@@ -15272,7 +15274,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15272
15274
|
}
|
15273
15275
|
var var_defs_by_id = new Map();
|
15274
15276
|
var initializations = new Map();
|
15275
|
-
var self_referential_classes = new Set();
|
15276
15277
|
|
15277
15278
|
// pass 1: find out which symbols are directly used in
|
15278
15279
|
// this scope (not in nested scopes).
|
@@ -15287,8 +15288,11 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15287
15288
|
}
|
15288
15289
|
if (node === self) return;
|
15289
15290
|
if (node instanceof AST_Class && node.has_side_effects(compressor)) {
|
15290
|
-
if (node.is_self_referential())
|
15291
|
-
|
15291
|
+
if (node.is_self_referential()) {
|
15292
|
+
descend();
|
15293
|
+
} else {
|
15294
|
+
node.visit_nondeferred_class_parts(tw);
|
15295
|
+
}
|
15292
15296
|
}
|
15293
15297
|
if (node instanceof AST_Defun || node instanceof AST_DefClass) {
|
15294
15298
|
var node_def = node.name.definition();
|
@@ -15352,9 +15356,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15352
15356
|
init.walk(tw);
|
15353
15357
|
});
|
15354
15358
|
});
|
15355
|
-
self_referential_classes.forEach(function (cls) {
|
15356
|
-
cls.walk(tw);
|
15357
|
-
});
|
15358
15359
|
// pass 3: we should drop declarations not in_use
|
15359
15360
|
var tt = new TreeTransformer(
|
15360
15361
|
function before(node, descend, in_list) {
|
@@ -15390,7 +15391,13 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15390
15391
|
if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
|
15391
15392
|
}
|
15392
15393
|
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
15393
|
-
var trim =
|
15394
|
+
var trim =
|
15395
|
+
!compressor.option("keep_fargs")
|
15396
|
+
// Is this an IIFE that won't refer to its name?
|
15397
|
+
|| parent instanceof AST_Call
|
15398
|
+
&& parent.expression === node
|
15399
|
+
&& !node.pinned()
|
15400
|
+
&& (!node.name || node.name.unreferenced());
|
15394
15401
|
for (var a = node.argnames, i = a.length; --i >= 0;) {
|
15395
15402
|
var sym = a[i];
|
15396
15403
|
if (sym instanceof AST_Expansion) {
|
@@ -30779,6 +30786,7 @@ var domprops = [
|
|
30779
30786
|
"uint32",
|
30780
30787
|
"uint8",
|
30781
30788
|
"uint8Clamped",
|
30789
|
+
"unadjustedMovement",
|
30782
30790
|
"unclippedDepth",
|
30783
30791
|
"unconfigure",
|
30784
30792
|
"undefined",
|
@@ -45,6 +45,7 @@ import {
|
|
45
45
|
AST_Accessor,
|
46
46
|
AST_Assign,
|
47
47
|
AST_BlockStatement,
|
48
|
+
AST_Call,
|
48
49
|
AST_Class,
|
49
50
|
AST_ClassExpression,
|
50
51
|
AST_ClassStaticBlock,
|
@@ -139,7 +140,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
139
140
|
}
|
140
141
|
var var_defs_by_id = new Map();
|
141
142
|
var initializations = new Map();
|
142
|
-
var self_referential_classes = new Set();
|
143
143
|
|
144
144
|
// pass 1: find out which symbols are directly used in
|
145
145
|
// this scope (not in nested scopes).
|
@@ -154,8 +154,11 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
154
154
|
}
|
155
155
|
if (node === self) return;
|
156
156
|
if (node instanceof AST_Class && node.has_side_effects(compressor)) {
|
157
|
-
if (node.is_self_referential())
|
158
|
-
|
157
|
+
if (node.is_self_referential()) {
|
158
|
+
descend();
|
159
|
+
} else {
|
160
|
+
node.visit_nondeferred_class_parts(tw);
|
161
|
+
}
|
159
162
|
}
|
160
163
|
if (node instanceof AST_Defun || node instanceof AST_DefClass) {
|
161
164
|
var node_def = node.name.definition();
|
@@ -219,9 +222,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
219
222
|
init.walk(tw);
|
220
223
|
});
|
221
224
|
});
|
222
|
-
self_referential_classes.forEach(function (cls) {
|
223
|
-
cls.walk(tw);
|
224
|
-
});
|
225
225
|
// pass 3: we should drop declarations not in_use
|
226
226
|
var tt = new TreeTransformer(
|
227
227
|
function before(node, descend, in_list) {
|
@@ -257,7 +257,13 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
257
257
|
if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
|
258
258
|
}
|
259
259
|
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
260
|
-
var trim =
|
260
|
+
var trim =
|
261
|
+
!compressor.option("keep_fargs")
|
262
|
+
// Is this an IIFE that won't refer to its name?
|
263
|
+
|| parent instanceof AST_Call
|
264
|
+
&& parent.expression === node
|
265
|
+
&& !node.pinned()
|
266
|
+
&& (!node.name || node.name.unreferenced());
|
261
267
|
for (var a = node.argnames, i = a.length; --i >= 0;) {
|
262
268
|
var sym = a[i];
|
263
269
|
if (sym instanceof AST_Expansion) {
|
package/lib/output.js
CHANGED
@@ -1501,7 +1501,9 @@ function OutputStream(options) {
|
|
1501
1501
|
AST_Arrow.DEFMETHOD("_do_print", function(output) {
|
1502
1502
|
var self = this;
|
1503
1503
|
var parent = output.parent();
|
1504
|
-
var needs_parens = (parent instanceof AST_Binary &&
|
1504
|
+
var needs_parens = (parent instanceof AST_Binary &&
|
1505
|
+
!(parent instanceof AST_Assign) &&
|
1506
|
+
!(parent instanceof AST_DefaultAssign)) ||
|
1505
1507
|
parent instanceof AST_Unary ||
|
1506
1508
|
(parent instanceof AST_Call && self === parent.expression);
|
1507
1509
|
if (needs_parens) { output.print("("); }
|
package/package.json
CHANGED