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/lib/ast.js
CHANGED
@@ -627,7 +627,7 @@ var AST_Catch = DEFNODE("Catch", "argname", {
|
|
627
627
|
},
|
628
628
|
_walk: function(visitor) {
|
629
629
|
return visitor._visit(this, function() {
|
630
|
-
this.argname._walk(visitor);
|
630
|
+
if (this.argname) this.argname._walk(visitor);
|
631
631
|
walk_body(this, visitor);
|
632
632
|
});
|
633
633
|
}
|
package/lib/compress.js
CHANGED
@@ -893,7 +893,7 @@ merge(Compressor.prototype, {
|
|
893
893
|
var scope, i = 0;
|
894
894
|
while (scope = compressor.parent(i++)) {
|
895
895
|
if (scope instanceof AST_Scope) break;
|
896
|
-
if (scope instanceof AST_Catch) {
|
896
|
+
if (scope instanceof AST_Catch && scope.argname) {
|
897
897
|
scope = scope.argname.definition().scope;
|
898
898
|
break;
|
899
899
|
}
|
@@ -4833,7 +4833,12 @@ merge(Compressor.prototype, {
|
|
4833
4833
|
if (can_inline && stat instanceof AST_Return && is_regular_func) {
|
4834
4834
|
var value = stat.value;
|
4835
4835
|
if (!value || value.is_constant_expression()) {
|
4836
|
-
|
4836
|
+
if (value) {
|
4837
|
+
value = value.clone(true);
|
4838
|
+
} else {
|
4839
|
+
value = make_node(AST_Undefined, self);
|
4840
|
+
}
|
4841
|
+
var args = self.args.concat(value);
|
4837
4842
|
return make_sequence(self, args).optimize(compressor);
|
4838
4843
|
}
|
4839
4844
|
}
|
@@ -4984,7 +4989,9 @@ merge(Compressor.prototype, {
|
|
4984
4989
|
}
|
4985
4990
|
}
|
4986
4991
|
if (scope instanceof AST_Catch) {
|
4987
|
-
|
4992
|
+
if (scope.argname) {
|
4993
|
+
block_scoped[scope.argname.name] = true;
|
4994
|
+
}
|
4988
4995
|
} else if (scope instanceof AST_IterationStatement) {
|
4989
4996
|
in_loop = [];
|
4990
4997
|
} else if (scope instanceof AST_SymbolRef) {
|
package/lib/output.js
CHANGED
@@ -1320,10 +1320,12 @@ function OutputStream(options) {
|
|
1320
1320
|
});
|
1321
1321
|
DEFPRINT(AST_Catch, function(self, output) {
|
1322
1322
|
output.print("catch");
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1323
|
+
if (self.argname) {
|
1324
|
+
output.space();
|
1325
|
+
output.with_parens(function() {
|
1326
|
+
self.argname.print(output);
|
1327
|
+
});
|
1328
|
+
}
|
1327
1329
|
output.space();
|
1328
1330
|
print_braced(self, output);
|
1329
1331
|
});
|
package/lib/parse.js
CHANGED
@@ -420,7 +420,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|
420
420
|
}
|
421
421
|
}
|
422
422
|
|
423
|
-
function read_escaped_char(in_string) {
|
423
|
+
function read_escaped_char(in_string, template_string) {
|
424
424
|
var ch = next(true, in_string);
|
425
425
|
switch (ch.charCodeAt(0)) {
|
426
426
|
case 110 : return "\n";
|
@@ -445,7 +445,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|
445
445
|
next(true);
|
446
446
|
return from_char_code(result);
|
447
447
|
}
|
448
|
-
return String.fromCharCode(hex_bytes(4));
|
448
|
+
return String.fromCharCode(hex_bytes(4, template_string));
|
449
449
|
case 10 : return ""; // newline
|
450
450
|
case 13 : // \r
|
451
451
|
if (peek() == "\n") { // DOS newline
|
@@ -474,9 +474,12 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|
474
474
|
return String.fromCharCode(parseInt(ch, 8));
|
475
475
|
}
|
476
476
|
|
477
|
-
function hex_bytes(n) {
|
477
|
+
function hex_bytes(n, abrupt_ending) {
|
478
478
|
var num = 0;
|
479
479
|
for (; n > 0; --n) {
|
480
|
+
if (abrupt_ending && isNaN(parseInt(peek(), 16))) {
|
481
|
+
return num || "";
|
482
|
+
}
|
480
483
|
var digit = parseInt(next(true), 16);
|
481
484
|
if (isNaN(digit))
|
482
485
|
parse_error("Invalid hex-character pattern in string");
|
@@ -522,7 +525,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|
522
525
|
raw += ch;
|
523
526
|
if (ch == "\\") {
|
524
527
|
var tmp = S.pos;
|
525
|
-
ch = read_escaped_char(true);
|
528
|
+
ch = read_escaped_char(true, true);
|
526
529
|
raw += S.text.substr(tmp, S.pos - tmp);
|
527
530
|
}
|
528
531
|
|
@@ -1847,9 +1850,13 @@ function parse($TEXT, options) {
|
|
1847
1850
|
if (is("keyword", "catch")) {
|
1848
1851
|
var start = S.token;
|
1849
1852
|
next();
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
+
if (is("punc", "{")) {
|
1854
|
+
var name = null;
|
1855
|
+
} else {
|
1856
|
+
expect("(");
|
1857
|
+
var name = parameter(undefined, AST_SymbolCatch);
|
1858
|
+
expect(")");
|
1859
|
+
}
|
1853
1860
|
bcatch = new AST_Catch({
|
1854
1861
|
start : start,
|
1855
1862
|
argname : name,
|
package/lib/transform.js
CHANGED
@@ -152,7 +152,7 @@ TreeTransformer.prototype = new TreeWalker;
|
|
152
152
|
});
|
153
153
|
|
154
154
|
_(AST_Catch, function(self, tw) {
|
155
|
-
self.argname = self.argname.transform(tw);
|
155
|
+
if (self.argname) self.argname = self.argname.transform(tw);
|
156
156
|
self.body = do_list(self.body, tw);
|
157
157
|
});
|
158
158
|
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"homepage": "https://github.com/fabiosantoscode/terser",
|
5
5
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
6
6
|
"license": "BSD-2-Clause",
|
7
|
-
"version": "3.10.
|
7
|
+
"version": "3.10.2",
|
8
8
|
"engines": {
|
9
9
|
"node": ">=0.8.0"
|
10
10
|
},
|
@@ -37,16 +37,17 @@
|
|
37
37
|
"eslint": "^4.19.1",
|
38
38
|
"istanbul": "^0.4.5",
|
39
39
|
"mocha": "^3.0.0",
|
40
|
+
"mochallel": "^1.6.8",
|
40
41
|
"pre-commit": "^1.2.2",
|
41
42
|
"semver": "~5.5.0"
|
42
43
|
},
|
43
44
|
"scripts": {
|
44
|
-
"test": "node test/run-tests.js",
|
45
|
+
"test": "rm -f dist/* && npm run prepublish && node test/run-tests.js",
|
45
46
|
"coverage": "istanbul cover test/run-tests.js",
|
46
47
|
"coveralls": "coveralls < coverage/lcov.info",
|
47
48
|
"lint": "eslint lib",
|
48
49
|
"lint-fix": "eslint --fix lib",
|
49
|
-
"prepublish": "node bin/uglifyjs lib/utils.js lib/ast.js lib/parse.js lib/transform.js lib/scope.js lib/output.js lib/compress.js lib/sourcemap.js lib/mozilla-ast.js lib/propmangle.js lib/minify.js tools/exports.js -c defaults=false -d \"MOZ_SourceMap=require('source-map')\" --source-map \"includeSources=true,url='bundle.js.map'\" -e \"exports:(typeof module != 'undefined' ? module.exports : Terser = {})\" -b ascii_only --comments /license/ -o dist/bundle.js
|
50
|
+
"prepublish": "cd dist && node ../bin/uglifyjs ../lib/utils.js ../lib/ast.js ../lib/parse.js ../lib/transform.js ../lib/scope.js ../lib/output.js ../lib/compress.js ../lib/sourcemap.js ../lib/mozilla-ast.js ../lib/propmangle.js ../lib/minify.js ../tools/exports.js -c defaults=false -d \"MOZ_SourceMap=require('source-map')\" --source-map \"includeSources=true,url='bundle.js.map'\" -e \"exports:(typeof module != 'undefined' ? module.exports : Terser = {})\" -b ascii_only --comments /license/ -o ../dist/bundle.js"
|
50
51
|
},
|
51
52
|
"keywords": [
|
52
53
|
"uglify",
|
package/tools/exports.js
CHANGED
package/tools/node.js
CHANGED
@@ -27,48 +27,12 @@ new Function("MOZ_SourceMap", "exports", function() {
|
|
27
27
|
if (global.__IS_TESTING__) return instrumenter.instrumentSync(contents, file);
|
28
28
|
return contents;
|
29
29
|
});
|
30
|
-
code.push("exports.describe_ast = " + describe_ast.toString());
|
31
30
|
return code.join("\n\n");
|
32
31
|
}())(
|
33
32
|
require("source-map"),
|
34
33
|
UglifyJS
|
35
34
|
);
|
36
35
|
|
37
|
-
function describe_ast() {
|
38
|
-
var out = OutputStream({ beautify: true });
|
39
|
-
function doitem(ctor) {
|
40
|
-
out.print("AST_" + ctor.TYPE);
|
41
|
-
var props = ctor.SELF_PROPS.filter(function(prop){
|
42
|
-
return !/^\$/.test(prop);
|
43
|
-
});
|
44
|
-
if (props.length > 0) {
|
45
|
-
out.space();
|
46
|
-
out.with_parens(function(){
|
47
|
-
props.forEach(function(prop, i){
|
48
|
-
if (i) out.space();
|
49
|
-
out.print(prop);
|
50
|
-
});
|
51
|
-
});
|
52
|
-
}
|
53
|
-
if (ctor.documentation) {
|
54
|
-
out.space();
|
55
|
-
out.print_string(ctor.documentation);
|
56
|
-
}
|
57
|
-
if (ctor.SUBCLASSES.length > 0) {
|
58
|
-
out.space();
|
59
|
-
out.with_block(function(){
|
60
|
-
ctor.SUBCLASSES.forEach(function(ctor, i){
|
61
|
-
out.indent();
|
62
|
-
doitem(ctor);
|
63
|
-
out.newline();
|
64
|
-
});
|
65
|
-
});
|
66
|
-
}
|
67
|
-
};
|
68
|
-
doitem(AST_Node);
|
69
|
-
return out + "\n";
|
70
|
-
}
|
71
|
-
|
72
36
|
function infer_options(options) {
|
73
37
|
var result = UglifyJS.minify("", options);
|
74
38
|
return result.error && result.error.defs;
|