terser 5.5.0 → 5.6.1
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 +21 -1
- package/README.md +2 -2
- package/dist/bundle.min.js +342 -67
- package/lib/ast.js +50 -2
- package/lib/cli.js +4 -14
- package/lib/compress/index.js +16 -7
- package/lib/mozilla-ast.js +75 -6
- package/lib/output.js +70 -9
- package/lib/parse.js +71 -19
- package/lib/propmangle.js +33 -2
- package/lib/scope.js +4 -1
- package/lib/size.js +33 -2
- package/lib/utils/index.js +3 -1
- package/package.json +8 -8
- package/tools/domprops.js +1 -0
- package/tools/terser.d.ts +1 -0
package/dist/bundle.min.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
(function (global, factory) {
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('source-map')) :
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'source-map'], factory) :
|
4
|
-
(global = global || self, factory(global.Terser = {}, global.sourceMap));
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
|
5
5
|
}(this, (function (exports, MOZ_SourceMap) { 'use strict';
|
6
6
|
|
7
|
-
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8
|
+
|
9
|
+
var MOZ_SourceMap__default = /*#__PURE__*/_interopDefaultLegacy(MOZ_SourceMap);
|
8
10
|
|
9
11
|
/***********************************************************************
|
10
12
|
|
@@ -241,6 +243,7 @@ function keep_name(keep_setting, name) {
|
|
241
243
|
}
|
242
244
|
|
243
245
|
var lineTerminatorEscape = {
|
246
|
+
"\0": "0",
|
244
247
|
"\n": "n",
|
245
248
|
"\r": "r",
|
246
249
|
"\u2028": "u2028",
|
@@ -248,7 +251,8 @@ var lineTerminatorEscape = {
|
|
248
251
|
};
|
249
252
|
function regexp_source_fix(source) {
|
250
253
|
// V8 does not escape line terminators in regexp patterns in node 12
|
251
|
-
|
254
|
+
// We'll also remove literal \0
|
255
|
+
return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
|
252
256
|
var escaped = source[offset - 1] == "\\"
|
253
257
|
&& (source[offset - 2] != "\\"
|
254
258
|
|| /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
|
@@ -482,12 +486,14 @@ function is_identifier_char(ch) {
|
|
482
486
|
return UNICODE.ID_Continue.test(ch);
|
483
487
|
}
|
484
488
|
|
489
|
+
const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
|
490
|
+
|
485
491
|
function is_basic_identifier_string(str) {
|
486
|
-
return
|
492
|
+
return BASIC_IDENT.test(str);
|
487
493
|
}
|
488
494
|
|
489
495
|
function is_identifier_string(str, allow_surrogates) {
|
490
|
-
if (
|
496
|
+
if (BASIC_IDENT.test(str)) {
|
491
497
|
return true;
|
492
498
|
}
|
493
499
|
if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
|
@@ -1033,6 +1039,11 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|
1033
1039
|
: token("keyword", word);
|
1034
1040
|
}
|
1035
1041
|
|
1042
|
+
function read_private_word() {
|
1043
|
+
next();
|
1044
|
+
return token("privatename", read_name());
|
1045
|
+
}
|
1046
|
+
|
1036
1047
|
function with_eof_error(eof_error, cont) {
|
1037
1048
|
return function(x) {
|
1038
1049
|
try {
|
@@ -1102,6 +1113,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|
1102
1113
|
if (PUNC_CHARS.has(ch)) return token("punc", next());
|
1103
1114
|
if (OPERATOR_CHARS.has(ch)) return read_operator();
|
1104
1115
|
if (code == 92 || is_identifier_start(ch)) return read_word();
|
1116
|
+
if (code == 35) return read_private_word();
|
1105
1117
|
break;
|
1106
1118
|
}
|
1107
1119
|
parse_error("Unexpected character '" + ch + "'");
|
@@ -1302,6 +1314,13 @@ function parse($TEXT, options) {
|
|
1302
1314
|
return S.in_async === S.in_function;
|
1303
1315
|
}
|
1304
1316
|
|
1317
|
+
function can_await() {
|
1318
|
+
return (
|
1319
|
+
S.in_async === S.in_function
|
1320
|
+
|| S.in_function === 0 && S.input.has_directive("use strict")
|
1321
|
+
);
|
1322
|
+
}
|
1323
|
+
|
1305
1324
|
function semicolon(optional) {
|
1306
1325
|
if (is("punc", ";")) next();
|
1307
1326
|
else if (!optional && !can_insert_semicolon()) unexpected();
|
@@ -1586,7 +1605,7 @@ function parse($TEXT, options) {
|
|
1586
1605
|
var for_await_error = "`for await` invalid in this context";
|
1587
1606
|
var await_tok = S.token;
|
1588
1607
|
if (await_tok.type == "name" && await_tok.value == "await") {
|
1589
|
-
if (!
|
1608
|
+
if (!can_await()) {
|
1590
1609
|
token_error(await_tok, for_await_error);
|
1591
1610
|
}
|
1592
1611
|
next();
|
@@ -2083,7 +2102,7 @@ function parse($TEXT, options) {
|
|
2083
2102
|
|
2084
2103
|
function _await_expression() {
|
2085
2104
|
// Previous token must be "await" and not be interpreted as an identifier
|
2086
|
-
if (!
|
2105
|
+
if (!can_await()) {
|
2087
2106
|
croak("Unexpected await expression outside async function",
|
2088
2107
|
S.prev.line, S.prev.col, S.prev.pos);
|
2089
2108
|
}
|
@@ -2703,6 +2722,7 @@ function parse($TEXT, options) {
|
|
2703
2722
|
}
|
2704
2723
|
return name;
|
2705
2724
|
};
|
2725
|
+
var privatename = start.type == "privatename";
|
2706
2726
|
var is_async = false;
|
2707
2727
|
var is_static = false;
|
2708
2728
|
var is_generator = false;
|
@@ -2710,16 +2730,19 @@ function parse($TEXT, options) {
|
|
2710
2730
|
if (is_class && name === "static" && !is("punc", "(")) {
|
2711
2731
|
is_static = true;
|
2712
2732
|
property_token = S.token;
|
2733
|
+
privatename = property_token.type == "privatename";
|
2713
2734
|
name = as_property_name();
|
2714
2735
|
}
|
2715
2736
|
if (name === "async" && !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("operator", "=")) {
|
2716
2737
|
is_async = true;
|
2717
2738
|
property_token = S.token;
|
2739
|
+
privatename = property_token.type == "privatename";
|
2718
2740
|
name = as_property_name();
|
2719
2741
|
}
|
2720
2742
|
if (name === null) {
|
2721
2743
|
is_generator = true;
|
2722
2744
|
property_token = S.token;
|
2745
|
+
privatename = property_token.type == "privatename";
|
2723
2746
|
name = as_property_name();
|
2724
2747
|
if (name === null) {
|
2725
2748
|
unexpected();
|
@@ -2727,7 +2750,10 @@ function parse($TEXT, options) {
|
|
2727
2750
|
}
|
2728
2751
|
if (is("punc", "(")) {
|
2729
2752
|
name = get_method_name_ast(name, start);
|
2730
|
-
|
2753
|
+
const AST_MethodVariant = privatename
|
2754
|
+
? AST_PrivateMethod
|
2755
|
+
: AST_ConciseMethod;
|
2756
|
+
var node = new AST_MethodVariant({
|
2731
2757
|
start : start,
|
2732
2758
|
static : is_static,
|
2733
2759
|
is_generator: is_generator,
|
@@ -2741,6 +2767,23 @@ function parse($TEXT, options) {
|
|
2741
2767
|
return node;
|
2742
2768
|
}
|
2743
2769
|
const setter_token = S.token;
|
2770
|
+
if ((name === "get" || name === "set") && setter_token.type === "privatename") {
|
2771
|
+
next();
|
2772
|
+
|
2773
|
+
const AST_AccessorVariant =
|
2774
|
+
name === "get"
|
2775
|
+
? AST_PrivateGetter
|
2776
|
+
: AST_PrivateSetter;
|
2777
|
+
|
2778
|
+
return new AST_AccessorVariant({
|
2779
|
+
start,
|
2780
|
+
static: is_static,
|
2781
|
+
key: get_method_name_ast(setter_token.value, start),
|
2782
|
+
value: create_accessor(),
|
2783
|
+
end: prev(),
|
2784
|
+
});
|
2785
|
+
}
|
2786
|
+
|
2744
2787
|
if (name == "get") {
|
2745
2788
|
if (!is("punc") || is("punc", "[")) {
|
2746
2789
|
name = get_method_name_ast(as_property_name(), start);
|
@@ -2773,9 +2816,12 @@ function parse($TEXT, options) {
|
|
2773
2816
|
const quote = key instanceof AST_SymbolClassProperty
|
2774
2817
|
? property_token.quote
|
2775
2818
|
: undefined;
|
2819
|
+
const AST_ClassPropertyVariant = privatename
|
2820
|
+
? AST_ClassPrivateProperty
|
2821
|
+
: AST_ClassProperty;
|
2776
2822
|
if (is("operator", "=")) {
|
2777
2823
|
next();
|
2778
|
-
return new
|
2824
|
+
return new AST_ClassPropertyVariant({
|
2779
2825
|
start,
|
2780
2826
|
static: is_static,
|
2781
2827
|
quote,
|
@@ -2783,8 +2829,14 @@ function parse($TEXT, options) {
|
|
2783
2829
|
value: expression(false),
|
2784
2830
|
end: prev()
|
2785
2831
|
});
|
2786
|
-
} else if (
|
2787
|
-
|
2832
|
+
} else if (
|
2833
|
+
is("name")
|
2834
|
+
|| is("privatename")
|
2835
|
+
|| is("operator", "*")
|
2836
|
+
|| is("punc", ";")
|
2837
|
+
|| is("punc", "}")
|
2838
|
+
) {
|
2839
|
+
return new AST_ClassPropertyVariant({
|
2788
2840
|
start,
|
2789
2841
|
static: is_static,
|
2790
2842
|
quote,
|
@@ -3023,6 +3075,7 @@ function parse($TEXT, options) {
|
|
3023
3075
|
}
|
3024
3076
|
/* falls through */
|
3025
3077
|
case "name":
|
3078
|
+
case "privatename":
|
3026
3079
|
case "string":
|
3027
3080
|
case "num":
|
3028
3081
|
case "big_int":
|
@@ -3037,7 +3090,7 @@ function parse($TEXT, options) {
|
|
3037
3090
|
|
3038
3091
|
function as_name() {
|
3039
3092
|
var tmp = S.token;
|
3040
|
-
if (tmp.type != "name") unexpected();
|
3093
|
+
if (tmp.type != "name" && tmp.type != "privatename") unexpected();
|
3041
3094
|
next();
|
3042
3095
|
return tmp.value;
|
3043
3096
|
}
|
@@ -3108,7 +3161,8 @@ function parse($TEXT, options) {
|
|
3108
3161
|
var start = expr.start;
|
3109
3162
|
if (is("punc", ".")) {
|
3110
3163
|
next();
|
3111
|
-
|
3164
|
+
const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
|
3165
|
+
return subscripts(new AST_DotVariant({
|
3112
3166
|
start : start,
|
3113
3167
|
expression : expr,
|
3114
3168
|
optional : false,
|
@@ -3159,8 +3213,9 @@ function parse($TEXT, options) {
|
|
3159
3213
|
annotate(call);
|
3160
3214
|
|
3161
3215
|
chain_contents = subscripts(call, true, true);
|
3162
|
-
} else if (is("name")) {
|
3163
|
-
|
3216
|
+
} else if (is("name") || is("privatename")) {
|
3217
|
+
const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
|
3218
|
+
chain_contents = subscripts(new AST_DotVariant({
|
3164
3219
|
start,
|
3165
3220
|
expression: expr,
|
3166
3221
|
optional: true,
|
@@ -3231,13 +3286,9 @@ function parse($TEXT, options) {
|
|
3231
3286
|
|
3232
3287
|
var maybe_unary = function(allow_calls, allow_arrows) {
|
3233
3288
|
var start = S.token;
|
3234
|
-
if (start.type == "name" && start.value == "await") {
|
3235
|
-
|
3236
|
-
|
3237
|
-
return _await_expression();
|
3238
|
-
} else if (S.input.has_directive("use strict")) {
|
3239
|
-
token_error(S.token, "Unexpected await identifier inside strict mode");
|
3240
|
-
}
|
3289
|
+
if (start.type == "name" && start.value == "await" && can_await()) {
|
3290
|
+
next();
|
3291
|
+
return _await_expression();
|
3241
3292
|
}
|
3242
3293
|
if (is("operator") && UNARY_PREFIX.has(start.value)) {
|
3243
3294
|
next();
|
@@ -3965,6 +4016,9 @@ var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator as
|
|
3965
4016
|
|
3966
4017
|
if (this.name) push(this.name);
|
3967
4018
|
},
|
4019
|
+
is_braceless() {
|
4020
|
+
return this.body[0] instanceof AST_Return && this.body[0].value;
|
4021
|
+
}
|
3968
4022
|
}, AST_Scope);
|
3969
4023
|
|
3970
4024
|
var AST_Accessor = DEFNODE("Accessor", null, {
|
@@ -4450,7 +4504,7 @@ var AST_PropAccess = DEFNODE("PropAccess", "expression property optional", {
|
|
4450
4504
|
$documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
|
4451
4505
|
$propdoc: {
|
4452
4506
|
expression: "[AST_Node] the “container” expression",
|
4453
|
-
property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
|
4507
|
+
property: "[AST_Node|string] the property to access. For AST_Dot & AST_DotHash this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
|
4454
4508
|
|
4455
4509
|
optional: "[boolean] whether this is an optional property access (IE ?.)"
|
4456
4510
|
}
|
@@ -4471,6 +4525,18 @@ var AST_Dot = DEFNODE("Dot", "quote", {
|
|
4471
4525
|
},
|
4472
4526
|
}, AST_PropAccess);
|
4473
4527
|
|
4528
|
+
var AST_DotHash = DEFNODE("DotHash", "", {
|
4529
|
+
$documentation: "A dotted property access to a private property",
|
4530
|
+
_walk: function(visitor) {
|
4531
|
+
return visitor._visit(this, function() {
|
4532
|
+
this.expression._walk(visitor);
|
4533
|
+
});
|
4534
|
+
},
|
4535
|
+
_children_backwards(push) {
|
4536
|
+
push(this.expression);
|
4537
|
+
},
|
4538
|
+
}, AST_PropAccess);
|
4539
|
+
|
4474
4540
|
var AST_Sub = DEFNODE("Sub", null, {
|
4475
4541
|
$documentation: "Index-style property access, i.e. `a[\"foo\"]`",
|
4476
4542
|
_walk: function(visitor) {
|
@@ -4488,7 +4554,7 @@ var AST_Sub = DEFNODE("Sub", null, {
|
|
4488
4554
|
var AST_Chain = DEFNODE("Chain", "expression", {
|
4489
4555
|
$documentation: "A chain expression like a?.b?.(c)?.[d]",
|
4490
4556
|
$propdoc: {
|
4491
|
-
expression: "[AST_Call|AST_Dot|AST_Sub] chain element."
|
4557
|
+
expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
|
4492
4558
|
},
|
4493
4559
|
_walk: function (visitor) {
|
4494
4560
|
return visitor._visit(this, function() {
|
@@ -4644,6 +4710,26 @@ var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
|
|
4644
4710
|
}
|
4645
4711
|
}, AST_ObjectProperty);
|
4646
4712
|
|
4713
|
+
var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", {
|
4714
|
+
$propdoc: {
|
4715
|
+
static: "[boolean] whether this is a static private setter"
|
4716
|
+
},
|
4717
|
+
$documentation: "A private setter property",
|
4718
|
+
computed_key() {
|
4719
|
+
return false;
|
4720
|
+
}
|
4721
|
+
}, AST_ObjectProperty);
|
4722
|
+
|
4723
|
+
var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", {
|
4724
|
+
$propdoc: {
|
4725
|
+
static: "[boolean] whether this is a static private getter"
|
4726
|
+
},
|
4727
|
+
$documentation: "A private getter property",
|
4728
|
+
computed_key() {
|
4729
|
+
return false;
|
4730
|
+
}
|
4731
|
+
}, AST_ObjectProperty);
|
4732
|
+
|
4647
4733
|
var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
|
4648
4734
|
$propdoc: {
|
4649
4735
|
quote: "[string|undefined] the original quote character, if any",
|
@@ -4679,6 +4765,10 @@ var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator asyn
|
|
4679
4765
|
}
|
4680
4766
|
}, AST_ObjectProperty);
|
4681
4767
|
|
4768
|
+
var AST_PrivateMethod = DEFNODE("PrivateMethod", "", {
|
4769
|
+
$documentation: "A private class method inside a class",
|
4770
|
+
}, AST_ConciseMethod);
|
4771
|
+
|
4682
4772
|
var AST_Class = DEFNODE("Class", "name extends properties", {
|
4683
4773
|
$propdoc: {
|
4684
4774
|
name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
|
@@ -4728,6 +4818,10 @@ var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", {
|
|
4728
4818
|
}
|
4729
4819
|
}, AST_ObjectProperty);
|
4730
4820
|
|
4821
|
+
var AST_ClassPrivateProperty = DEFNODE("ClassProperty", "", {
|
4822
|
+
$documentation: "A class property for a private property",
|
4823
|
+
}, AST_ClassProperty);
|
4824
|
+
|
4731
4825
|
var AST_DefClass = DEFNODE("DefClass", null, {
|
4732
4826
|
$documentation: "A class definition",
|
4733
4827
|
}, AST_Class);
|
@@ -5128,6 +5222,7 @@ AST_Catch: AST_Catch,
|
|
5128
5222
|
AST_Chain: AST_Chain,
|
5129
5223
|
AST_Class: AST_Class,
|
5130
5224
|
AST_ClassExpression: AST_ClassExpression,
|
5225
|
+
AST_ClassPrivateProperty: AST_ClassPrivateProperty,
|
5131
5226
|
AST_ClassProperty: AST_ClassProperty,
|
5132
5227
|
AST_ConciseMethod: AST_ConciseMethod,
|
5133
5228
|
AST_Conditional: AST_Conditional,
|
@@ -5144,6 +5239,7 @@ AST_Destructuring: AST_Destructuring,
|
|
5144
5239
|
AST_Directive: AST_Directive,
|
5145
5240
|
AST_Do: AST_Do,
|
5146
5241
|
AST_Dot: AST_Dot,
|
5242
|
+
AST_DotHash: AST_DotHash,
|
5147
5243
|
AST_DWLoop: AST_DWLoop,
|
5148
5244
|
AST_EmptyStatement: AST_EmptyStatement,
|
5149
5245
|
AST_Exit: AST_Exit,
|
@@ -5181,6 +5277,9 @@ AST_ObjectKeyVal: AST_ObjectKeyVal,
|
|
5181
5277
|
AST_ObjectProperty: AST_ObjectProperty,
|
5182
5278
|
AST_ObjectSetter: AST_ObjectSetter,
|
5183
5279
|
AST_PrefixedTemplateString: AST_PrefixedTemplateString,
|
5280
|
+
AST_PrivateGetter: AST_PrivateGetter,
|
5281
|
+
AST_PrivateMethod: AST_PrivateMethod,
|
5282
|
+
AST_PrivateSetter: AST_PrivateSetter,
|
5184
5283
|
AST_PropAccess: AST_PropAccess,
|
5185
5284
|
AST_RegExp: AST_RegExp,
|
5186
5285
|
AST_Return: AST_Return,
|
@@ -5784,6 +5883,23 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
5784
5883
|
static : M.static,
|
5785
5884
|
});
|
5786
5885
|
},
|
5886
|
+
PropertyDefinition: function(M) {
|
5887
|
+
let key;
|
5888
|
+
if (M.computed) {
|
5889
|
+
key = from_moz(M.key);
|
5890
|
+
} else {
|
5891
|
+
if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
|
5892
|
+
key = from_moz(M.key);
|
5893
|
+
}
|
5894
|
+
|
5895
|
+
return new AST_ClassProperty({
|
5896
|
+
start : my_start_token(M),
|
5897
|
+
end : my_end_token(M),
|
5898
|
+
key,
|
5899
|
+
value : from_moz(M.value),
|
5900
|
+
static : M.static,
|
5901
|
+
});
|
5902
|
+
},
|
5787
5903
|
ArrayExpression: function(M) {
|
5788
5904
|
return new AST_Array({
|
5789
5905
|
start : my_start_token(M),
|
@@ -5972,7 +6088,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
5972
6088
|
: p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
|
5973
6089
|
: p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
|
5974
6090
|
: p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
|
5975
|
-
: p.type == "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
|
6091
|
+
: p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
|
5976
6092
|
: p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
|
5977
6093
|
: p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
|
5978
6094
|
: p.type == "CatchClause" ? AST_SymbolCatch
|
@@ -6271,6 +6387,19 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
6271
6387
|
};
|
6272
6388
|
});
|
6273
6389
|
|
6390
|
+
def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
|
6391
|
+
return {
|
6392
|
+
type: "MemberExpression",
|
6393
|
+
object: to_moz(M.expression),
|
6394
|
+
computed: false,
|
6395
|
+
property: {
|
6396
|
+
type: "PrivateIdentifier",
|
6397
|
+
name: M.property
|
6398
|
+
},
|
6399
|
+
optional: M.optional
|
6400
|
+
};
|
6401
|
+
});
|
6402
|
+
|
6274
6403
|
def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
|
6275
6404
|
var isComputed = M instanceof AST_Sub;
|
6276
6405
|
return {
|
@@ -6363,12 +6492,38 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
6363
6492
|
if (M instanceof AST_ObjectSetter) {
|
6364
6493
|
kind = "set";
|
6365
6494
|
}
|
6495
|
+
if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
|
6496
|
+
const kind = M instanceof AST_PrivateGetter ? "get" : "set";
|
6497
|
+
return {
|
6498
|
+
type: "MethodDefinition",
|
6499
|
+
computed: false,
|
6500
|
+
kind: kind,
|
6501
|
+
static: M.static,
|
6502
|
+
key: {
|
6503
|
+
type: "PrivateIdentifier",
|
6504
|
+
name: M.key.name
|
6505
|
+
},
|
6506
|
+
value: to_moz(M.value)
|
6507
|
+
};
|
6508
|
+
}
|
6509
|
+
if (M instanceof AST_ClassPrivateProperty) {
|
6510
|
+
return {
|
6511
|
+
type: "PropertyDefinition",
|
6512
|
+
key: {
|
6513
|
+
type: "PrivateIdentifier",
|
6514
|
+
name: M.key.name
|
6515
|
+
},
|
6516
|
+
value: to_moz(M.value),
|
6517
|
+
computed: false,
|
6518
|
+
static: M.static
|
6519
|
+
};
|
6520
|
+
}
|
6366
6521
|
if (M instanceof AST_ClassProperty) {
|
6367
6522
|
return {
|
6368
|
-
type: "
|
6369
|
-
computed,
|
6523
|
+
type: "PropertyDefinition",
|
6370
6524
|
key,
|
6371
6525
|
value: to_moz(M.value),
|
6526
|
+
computed,
|
6372
6527
|
static: M.static
|
6373
6528
|
};
|
6374
6529
|
}
|
@@ -6403,13 +6558,21 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
6403
6558
|
value: to_moz(M.value)
|
6404
6559
|
};
|
6405
6560
|
}
|
6561
|
+
|
6562
|
+
const key = M instanceof AST_PrivateMethod
|
6563
|
+
? {
|
6564
|
+
type: "PrivateIdentifier",
|
6565
|
+
name: M.key.name
|
6566
|
+
}
|
6567
|
+
: to_moz(M.key);
|
6568
|
+
|
6406
6569
|
return {
|
6407
6570
|
type: "MethodDefinition",
|
6408
|
-
computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
|
6409
6571
|
kind: M.key === "constructor" ? "constructor" : "method",
|
6572
|
+
key,
|
6573
|
+
value: to_moz(M.value),
|
6574
|
+
computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
|
6410
6575
|
static: M.static,
|
6411
|
-
key: to_moz(M.key),
|
6412
|
-
value: to_moz(M.value)
|
6413
6576
|
};
|
6414
6577
|
});
|
6415
6578
|
|
@@ -6824,7 +6987,7 @@ function OutputStream(options) {
|
|
6824
6987
|
let printed_comments = new Set();
|
6825
6988
|
|
6826
6989
|
var to_utf8 = options.ascii_only ? function(str, identifier) {
|
6827
|
-
if (options.ecma >= 2015) {
|
6990
|
+
if (options.ecma >= 2015 && !options.safari10) {
|
6828
6991
|
str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
|
6829
6992
|
var code = get_full_char_code(ch, 0).toString(16);
|
6830
6993
|
return "\\u{" + code + "}";
|
@@ -7513,6 +7676,7 @@ function OutputStream(options) {
|
|
7513
7676
|
var p = output.parent();
|
7514
7677
|
return p instanceof AST_PropAccess && p.expression === this
|
7515
7678
|
|| p instanceof AST_Call && p.expression === this
|
7679
|
+
|| p instanceof AST_Binary && p.operator === "**" && p.left === this
|
7516
7680
|
|| output.option("safari10") && p instanceof AST_UnaryPrefix;
|
7517
7681
|
});
|
7518
7682
|
|
@@ -8364,7 +8528,10 @@ function OutputStream(options) {
|
|
8364
8528
|
var prop = self.property;
|
8365
8529
|
var print_computed = RESERVED_WORDS.has(prop)
|
8366
8530
|
? output.option("ie8")
|
8367
|
-
: !is_identifier_string(
|
8531
|
+
: !is_identifier_string(
|
8532
|
+
prop,
|
8533
|
+
output.option("ecma") >= 2015 || output.option("safari10")
|
8534
|
+
);
|
8368
8535
|
|
8369
8536
|
if (self.optional) output.print("?.");
|
8370
8537
|
|
@@ -8385,6 +8552,15 @@ function OutputStream(options) {
|
|
8385
8552
|
output.print_name(prop);
|
8386
8553
|
}
|
8387
8554
|
});
|
8555
|
+
DEFPRINT(AST_DotHash, function(self, output) {
|
8556
|
+
var expr = self.expression;
|
8557
|
+
expr.print(output);
|
8558
|
+
var prop = self.property;
|
8559
|
+
|
8560
|
+
if (self.optional) output.print("?");
|
8561
|
+
output.print(".#");
|
8562
|
+
output.print_name(prop);
|
8563
|
+
});
|
8388
8564
|
DEFPRINT(AST_Sub, function(self, output) {
|
8389
8565
|
self.expression.print(output);
|
8390
8566
|
if (self.optional) output.print("?.");
|
@@ -8534,7 +8710,7 @@ function OutputStream(options) {
|
|
8534
8710
|
var print_string = RESERVED_WORDS.has(key)
|
8535
8711
|
? output.option("ie8")
|
8536
8712
|
: (
|
8537
|
-
output.option("ecma") < 2015
|
8713
|
+
output.option("ecma") < 2015 || output.option("safari10")
|
8538
8714
|
? !is_basic_identifier_string(key)
|
8539
8715
|
: !is_identifier_string(key, true)
|
8540
8716
|
);
|
@@ -8553,7 +8729,10 @@ function OutputStream(options) {
|
|
8553
8729
|
var allowShortHand = output.option("shorthand");
|
8554
8730
|
if (allowShortHand &&
|
8555
8731
|
self.value instanceof AST_Symbol &&
|
8556
|
-
is_identifier_string(
|
8732
|
+
is_identifier_string(
|
8733
|
+
self.key,
|
8734
|
+
output.option("ecma") >= 2015 || output.option("safari10")
|
8735
|
+
) &&
|
8557
8736
|
get_name(self.value) === self.key &&
|
8558
8737
|
!RESERVED_WORDS.has(self.key)
|
8559
8738
|
) {
|
@@ -8562,7 +8741,10 @@ function OutputStream(options) {
|
|
8562
8741
|
} else if (allowShortHand &&
|
8563
8742
|
self.value instanceof AST_DefaultAssign &&
|
8564
8743
|
self.value.left instanceof AST_Symbol &&
|
8565
|
-
is_identifier_string(
|
8744
|
+
is_identifier_string(
|
8745
|
+
self.key,
|
8746
|
+
output.option("ecma") >= 2015 || output.option("safari10")
|
8747
|
+
) &&
|
8566
8748
|
get_name(self.value.left) === self.key
|
8567
8749
|
) {
|
8568
8750
|
print_property_name(self.key, self.quote, output);
|
@@ -8582,6 +8764,23 @@ function OutputStream(options) {
|
|
8582
8764
|
self.value.print(output);
|
8583
8765
|
}
|
8584
8766
|
});
|
8767
|
+
DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
|
8768
|
+
if (self.static) {
|
8769
|
+
output.print("static");
|
8770
|
+
output.space();
|
8771
|
+
}
|
8772
|
+
|
8773
|
+
output.print("#");
|
8774
|
+
|
8775
|
+
print_property_name(self.key.name, self.quote, output);
|
8776
|
+
|
8777
|
+
if (self.value) {
|
8778
|
+
output.print("=");
|
8779
|
+
self.value.print(output);
|
8780
|
+
}
|
8781
|
+
|
8782
|
+
output.semicolon();
|
8783
|
+
});
|
8585
8784
|
DEFPRINT(AST_ClassProperty, (self, output) => {
|
8586
8785
|
if (self.static) {
|
8587
8786
|
output.print("static");
|
@@ -8603,7 +8802,7 @@ function OutputStream(options) {
|
|
8603
8802
|
|
8604
8803
|
output.semicolon();
|
8605
8804
|
});
|
8606
|
-
AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, output) {
|
8805
|
+
AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
|
8607
8806
|
var self = this;
|
8608
8807
|
if (self.static) {
|
8609
8808
|
output.print("static");
|
@@ -8614,6 +8813,7 @@ function OutputStream(options) {
|
|
8614
8813
|
output.space();
|
8615
8814
|
}
|
8616
8815
|
if (self.key instanceof AST_SymbolMethod) {
|
8816
|
+
if (is_private) output.print("#");
|
8617
8817
|
print_property_name(self.key.name, self.quote, output);
|
8618
8818
|
} else {
|
8619
8819
|
output.with_square(function() {
|
@@ -8623,10 +8823,27 @@ function OutputStream(options) {
|
|
8623
8823
|
self.value._do_print(output, true);
|
8624
8824
|
});
|
8625
8825
|
DEFPRINT(AST_ObjectSetter, function(self, output) {
|
8626
|
-
self._print_getter_setter("set", output);
|
8826
|
+
self._print_getter_setter("set", false, output);
|
8627
8827
|
});
|
8628
8828
|
DEFPRINT(AST_ObjectGetter, function(self, output) {
|
8629
|
-
self._print_getter_setter("get", output);
|
8829
|
+
self._print_getter_setter("get", false, output);
|
8830
|
+
});
|
8831
|
+
DEFPRINT(AST_PrivateSetter, function(self, output) {
|
8832
|
+
self._print_getter_setter("set", true, output);
|
8833
|
+
});
|
8834
|
+
DEFPRINT(AST_PrivateGetter, function(self, output) {
|
8835
|
+
self._print_getter_setter("get", true, output);
|
8836
|
+
});
|
8837
|
+
DEFPRINT(AST_PrivateMethod, function(self, output) {
|
8838
|
+
var type;
|
8839
|
+
if (self.is_generator && self.async) {
|
8840
|
+
type = "async*";
|
8841
|
+
} else if (self.is_generator) {
|
8842
|
+
type = "*";
|
8843
|
+
} else if (self.async) {
|
8844
|
+
type = "async";
|
8845
|
+
}
|
8846
|
+
self._print_getter_setter(type, true, output);
|
8630
8847
|
});
|
8631
8848
|
DEFPRINT(AST_ConciseMethod, function(self, output) {
|
8632
8849
|
var type;
|
@@ -8637,7 +8854,7 @@ function OutputStream(options) {
|
|
8637
8854
|
} else if (self.async) {
|
8638
8855
|
type = "async";
|
8639
8856
|
}
|
8640
|
-
self._print_getter_setter(type, output);
|
8857
|
+
self._print_getter_setter(type, false, output);
|
8641
8858
|
});
|
8642
8859
|
AST_Symbol.DEFMETHOD("_do_print", function(output) {
|
8643
8860
|
var def = this.definition();
|
@@ -8677,7 +8894,9 @@ function OutputStream(options) {
|
|
8677
8894
|
source = regexp_source_fix(source);
|
8678
8895
|
flags = flags ? sort_regexp_flags(flags) : "";
|
8679
8896
|
source = source.replace(r_slash_script, slash_script_replace);
|
8897
|
+
|
8680
8898
|
output.print(output.to_utf8(`/${source}/${flags}`));
|
8899
|
+
|
8681
8900
|
const parent = output.parent();
|
8682
8901
|
if (
|
8683
8902
|
parent instanceof AST_Binary
|
@@ -9898,7 +10117,9 @@ AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
|
|
9898
10117
|
if (this instanceof AST_Symbol && !this.unmangleable(options)) {
|
9899
10118
|
base54.consider(this.name, -1);
|
9900
10119
|
} else if (options.properties) {
|
9901
|
-
if (this instanceof
|
10120
|
+
if (this instanceof AST_DotHash) {
|
10121
|
+
base54.consider("#" + this.property, -1);
|
10122
|
+
} else if (this instanceof AST_Dot) {
|
9902
10123
|
base54.consider(this.property, -1);
|
9903
10124
|
} else if (this instanceof AST_Sub) {
|
9904
10125
|
skip_string(this.property);
|
@@ -9971,6 +10192,12 @@ AST_Node.prototype.size = function (compressor, stack) {
|
|
9971
10192
|
let size = 0;
|
9972
10193
|
walk_parent(this, (node, info) => {
|
9973
10194
|
size += node._size(info);
|
10195
|
+
|
10196
|
+
// Braceless arrow functions have fake "return" statements
|
10197
|
+
if (node instanceof AST_Arrow && node.is_braceless()) {
|
10198
|
+
size += node.body[0].value._size(info);
|
10199
|
+
return true;
|
10200
|
+
}
|
9974
10201
|
}, stack || (compressor && compressor.stack));
|
9975
10202
|
|
9976
10203
|
// just to save a bit of memory
|
@@ -10015,7 +10242,6 @@ AST_With.prototype._size = () => 6;
|
|
10015
10242
|
|
10016
10243
|
AST_Expansion.prototype._size = () => 3;
|
10017
10244
|
|
10018
|
-
/*#__INLINE__*/
|
10019
10245
|
const lambda_modifiers = func =>
|
10020
10246
|
(func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
|
10021
10247
|
|
@@ -10044,7 +10270,9 @@ AST_Arrow.prototype._size = function () {
|
|
10044
10270
|
args_and_arrow += 2;
|
10045
10271
|
}
|
10046
10272
|
|
10047
|
-
|
10273
|
+
const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
|
10274
|
+
|
10275
|
+
return lambda_modifiers(this) + args_and_arrow + body_overhead;
|
10048
10276
|
};
|
10049
10277
|
|
10050
10278
|
AST_Destructuring.prototype._size = () => 2;
|
@@ -10186,6 +10414,13 @@ AST_Dot.prototype._size = function () {
|
|
10186
10414
|
return this.property.length + 1;
|
10187
10415
|
};
|
10188
10416
|
|
10417
|
+
AST_DotHash.prototype._size = function () {
|
10418
|
+
if (this.optional) {
|
10419
|
+
return this.property.length + 3;
|
10420
|
+
}
|
10421
|
+
return this.property.length + 2;
|
10422
|
+
};
|
10423
|
+
|
10189
10424
|
AST_Sub.prototype._size = function () {
|
10190
10425
|
return this.optional ? 4 : 2;
|
10191
10426
|
};
|
@@ -10253,6 +10488,14 @@ AST_ConciseMethod.prototype._size = function () {
|
|
10253
10488
|
return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
|
10254
10489
|
};
|
10255
10490
|
|
10491
|
+
AST_PrivateMethod.prototype._size = function () {
|
10492
|
+
return AST_ConciseMethod.prototype._size.call(this) + 1;
|
10493
|
+
};
|
10494
|
+
|
10495
|
+
AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
|
10496
|
+
return AST_ConciseMethod.prototype._size.call(this) + 4;
|
10497
|
+
};
|
10498
|
+
|
10256
10499
|
AST_Class.prototype._size = function () {
|
10257
10500
|
return (
|
10258
10501
|
(this.name ? 8 : 7)
|
@@ -10268,6 +10511,10 @@ AST_ClassProperty.prototype._size = function () {
|
|
10268
10511
|
);
|
10269
10512
|
};
|
10270
10513
|
|
10514
|
+
AST_ClassPrivateProperty.prototype._size = function () {
|
10515
|
+
return AST_ClassProperty.prototype._size.call(this) + 1;
|
10516
|
+
};
|
10517
|
+
|
10271
10518
|
AST_Symbol.prototype._size = function () {
|
10272
10519
|
return !mangle_options || this.definition().unmangleable(mangle_options)
|
10273
10520
|
? this.name.length
|
@@ -11607,8 +11854,11 @@ function tighten_body(statements, compressor) {
|
|
11607
11854
|
|| node instanceof AST_Debugger
|
11608
11855
|
|| node instanceof AST_Destructuring
|
11609
11856
|
|| node instanceof AST_Expansion
|
11610
|
-
|
11611
|
-
|
11857
|
+
&& node.expression instanceof AST_Symbol
|
11858
|
+
&& (
|
11859
|
+
node.expression instanceof AST_This
|
11860
|
+
|| node.expression.definition().references.length > 1
|
11861
|
+
)
|
11612
11862
|
|| node instanceof AST_IterationStatement && !(node instanceof AST_For)
|
11613
11863
|
|| node instanceof AST_LoopControl
|
11614
11864
|
|| node instanceof AST_Try
|
@@ -12777,7 +13027,13 @@ function is_undefined(node, compressor) {
|
|
12777
13027
|
});
|
12778
13028
|
def_may_throw_on_access(AST_Dot, function(compressor) {
|
12779
13029
|
if (!is_strict(compressor)) return false;
|
12780
|
-
|
13030
|
+
|
13031
|
+
if (this.property == "prototype") {
|
13032
|
+
return !(
|
13033
|
+
this.expression instanceof AST_Function
|
13034
|
+
|| this.expression instanceof AST_Class
|
13035
|
+
);
|
13036
|
+
}
|
12781
13037
|
return true;
|
12782
13038
|
});
|
12783
13039
|
def_may_throw_on_access(AST_Chain, function(compressor) {
|
@@ -13624,7 +13880,7 @@ const pure_prop_access_globals = new Set([
|
|
13624
13880
|
def_has_side_effects(AST_ObjectProperty, function(compressor) {
|
13625
13881
|
return (
|
13626
13882
|
this.computed_key() && this.key.has_side_effects(compressor)
|
13627
|
-
|| this.value.has_side_effects(compressor)
|
13883
|
+
|| this.value && this.value.has_side_effects(compressor)
|
13628
13884
|
);
|
13629
13885
|
});
|
13630
13886
|
def_has_side_effects(AST_ClassProperty, function(compressor) {
|
@@ -13752,7 +14008,7 @@ const pure_prop_access_globals = new Set([
|
|
13752
14008
|
});
|
13753
14009
|
def_may_throw(AST_ObjectProperty, function(compressor) {
|
13754
14010
|
// TODO key may throw too
|
13755
|
-
return this.value.may_throw(compressor);
|
14011
|
+
return this.value ? this.value.may_throw(compressor) : false;
|
13756
14012
|
});
|
13757
14013
|
def_may_throw(AST_ClassProperty, function(compressor) {
|
13758
14014
|
return (
|
@@ -13886,7 +14142,7 @@ const pure_prop_access_globals = new Set([
|
|
13886
14142
|
return this.properties.every((l) => l.is_constant_expression());
|
13887
14143
|
});
|
13888
14144
|
def_is_constant_expression(AST_ObjectProperty, function() {
|
13889
|
-
return !(this.key instanceof AST_Node) && this.value.is_constant_expression();
|
14145
|
+
return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
|
13890
14146
|
});
|
13891
14147
|
})(function(node, func) {
|
13892
14148
|
node.DEFMETHOD("is_constant_expression", func);
|
@@ -14713,7 +14969,7 @@ AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
|
|
14713
14969
|
def_drop_side_effect_free(AST_ObjectProperty, function(compressor, first_in_statement) {
|
14714
14970
|
const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
|
14715
14971
|
const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
|
14716
|
-
const value = this.value.drop_side_effect_free(compressor, first_in_statement);
|
14972
|
+
const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
|
14717
14973
|
if (key && value) {
|
14718
14974
|
return make_sequence(this, [key, value]);
|
14719
14975
|
}
|
@@ -17971,13 +18227,13 @@ async function SourceMap(options) {
|
|
17971
18227
|
});
|
17972
18228
|
|
17973
18229
|
var orig_map;
|
17974
|
-
var generator = new
|
18230
|
+
var generator = new MOZ_SourceMap__default['default'].SourceMapGenerator({
|
17975
18231
|
file : options.file,
|
17976
18232
|
sourceRoot : options.root
|
17977
18233
|
});
|
17978
18234
|
|
17979
18235
|
if (options.orig) {
|
17980
|
-
orig_map = await new
|
18236
|
+
orig_map = await new MOZ_SourceMap__default['default'].SourceMapConsumer(options.orig);
|
17981
18237
|
orig_map.sources.forEach(function(source) {
|
17982
18238
|
var sourceContent = orig_map.sourceContentFor(source, true);
|
17983
18239
|
if (sourceContent) {
|
@@ -22142,6 +22398,7 @@ var domprops = [
|
|
22142
22398
|
"exponent",
|
22143
22399
|
"exponentialRampToValueAtTime",
|
22144
22400
|
"exportKey",
|
22401
|
+
"exports",
|
22145
22402
|
"extend",
|
22146
22403
|
"extensions",
|
22147
22404
|
"extentNode",
|
@@ -25925,7 +26182,10 @@ function mangle_properties(ast, options) {
|
|
25925
26182
|
if (!options.builtins) find_builtins(reserved);
|
25926
26183
|
|
25927
26184
|
var cname = -1;
|
26185
|
+
var cprivate = -1;
|
26186
|
+
|
25928
26187
|
var cache;
|
26188
|
+
var private_cache = new Map();
|
25929
26189
|
if (options.cache) {
|
25930
26190
|
cache = options.cache.props;
|
25931
26191
|
cache.forEach(function(mangled_name) {
|
@@ -25948,12 +26208,20 @@ function mangle_properties(ast, options) {
|
|
25948
26208
|
|
25949
26209
|
var names_to_mangle = new Set();
|
25950
26210
|
var unmangleable = new Set();
|
26211
|
+
var private_properties = new Set();
|
25951
26212
|
|
25952
26213
|
var keep_quoted_strict = options.keep_quoted === "strict";
|
25953
26214
|
|
25954
26215
|
// step 1: find candidates to mangle
|
25955
26216
|
ast.walk(new TreeWalker(function(node) {
|
25956
|
-
if (
|
26217
|
+
if (
|
26218
|
+
node instanceof AST_ClassPrivateProperty
|
26219
|
+
|| node instanceof AST_PrivateMethod
|
26220
|
+
) {
|
26221
|
+
private_properties.add(node.key.name);
|
26222
|
+
} else if (node instanceof AST_DotHash) {
|
26223
|
+
private_properties.add(node.property);
|
26224
|
+
} else if (node instanceof AST_ObjectKeyVal) {
|
25957
26225
|
if (typeof node.key == "string" &&
|
25958
26226
|
(!keep_quoted_strict || !node.quote)) {
|
25959
26227
|
add(node.key);
|
@@ -25990,7 +26258,14 @@ function mangle_properties(ast, options) {
|
|
25990
26258
|
|
25991
26259
|
// step 2: transform the tree, renaming properties
|
25992
26260
|
return ast.transform(new TreeTransformer(function(node) {
|
25993
|
-
if (
|
26261
|
+
if (
|
26262
|
+
node instanceof AST_ClassPrivateProperty
|
26263
|
+
|| node instanceof AST_PrivateMethod
|
26264
|
+
) {
|
26265
|
+
node.key.name = mangle_private(node.key.name);
|
26266
|
+
} else if (node instanceof AST_DotHash) {
|
26267
|
+
node.property = mangle_private(node.property);
|
26268
|
+
} else if (node instanceof AST_ObjectKeyVal) {
|
25994
26269
|
if (typeof node.key == "string" &&
|
25995
26270
|
(!keep_quoted_strict || !node.quote)) {
|
25996
26271
|
node.key = mangle(node.key);
|
@@ -26070,6 +26345,16 @@ function mangle_properties(ast, options) {
|
|
26070
26345
|
return mangled;
|
26071
26346
|
}
|
26072
26347
|
|
26348
|
+
function mangle_private(name) {
|
26349
|
+
let mangled = private_cache.get(name);
|
26350
|
+
if (!mangled) {
|
26351
|
+
mangled = base54(++cprivate);
|
26352
|
+
private_cache.set(name, mangled);
|
26353
|
+
}
|
26354
|
+
|
26355
|
+
return mangled;
|
26356
|
+
}
|
26357
|
+
|
26073
26358
|
function mangleStrings(node) {
|
26074
26359
|
return node.transform(new TreeTransformer(function(node) {
|
26075
26360
|
if (node instanceof AST_Sequence) {
|
@@ -26352,7 +26637,7 @@ async function run_cli({ program, packageJson, fs, path }) {
|
|
26352
26637
|
program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
|
26353
26638
|
program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
|
26354
26639
|
program.option("-f, --format [options]", "Format options.", parse_js());
|
26355
|
-
program.option("-b, --beautify [options]", "Alias for --format
|
26640
|
+
program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
|
26356
26641
|
program.option("-o, --output <file>", "Output file (default STDOUT).");
|
26357
26642
|
program.option("--comments [filter]", "Preserve copyright comments in the output.");
|
26358
26643
|
program.option("--config-file <file>", "Read minify() options from JSON file.");
|
@@ -26403,19 +26688,9 @@ async function run_cli({ program, packageJson, fs, path }) {
|
|
26403
26688
|
else
|
26404
26689
|
options.ecma = ecma;
|
26405
26690
|
}
|
26406
|
-
if (program.
|
26407
|
-
|
26408
|
-
|
26409
|
-
}
|
26410
|
-
if (program.beautify) {
|
26411
|
-
options.format = typeof program.beautify == "object" ? program.beautify : {};
|
26412
|
-
if (!("beautify" in options.format)) {
|
26413
|
-
options.format.beautify = true;
|
26414
|
-
}
|
26415
|
-
}
|
26416
|
-
if (program.format) {
|
26417
|
-
options.format = typeof program.format == "object" ? program.format : {};
|
26418
|
-
}
|
26691
|
+
if (program.format || program.beautify) {
|
26692
|
+
const chosenOption = program.format || program.beautify;
|
26693
|
+
options.format = typeof chosenOption === "object" ? chosenOption : {};
|
26419
26694
|
}
|
26420
26695
|
if (program.comments) {
|
26421
26696
|
if (typeof options.format != "object") options.format = {};
|