terser 3.10.1 → 3.10.2
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.
Potentially problematic release.
This version of terser might be problematic. Click here for more details.
- package/bin/uglifyjs +42 -10
- package/dist/bundle.js +25 -16
- package/dist/bundle.js.map +1 -1
- package/lib/ast.js +1 -1
- package/lib/compress.js +10 -3
- package/lib/output.js +6 -4
- package/lib/parse.js +14 -7
- package/lib/transform.js +1 -1
- package/package.json +4 -3
- package/tools/exports.js +1 -0
- package/tools/node.js +0 -36
- package/dist/exports.js +0 -6
package/bin/uglifyjs
CHANGED
@@ -11,16 +11,13 @@ var path = require("path");
|
|
11
11
|
var program = require("commander");
|
12
12
|
|
13
13
|
var bundle_path = __dirname + "/../dist/bundle.js";
|
14
|
-
if (
|
15
|
-
/* note: commander not initialized yet */
|
16
|
-
&& !/--help/.test(process.argv.toString())
|
17
|
-
&& fs.existsSync(bundle_path)) {
|
18
|
-
var UglifyJS = require(bundle_path);
|
19
|
-
try {
|
20
|
-
require("source-map-support").install();
|
21
|
-
} catch (err) {}
|
22
|
-
} else if (fs.existsSync(bundle_path)) {
|
14
|
+
if (fs.existsSync(bundle_path)) {
|
23
15
|
var UglifyJS = require(bundle_path)
|
16
|
+
if (process.env.TERSER_DEBUG) {
|
17
|
+
try {
|
18
|
+
require("source-map-support").install();
|
19
|
+
} catch (err) {}
|
20
|
+
}
|
24
21
|
} else {
|
25
22
|
var UglifyJS = require("../tools/node.js");
|
26
23
|
}
|
@@ -34,7 +31,7 @@ var options = {
|
|
34
31
|
program.version(info.name + " " + info.version);
|
35
32
|
program.parseArgv = program.parse;
|
36
33
|
program.parse = undefined;
|
37
|
-
if (process.argv.indexOf("ast") >= 0) program.helpInformation =
|
34
|
+
if (process.argv.indexOf("ast") >= 0) program.helpInformation = describe_ast;
|
38
35
|
else if (process.argv.indexOf("options") >= 0) program.helpInformation = function() {
|
39
36
|
var text = [];
|
40
37
|
var options = UglifyJS.default_options();
|
@@ -447,3 +444,38 @@ function print(txt) {
|
|
447
444
|
process.stdout.write(txt);
|
448
445
|
process.stdout.write("\n");
|
449
446
|
}
|
447
|
+
|
448
|
+
function describe_ast() {
|
449
|
+
var out = UglifyJS.OutputStream({ beautify: true });
|
450
|
+
function doitem(ctor) {
|
451
|
+
out.print("AST_" + ctor.TYPE);
|
452
|
+
var props = ctor.SELF_PROPS.filter(function(prop){
|
453
|
+
return !/^\$/.test(prop);
|
454
|
+
});
|
455
|
+
if (props.length > 0) {
|
456
|
+
out.space();
|
457
|
+
out.with_parens(function(){
|
458
|
+
props.forEach(function(prop, i){
|
459
|
+
if (i) out.space();
|
460
|
+
out.print(prop);
|
461
|
+
});
|
462
|
+
});
|
463
|
+
}
|
464
|
+
if (ctor.documentation) {
|
465
|
+
out.space();
|
466
|
+
out.print_string(ctor.documentation);
|
467
|
+
}
|
468
|
+
if (ctor.SUBCLASSES.length > 0) {
|
469
|
+
out.space();
|
470
|
+
out.with_block(function(){
|
471
|
+
ctor.SUBCLASSES.forEach(function(ctor, i){
|
472
|
+
out.indent();
|
473
|
+
doitem(ctor);
|
474
|
+
out.newline();
|
475
|
+
});
|
476
|
+
});
|
477
|
+
}
|
478
|
+
};
|
479
|
+
doitem(UglifyJS.AST_Node);
|
480
|
+
return out + "\n";
|
481
|
+
}
|
package/dist/bundle.js
CHANGED
@@ -763,7 +763,7 @@
|
|
763
763
|
},
|
764
764
|
_walk: function(visitor) {
|
765
765
|
return visitor._visit(this, function() {
|
766
|
-
this.argname._walk(visitor);
|
766
|
+
if (this.argname) this.argname._walk(visitor);
|
767
767
|
walk_body(this, visitor);
|
768
768
|
});
|
769
769
|
}
|
@@ -1516,7 +1516,7 @@
|
|
1516
1516
|
var valid = parse_js_number(num);
|
1517
1517
|
if (!isNaN(valid)) return token("num", valid); else parse_error("Invalid syntax: " + num);
|
1518
1518
|
}
|
1519
|
-
function read_escaped_char(in_string) {
|
1519
|
+
function read_escaped_char(in_string, template_string) {
|
1520
1520
|
var ch = next(true, in_string);
|
1521
1521
|
switch (ch.charCodeAt(0)) {
|
1522
1522
|
case 110:
|
@@ -1550,7 +1550,7 @@
|
|
1550
1550
|
next(true);
|
1551
1551
|
return from_char_code(result);
|
1552
1552
|
}
|
1553
|
-
return String.fromCharCode(hex_bytes(4));
|
1553
|
+
return String.fromCharCode(hex_bytes(4, template_string));
|
1554
1554
|
|
1555
1555
|
case 10:
|
1556
1556
|
return "";
|
@@ -1574,9 +1574,10 @@
|
|
1574
1574
|
if (ch.length > 0 && next_token.has_directive("use strict")) parse_error("Legacy octal escape sequences are not allowed in strict mode");
|
1575
1575
|
return String.fromCharCode(parseInt(ch, 8));
|
1576
1576
|
}
|
1577
|
-
function hex_bytes(n) {
|
1577
|
+
function hex_bytes(n, abrupt_ending) {
|
1578
1578
|
var num = 0;
|
1579
1579
|
for (;n > 0; --n) {
|
1580
|
+
if (abrupt_ending && isNaN(parseInt(peek(), 16))) return num || "";
|
1580
1581
|
var digit = parseInt(next(true), 16);
|
1581
1582
|
if (isNaN(digit)) parse_error("Invalid hex-character pattern in string");
|
1582
1583
|
num = num << 4 | digit;
|
@@ -1614,7 +1615,7 @@
|
|
1614
1615
|
raw += ch;
|
1615
1616
|
if ("\\" == ch) {
|
1616
1617
|
var tmp = S.pos;
|
1617
|
-
ch = read_escaped_char(true);
|
1618
|
+
ch = read_escaped_char(true, true);
|
1618
1619
|
raw += S.text.substr(tmp, S.pos - tmp);
|
1619
1620
|
}
|
1620
1621
|
content += ch;
|
@@ -2640,9 +2641,11 @@
|
|
2640
2641
|
if (is("keyword", "catch")) {
|
2641
2642
|
var start = S.token;
|
2642
2643
|
next();
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2644
|
+
if (is("punc", "{")) var name = null; else {
|
2645
|
+
expect("(");
|
2646
|
+
var name = parameter(void 0, AST_SymbolCatch);
|
2647
|
+
expect(")");
|
2648
|
+
}
|
2646
2649
|
bcatch = new AST_Catch({
|
2647
2650
|
start: start,
|
2648
2651
|
argname: name,
|
@@ -3662,7 +3665,7 @@
|
|
3662
3665
|
if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
|
3663
3666
|
});
|
3664
3667
|
_(AST_Catch, function(self, tw) {
|
3665
|
-
self.argname = self.argname.transform(tw);
|
3668
|
+
if (self.argname) self.argname = self.argname.transform(tw);
|
3666
3669
|
self.body = do_list(self.body, tw);
|
3667
3670
|
});
|
3668
3671
|
_(AST_Definitions, function(self, tw) {
|
@@ -5208,10 +5211,12 @@
|
|
5208
5211
|
});
|
5209
5212
|
DEFPRINT(AST_Catch, function(self, output) {
|
5210
5213
|
output.print("catch");
|
5211
|
-
|
5212
|
-
|
5213
|
-
|
5214
|
-
|
5214
|
+
if (self.argname) {
|
5215
|
+
output.space();
|
5216
|
+
output.with_parens(function() {
|
5217
|
+
self.argname.print(output);
|
5218
|
+
});
|
5219
|
+
}
|
5215
5220
|
output.space();
|
5216
5221
|
print_braced(self, output);
|
5217
5222
|
});
|
@@ -6273,7 +6278,7 @@
|
|
6273
6278
|
var scope, i = 0;
|
6274
6279
|
while (scope = compressor.parent(i++)) {
|
6275
6280
|
if (scope instanceof AST_Scope) break;
|
6276
|
-
if (scope instanceof AST_Catch) {
|
6281
|
+
if (scope instanceof AST_Catch && scope.argname) {
|
6277
6282
|
scope = scope.argname.definition().scope;
|
6278
6283
|
break;
|
6279
6284
|
}
|
@@ -9404,7 +9409,8 @@
|
|
9404
9409
|
if (can_inline && stat instanceof AST_Return && is_regular_func) {
|
9405
9410
|
var value = stat.value;
|
9406
9411
|
if (!value || value.is_constant_expression()) {
|
9407
|
-
|
9412
|
+
if (value) value = value.clone(true); else value = make_node(AST_Undefined, self);
|
9413
|
+
var args = self.args.concat(value);
|
9408
9414
|
return make_sequence(self, args).optimize(compressor);
|
9409
9415
|
}
|
9410
9416
|
}
|
@@ -9496,7 +9502,9 @@
|
|
9496
9502
|
if (scope.is_block_scope() && !(compressor.parent(level - 1) instanceof AST_Scope)) if (scope.block_scope) scope.block_scope.variables.each(function(variable) {
|
9497
9503
|
block_scoped[variable.name] = true;
|
9498
9504
|
});
|
9499
|
-
if (scope instanceof AST_Catch)
|
9505
|
+
if (scope instanceof AST_Catch) {
|
9506
|
+
if (scope.argname) block_scoped[scope.argname.name] = true;
|
9507
|
+
} else if (scope instanceof AST_IterationStatement) in_loop = []; else if (scope instanceof AST_SymbolRef) if (scope.fixed_value() instanceof AST_Scope) return false;
|
9500
9508
|
} while (!(scope instanceof AST_Scope) || scope instanceof AST_Arrow);
|
9501
9509
|
var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
|
9502
9510
|
var inline = compressor.option("inline");
|
@@ -11993,6 +12001,7 @@
|
|
11993
12001
|
exports["minify"] = minify;
|
11994
12002
|
exports["parse"] = parse;
|
11995
12003
|
exports["push_uniq"] = push_uniq;
|
12004
|
+
exports["OutputStream"] = OutputStream;
|
11996
12005
|
exports["TreeTransformer"] = TreeTransformer;
|
11997
12006
|
exports["TreeWalker"] = TreeWalker;
|
11998
12007
|
})("undefined" != typeof module ? module.exports : Terser = {});
|