terser 5.24.0 → 5.26.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.
- package/CHANGELOG.md +9 -0
- package/README.md +3 -0
- package/dist/bundle.min.js +30 -10
- package/lib/compress/index.js +1 -0
- package/lib/compress/inference.js +7 -1
- package/lib/output.js +8 -1
- package/lib/parse.js +12 -8
- package/package.json +1 -1
- package/tools/domprops.js +2 -0
- package/tools/terser.d.ts +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.26.0
|
4
|
+
- Do not take the `/*#__PURE__*/` annotation into account when the `side_effects` compress option is off.
|
5
|
+
- The `preserve_annotations` option now automatically opts annotation comments in, instead of requiring the `comments` option to be configured for this.
|
6
|
+
- Refuse to parse empty parenthesized expressions (`()`)
|
7
|
+
|
8
|
+
## v5.25.0
|
9
|
+
- Regex properties added to reserved property mangler (#1471)
|
10
|
+
- `pure_new` option added to drop unused `new` expressions.
|
11
|
+
|
3
12
|
## v5.24.0
|
4
13
|
- Improve formatting performance in V8 by keeping a small work string and a large output string
|
5
14
|
|
package/README.md
CHANGED
@@ -820,6 +820,9 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
820
820
|
Specify `"strict"` to treat `foo.bar` as side-effect-free only when
|
821
821
|
`foo` is certain to not throw, i.e. not `null` or `undefined`.
|
822
822
|
|
823
|
+
- `pure_new` (default: `false`) -- Set to `true` to assume `new X()` never has
|
824
|
+
side effects.
|
825
|
+
|
823
826
|
- `reduce_vars` (default: `true`) -- Improve optimization on variables assigned with and
|
824
827
|
used as constant values.
|
825
828
|
|
package/dist/bundle.min.js
CHANGED
@@ -2475,9 +2475,7 @@ function parse($TEXT, options) {
|
|
2475
2475
|
var ex = async ? new AST_Call({
|
2476
2476
|
expression: async,
|
2477
2477
|
args: exprs
|
2478
|
-
}) :
|
2479
|
-
expressions: exprs
|
2480
|
-
});
|
2478
|
+
}) : to_expr_or_sequence(start, exprs);
|
2481
2479
|
if (ex.start) {
|
2482
2480
|
const outer_comments_before = start.comments_before.length;
|
2483
2481
|
outer_comments_before_counts.set(start, outer_comments_before);
|
@@ -3574,6 +3572,16 @@ function parse($TEXT, options) {
|
|
3574
3572
|
return left;
|
3575
3573
|
};
|
3576
3574
|
|
3575
|
+
var to_expr_or_sequence = function(start, exprs) {
|
3576
|
+
if (exprs.length === 1) {
|
3577
|
+
return exprs[0];
|
3578
|
+
} else if (exprs.length > 1) {
|
3579
|
+
return new AST_Sequence({ start, expressions: exprs, end: peek() });
|
3580
|
+
} else {
|
3581
|
+
croak("Invalid parenthesized expression");
|
3582
|
+
}
|
3583
|
+
};
|
3584
|
+
|
3577
3585
|
var expression = function(commas, no_in) {
|
3578
3586
|
var start = S.token;
|
3579
3587
|
var exprs = [];
|
@@ -3583,11 +3591,7 @@ function parse($TEXT, options) {
|
|
3583
3591
|
next();
|
3584
3592
|
commas = true;
|
3585
3593
|
}
|
3586
|
-
return
|
3587
|
-
start : start,
|
3588
|
-
expressions : exprs,
|
3589
|
-
end : peek()
|
3590
|
-
});
|
3594
|
+
return to_expr_or_sequence(start, exprs);
|
3591
3595
|
};
|
3592
3596
|
|
3593
3597
|
function in_loop(cont) {
|
@@ -8931,7 +8935,7 @@ function left_is_object(node) {
|
|
8931
8935
|
const CODE_LINE_BREAK = 10;
|
8932
8936
|
const CODE_SPACE = 32;
|
8933
8937
|
|
8934
|
-
const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__
|
8938
|
+
const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/;
|
8935
8939
|
|
8936
8940
|
function is_some_comments(comment) {
|
8937
8941
|
// multiline comment
|
@@ -9083,6 +9087,13 @@ function OutputStream(options) {
|
|
9083
9087
|
}
|
9084
9088
|
}
|
9085
9089
|
|
9090
|
+
if (options.preserve_annotations) {
|
9091
|
+
let prev_comment_filter = comment_filter;
|
9092
|
+
comment_filter = function (comment) {
|
9093
|
+
return r_annotation.test(comment.value) || prev_comment_filter.apply(this, arguments);
|
9094
|
+
};
|
9095
|
+
}
|
9096
|
+
|
9086
9097
|
var indentation = 0;
|
9087
9098
|
var current_col = 0;
|
9088
9099
|
var current_line = 1;
|
@@ -14170,7 +14181,13 @@ AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
|
|
14170
14181
|
return true;
|
14171
14182
|
}
|
14172
14183
|
}
|
14173
|
-
|
14184
|
+
if ((this instanceof AST_New) && compressor.option("pure_new")) {
|
14185
|
+
return true;
|
14186
|
+
}
|
14187
|
+
if (compressor.option("side_effects") && has_annotation(this, _PURE)) {
|
14188
|
+
return true;
|
14189
|
+
}
|
14190
|
+
return !compressor.pure_funcs(this);
|
14174
14191
|
});
|
14175
14192
|
|
14176
14193
|
// If I call this, is it a pure function?
|
@@ -18390,6 +18407,7 @@ class Compressor extends TreeWalker {
|
|
18390
18407
|
properties : !false_by_default,
|
18391
18408
|
pure_getters : !false_by_default && "strict",
|
18392
18409
|
pure_funcs : null,
|
18410
|
+
pure_new : false,
|
18393
18411
|
reduce_funcs : !false_by_default,
|
18394
18412
|
reduce_vars : !false_by_default,
|
18395
18413
|
sequences : !false_by_default,
|
@@ -26841,6 +26859,7 @@ var domprops = [
|
|
26841
26859
|
"gridTemplateRows",
|
26842
26860
|
"gripSpace",
|
26843
26861
|
"group",
|
26862
|
+
"groups",
|
26844
26863
|
"groupCollapsed",
|
26845
26864
|
"groupEnd",
|
26846
26865
|
"groupId",
|
@@ -26948,6 +26967,7 @@ var domprops = [
|
|
26948
26967
|
"indexOf",
|
26949
26968
|
"indexedDB",
|
26950
26969
|
"indicate",
|
26970
|
+
"indices",
|
26951
26971
|
"inert",
|
26952
26972
|
"inertiaDestinationX",
|
26953
26973
|
"inertiaDestinationY",
|
package/lib/compress/index.js
CHANGED
@@ -251,6 +251,7 @@ class Compressor extends TreeWalker {
|
|
251
251
|
properties : !false_by_default,
|
252
252
|
pure_getters : !false_by_default && "strict",
|
253
253
|
pure_funcs : null,
|
254
|
+
pure_new : false,
|
254
255
|
reduce_funcs : !false_by_default,
|
255
256
|
reduce_vars : !false_by_default,
|
256
257
|
sequences : !false_by_default,
|
@@ -828,7 +828,13 @@ AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
|
|
828
828
|
return true;
|
829
829
|
}
|
830
830
|
}
|
831
|
-
|
831
|
+
if ((this instanceof AST_New) && compressor.option("pure_new")) {
|
832
|
+
return true;
|
833
|
+
}
|
834
|
+
if (compressor.option("side_effects") && has_annotation(this, _PURE)) {
|
835
|
+
return true;
|
836
|
+
}
|
837
|
+
return !compressor.pure_funcs(this);
|
832
838
|
});
|
833
839
|
|
834
840
|
// If I call this, is it a pure function?
|
package/lib/output.js
CHANGED
@@ -169,7 +169,7 @@ import {
|
|
169
169
|
const CODE_LINE_BREAK = 10;
|
170
170
|
const CODE_SPACE = 32;
|
171
171
|
|
172
|
-
const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__
|
172
|
+
const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/;
|
173
173
|
|
174
174
|
function is_some_comments(comment) {
|
175
175
|
// multiline comment
|
@@ -321,6 +321,13 @@ function OutputStream(options) {
|
|
321
321
|
}
|
322
322
|
}
|
323
323
|
|
324
|
+
if (options.preserve_annotations) {
|
325
|
+
let prev_comment_filter = comment_filter;
|
326
|
+
comment_filter = function (comment) {
|
327
|
+
return r_annotation.test(comment.value) || prev_comment_filter.apply(this, arguments);
|
328
|
+
};
|
329
|
+
}
|
330
|
+
|
324
331
|
var indentation = 0;
|
325
332
|
var current_col = 0;
|
326
333
|
var current_line = 1;
|
package/lib/parse.js
CHANGED
@@ -2330,9 +2330,7 @@ function parse($TEXT, options) {
|
|
2330
2330
|
var ex = async ? new AST_Call({
|
2331
2331
|
expression: async,
|
2332
2332
|
args: exprs
|
2333
|
-
}) :
|
2334
|
-
expressions: exprs
|
2335
|
-
});
|
2333
|
+
}) : to_expr_or_sequence(start, exprs);
|
2336
2334
|
if (ex.start) {
|
2337
2335
|
const outer_comments_before = start.comments_before.length;
|
2338
2336
|
outer_comments_before_counts.set(start, outer_comments_before);
|
@@ -3429,6 +3427,16 @@ function parse($TEXT, options) {
|
|
3429
3427
|
return left;
|
3430
3428
|
};
|
3431
3429
|
|
3430
|
+
var to_expr_or_sequence = function(start, exprs) {
|
3431
|
+
if (exprs.length === 1) {
|
3432
|
+
return exprs[0];
|
3433
|
+
} else if (exprs.length > 1) {
|
3434
|
+
return new AST_Sequence({ start, expressions: exprs, end: peek() });
|
3435
|
+
} else {
|
3436
|
+
croak("Invalid parenthesized expression");
|
3437
|
+
}
|
3438
|
+
};
|
3439
|
+
|
3432
3440
|
var expression = function(commas, no_in) {
|
3433
3441
|
var start = S.token;
|
3434
3442
|
var exprs = [];
|
@@ -3438,11 +3446,7 @@ function parse($TEXT, options) {
|
|
3438
3446
|
next();
|
3439
3447
|
commas = true;
|
3440
3448
|
}
|
3441
|
-
return
|
3442
|
-
start : start,
|
3443
|
-
expressions : exprs,
|
3444
|
-
end : peek()
|
3445
|
-
});
|
3449
|
+
return to_expr_or_sequence(start, exprs);
|
3446
3450
|
};
|
3447
3451
|
|
3448
3452
|
function in_loop(cont) {
|
package/package.json
CHANGED
package/tools/domprops.js
CHANGED
@@ -4771,6 +4771,7 @@ export var domprops = [
|
|
4771
4771
|
"gridTemplateRows",
|
4772
4772
|
"gripSpace",
|
4773
4773
|
"group",
|
4774
|
+
"groups",
|
4774
4775
|
"groupCollapsed",
|
4775
4776
|
"groupEnd",
|
4776
4777
|
"groupId",
|
@@ -4878,6 +4879,7 @@ export var domprops = [
|
|
4878
4879
|
"indexOf",
|
4879
4880
|
"indexedDB",
|
4880
4881
|
"indicate",
|
4882
|
+
"indices",
|
4881
4883
|
"inert",
|
4882
4884
|
"inertiaDestinationX",
|
4883
4885
|
"inertiaDestinationY",
|