terser 5.31.5 → 5.31.6
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 +3 -0
- package/dist/bundle.min.js +16 -17
- package/lib/compress/index.js +13 -14
- package/lib/compress/inference.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/bundle.min.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
|
5
|
-
}
|
5
|
+
}(this, (function (exports, sourceMap) { 'use strict';
|
6
6
|
|
7
7
|
/***********************************************************************
|
8
8
|
|
@@ -13836,7 +13836,7 @@ function is_nullish(node, compressor) {
|
|
13836
13836
|
return any(this.definitions, compressor);
|
13837
13837
|
});
|
13838
13838
|
def_has_side_effects(AST_VarDef, function() {
|
13839
|
-
return this.value;
|
13839
|
+
return this.value != null;
|
13840
13840
|
});
|
13841
13841
|
def_has_side_effects(AST_TemplateSegment, return_false);
|
13842
13842
|
def_has_side_effects(AST_TemplateString, function(compressor) {
|
@@ -19588,7 +19588,9 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
19588
19588
|
eliminate_branch(branch, body[body.length - 1]);
|
19589
19589
|
continue;
|
19590
19590
|
}
|
19591
|
-
if (exp instanceof AST_Node
|
19591
|
+
if (exp instanceof AST_Node && !exp.has_side_effects(compressor)) {
|
19592
|
+
exp = branch.expression.tail_node().evaluate(compressor);
|
19593
|
+
}
|
19592
19594
|
if (exp === value) {
|
19593
19595
|
exact_match = branch;
|
19594
19596
|
if (default_branch) {
|
@@ -19770,12 +19772,9 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
19770
19772
|
break DEFAULT;
|
19771
19773
|
}
|
19772
19774
|
|
19773
|
-
let sideEffect = body.find(
|
19774
|
-
|
19775
|
-
|
19776
|
-
&& branch.expression.has_side_effects(compressor)
|
19777
|
-
);
|
19778
|
-
});
|
19775
|
+
let sideEffect = body.find(
|
19776
|
+
branch => branch !== default_or_exact && branch.expression.has_side_effects(compressor)
|
19777
|
+
);
|
19779
19778
|
// If no cases cause a side-effect, we can eliminate the switch entirely.
|
19780
19779
|
if (!sideEffect) {
|
19781
19780
|
return make_node(AST_BlockStatement, self, {
|
@@ -19883,9 +19882,10 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
19883
19882
|
right: branch.expression,
|
19884
19883
|
}),
|
19885
19884
|
body: consequent,
|
19886
|
-
alternative: null
|
19887
|
-
})
|
19888
|
-
|
19885
|
+
alternative: null,
|
19886
|
+
}),
|
19887
|
+
always,
|
19888
|
+
],
|
19889
19889
|
}).optimize(compressor);
|
19890
19890
|
}
|
19891
19891
|
return self;
|
@@ -19908,13 +19908,12 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
19908
19908
|
let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
|
19909
19909
|
return bblock.equivalent_to(pblock);
|
19910
19910
|
}
|
19911
|
-
function statement(
|
19912
|
-
return make_node(AST_SimpleStatement,
|
19913
|
-
body: expression
|
19914
|
-
});
|
19911
|
+
function statement(body) {
|
19912
|
+
return make_node(AST_SimpleStatement, body, { body });
|
19915
19913
|
}
|
19916
19914
|
function has_nested_break(root) {
|
19917
19915
|
let has_break = false;
|
19916
|
+
|
19918
19917
|
let tw = new TreeWalker(node => {
|
19919
19918
|
if (has_break) return true;
|
19920
19919
|
if (node instanceof AST_Lambda) return true;
|
@@ -32547,4 +32546,4 @@ exports._run_cli = run_cli;
|
|
32547
32546
|
exports.minify = minify;
|
32548
32547
|
exports.minify_sync = minify_sync;
|
32549
32548
|
|
32550
|
-
}));
|
32549
|
+
})));
|
package/lib/compress/index.js
CHANGED
@@ -1233,7 +1233,9 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
1233
1233
|
eliminate_branch(branch, body[body.length - 1]);
|
1234
1234
|
continue;
|
1235
1235
|
}
|
1236
|
-
if (exp instanceof AST_Node
|
1236
|
+
if (exp instanceof AST_Node && !exp.has_side_effects(compressor)) {
|
1237
|
+
exp = branch.expression.tail_node().evaluate(compressor);
|
1238
|
+
}
|
1237
1239
|
if (exp === value) {
|
1238
1240
|
exact_match = branch;
|
1239
1241
|
if (default_branch) {
|
@@ -1415,12 +1417,9 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
1415
1417
|
break DEFAULT;
|
1416
1418
|
}
|
1417
1419
|
|
1418
|
-
let sideEffect = body.find(
|
1419
|
-
|
1420
|
-
|
1421
|
-
&& branch.expression.has_side_effects(compressor)
|
1422
|
-
);
|
1423
|
-
});
|
1420
|
+
let sideEffect = body.find(
|
1421
|
+
branch => branch !== default_or_exact && branch.expression.has_side_effects(compressor)
|
1422
|
+
);
|
1424
1423
|
// If no cases cause a side-effect, we can eliminate the switch entirely.
|
1425
1424
|
if (!sideEffect) {
|
1426
1425
|
return make_node(AST_BlockStatement, self, {
|
@@ -1528,9 +1527,10 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
1528
1527
|
right: branch.expression,
|
1529
1528
|
}),
|
1530
1529
|
body: consequent,
|
1531
|
-
alternative: null
|
1532
|
-
})
|
1533
|
-
|
1530
|
+
alternative: null,
|
1531
|
+
}),
|
1532
|
+
always,
|
1533
|
+
],
|
1534
1534
|
}).optimize(compressor);
|
1535
1535
|
}
|
1536
1536
|
return self;
|
@@ -1553,13 +1553,12 @@ def_optimize(AST_Switch, function(self, compressor) {
|
|
1553
1553
|
let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
|
1554
1554
|
return bblock.equivalent_to(pblock);
|
1555
1555
|
}
|
1556
|
-
function statement(
|
1557
|
-
return make_node(AST_SimpleStatement,
|
1558
|
-
body: expression
|
1559
|
-
});
|
1556
|
+
function statement(body) {
|
1557
|
+
return make_node(AST_SimpleStatement, body, { body });
|
1560
1558
|
}
|
1561
1559
|
function has_nested_break(root) {
|
1562
1560
|
let has_break = false;
|
1561
|
+
|
1563
1562
|
let tw = new TreeWalker(node => {
|
1564
1563
|
if (has_break) return true;
|
1565
1564
|
if (node instanceof AST_Lambda) return true;
|
@@ -424,7 +424,7 @@ export function is_nullish(node, compressor) {
|
|
424
424
|
return any(this.definitions, compressor);
|
425
425
|
});
|
426
426
|
def_has_side_effects(AST_VarDef, function() {
|
427
|
-
return this.value;
|
427
|
+
return this.value != null;
|
428
428
|
});
|
429
429
|
def_has_side_effects(AST_TemplateSegment, return_false);
|
430
430
|
def_has_side_effects(AST_TemplateString, function(compressor) {
|