terser 5.11.0 → 5.13.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 +16 -0
- package/README.md +24 -8
- package/dist/bundle.min.js +2360 -731
- package/lib/ast.js +1662 -350
- package/lib/cli.js +13 -9
- package/lib/compress/evaluate.js +4 -3
- package/lib/equivalent-to.js +81 -107
- package/lib/minify.js +49 -1
- package/lib/mozilla-ast.js +474 -81
- package/lib/output.js +3 -2
- package/lib/propmangle.js +1 -1
- package/lib/scope.js +22 -0
- package/package.json +4 -2
- package/tools/domprops.js +11 -0
package/lib/output.js
CHANGED
@@ -172,7 +172,7 @@ function is_some_comments(comment) {
|
|
172
172
|
// multiline comment
|
173
173
|
return (
|
174
174
|
(comment.type === "comment2" || comment.type === "comment1")
|
175
|
-
&& /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
|
175
|
+
&& /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
|
176
176
|
);
|
177
177
|
}
|
178
178
|
|
@@ -1098,7 +1098,8 @@ function OutputStream(options) {
|
|
1098
1098
|
var p = output.parent();
|
1099
1099
|
if (this.args.length === 0
|
1100
1100
|
&& (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
|
1101
|
-
|| p instanceof AST_Call && p.expression === this
|
1101
|
+
|| p instanceof AST_Call && p.expression === this
|
1102
|
+
|| p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
|
1102
1103
|
return true;
|
1103
1104
|
});
|
1104
1105
|
|
package/lib/propmangle.js
CHANGED
@@ -78,7 +78,7 @@ function find_builtins(reserved) {
|
|
78
78
|
var global_ref = typeof global === "object" ? global : self;
|
79
79
|
|
80
80
|
new_globals.forEach(function (new_global) {
|
81
|
-
objects[new_global] = global_ref[new_global] ||
|
81
|
+
objects[new_global] = global_ref[new_global] || function() {};
|
82
82
|
});
|
83
83
|
|
84
84
|
[
|
package/lib/scope.js
CHANGED
@@ -116,6 +116,11 @@ const MASK_EXPORT_WANT_MANGLE = 1 << 1;
|
|
116
116
|
|
117
117
|
let function_defs = null;
|
118
118
|
let unmangleable_names = null;
|
119
|
+
/**
|
120
|
+
* When defined, there is a function declaration somewhere that's inside of a block.
|
121
|
+
* See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
|
122
|
+
*/
|
123
|
+
let scopes_with_block_defuns = null;
|
119
124
|
|
120
125
|
class SymbolDef {
|
121
126
|
constructor(scope, orig, init) {
|
@@ -666,6 +671,15 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
|
666
671
|
});
|
667
672
|
|
668
673
|
function next_mangled(scope, options) {
|
674
|
+
let defun_scope;
|
675
|
+
if (
|
676
|
+
scopes_with_block_defuns
|
677
|
+
&& (defun_scope = scope.get_defun_scope())
|
678
|
+
&& scopes_with_block_defuns.has(defun_scope)
|
679
|
+
) {
|
680
|
+
scope = defun_scope;
|
681
|
+
}
|
682
|
+
|
669
683
|
var ext = scope.enclosed;
|
670
684
|
var nth_identifier = options.nth_identifier;
|
671
685
|
out: while (true) {
|
@@ -800,6 +814,13 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
800
814
|
lname = save_nesting;
|
801
815
|
return true; // don't descend again in TreeWalker
|
802
816
|
}
|
817
|
+
if (
|
818
|
+
node instanceof AST_Defun
|
819
|
+
&& !(tw.parent() instanceof AST_Scope)
|
820
|
+
) {
|
821
|
+
scopes_with_block_defuns = scopes_with_block_defuns || new Set();
|
822
|
+
scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
|
823
|
+
}
|
803
824
|
if (node instanceof AST_Scope) {
|
804
825
|
node.variables.forEach(collect);
|
805
826
|
return;
|
@@ -848,6 +869,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
848
869
|
|
849
870
|
function_defs = null;
|
850
871
|
unmangleable_names = null;
|
872
|
+
scopes_with_block_defuns = null;
|
851
873
|
|
852
874
|
function collect(symbol) {
|
853
875
|
if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"homepage": "https://terser.org",
|
5
5
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
6
6
|
"license": "BSD-2-Clause",
|
7
|
-
"version": "5.
|
7
|
+
"version": "5.13.0",
|
8
8
|
"engines": {
|
9
9
|
"node": ">=10"
|
10
10
|
},
|
@@ -45,7 +45,7 @@
|
|
45
45
|
"dependencies": {
|
46
46
|
"acorn": "^8.5.0",
|
47
47
|
"commander": "^2.20.0",
|
48
|
-
"source-map": "~0.
|
48
|
+
"source-map": "~0.8.0-beta.0",
|
49
49
|
"source-map-support": "~0.5.20"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
@@ -104,6 +104,8 @@
|
|
104
104
|
"describe": false,
|
105
105
|
"it": false,
|
106
106
|
"require": false,
|
107
|
+
"before": false,
|
108
|
+
"after": false,
|
107
109
|
"global": false,
|
108
110
|
"process": false
|
109
111
|
},
|
package/tools/domprops.js
CHANGED
@@ -2979,6 +2979,7 @@ export var domprops = [
|
|
2979
2979
|
"applyElement",
|
2980
2980
|
"arc",
|
2981
2981
|
"arcTo",
|
2982
|
+
"architecture",
|
2982
2983
|
"archive",
|
2983
2984
|
"areas",
|
2984
2985
|
"arguments",
|
@@ -3153,6 +3154,7 @@ export var domprops = [
|
|
3153
3154
|
"bindTexture",
|
3154
3155
|
"bindTransformFeedback",
|
3155
3156
|
"bindVertexArray",
|
3157
|
+
"bitness",
|
3156
3158
|
"blendColor",
|
3157
3159
|
"blendEquation",
|
3158
3160
|
"blendEquationSeparate",
|
@@ -3314,6 +3316,8 @@ export var domprops = [
|
|
3314
3316
|
"boxDecorationBreak",
|
3315
3317
|
"boxShadow",
|
3316
3318
|
"boxSizing",
|
3319
|
+
"brand",
|
3320
|
+
"brands",
|
3317
3321
|
"break-after",
|
3318
3322
|
"break-before",
|
3319
3323
|
"break-inside",
|
@@ -4312,6 +4316,7 @@ export var domprops = [
|
|
4312
4316
|
"fround",
|
4313
4317
|
"fullPath",
|
4314
4318
|
"fullScreen",
|
4319
|
+
"fullVersionList",
|
4315
4320
|
"fullscreen",
|
4316
4321
|
"fullscreenElement",
|
4317
4322
|
"fullscreenEnabled",
|
@@ -4437,6 +4442,7 @@ export var domprops = [
|
|
4437
4442
|
"getFrequencyResponse",
|
4438
4443
|
"getFullYear",
|
4439
4444
|
"getGamepads",
|
4445
|
+
"getHighEntropyValues",
|
4440
4446
|
"getHitTestResults",
|
4441
4447
|
"getHitTestResultsForTransientInput",
|
4442
4448
|
"getHours",
|
@@ -5277,7 +5283,9 @@ export var domprops = [
|
|
5277
5283
|
"mix-blend-mode",
|
5278
5284
|
"mixBlendMode",
|
5279
5285
|
"mm",
|
5286
|
+
"mobile",
|
5280
5287
|
"mode",
|
5288
|
+
"model",
|
5281
5289
|
"modify",
|
5282
5290
|
"mount",
|
5283
5291
|
"move",
|
@@ -6183,6 +6191,7 @@ export var domprops = [
|
|
6183
6191
|
"placeItems",
|
6184
6192
|
"placeSelf",
|
6185
6193
|
"placeholder",
|
6194
|
+
"platformVersion",
|
6186
6195
|
"platform",
|
6187
6196
|
"platforms",
|
6188
6197
|
"play",
|
@@ -7421,6 +7430,7 @@ export var domprops = [
|
|
7421
7430
|
"user-select",
|
7422
7431
|
"userActivation",
|
7423
7432
|
"userAgent",
|
7433
|
+
"userAgentData",
|
7424
7434
|
"userChoice",
|
7425
7435
|
"userHandle",
|
7426
7436
|
"userHint",
|
@@ -7734,6 +7744,7 @@ export var domprops = [
|
|
7734
7744
|
"wordSpacing",
|
7735
7745
|
"wordWrap",
|
7736
7746
|
"workerStart",
|
7747
|
+
"wow64",
|
7737
7748
|
"wrap",
|
7738
7749
|
"wrapKey",
|
7739
7750
|
"writable",
|