terser 3.10.4 → 3.10.8
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/dist/bundle.js +15 -7
- package/dist/bundle.js.map +1 -1
- package/lib/compress.js +20 -4
- package/lib/scope.js +7 -7
- package/lib/utils.js +5 -0
- package/package.json +3 -2
- package/tools/node.js +5 -3
- package/dist/.coverage.lock +0 -0
- package/dist/bundle.instrumented.js +0 -9
package/lib/compress.js
CHANGED
@@ -3430,10 +3430,12 @@ merge(Compressor.prototype, {
|
|
3430
3430
|
}
|
3431
3431
|
}
|
3432
3432
|
if (scope !== self) return;
|
3433
|
+
var def;
|
3433
3434
|
if (node.name
|
3434
|
-
&& (
|
3435
|
-
|
3436
|
-
|
3435
|
+
&& (node instanceof AST_ClassExpression
|
3436
|
+
&& !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
|
3437
|
+
|| node instanceof AST_Function
|
3438
|
+
&& !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
|
3437
3439
|
// any declarations with same name will overshadow
|
3438
3440
|
// name of this anonymous function and can therefore
|
3439
3441
|
// never be used anywhere
|
@@ -4172,8 +4174,22 @@ merge(Compressor.prototype, {
|
|
4172
4174
|
}
|
4173
4175
|
}
|
4174
4176
|
|
4177
|
+
function use_increment(self) {
|
4178
|
+
if (self.step instanceof AST_Assign
|
4179
|
+
&& self.step.operator === "+="
|
4180
|
+
&& self.step.left instanceof AST_Symbol
|
4181
|
+
&& self.step.right.print_to_string() === "1"
|
4182
|
+
) {
|
4183
|
+
self.step = make_node(AST_UnaryPrefix, self.step, {
|
4184
|
+
operator: "++",
|
4185
|
+
expression: self.step.left
|
4186
|
+
});
|
4187
|
+
}
|
4188
|
+
}
|
4189
|
+
|
4175
4190
|
OPT(AST_For, function(self, compressor) {
|
4176
4191
|
if (!compressor.option("loops")) return self;
|
4192
|
+
use_increment(self);
|
4177
4193
|
if (compressor.option("side_effects") && self.init) {
|
4178
4194
|
self.init = self.init.drop_side_effect_free(compressor);
|
4179
4195
|
}
|
@@ -5031,7 +5047,7 @@ merge(Compressor.prototype, {
|
|
5031
5047
|
if (value) expressions.push(make_node(AST_Assign, self, {
|
5032
5048
|
operator: "=",
|
5033
5049
|
left: sym,
|
5034
|
-
right: value
|
5050
|
+
right: value.clone(true)
|
5035
5051
|
}));
|
5036
5052
|
}
|
5037
5053
|
|
package/lib/scope.js
CHANGED
@@ -68,13 +68,11 @@ SymbolDef.prototype = {
|
|
68
68
|
|| this.export
|
69
69
|
|| this.undeclared
|
70
70
|
|| !options.eval && this.scope.pinned()
|
71
|
-
|| (
|
72
|
-
|
73
|
-
|| this.orig[0] instanceof AST_SymbolDefun)
|
71
|
+
|| (this.orig[0] instanceof AST_SymbolLambda
|
72
|
+
|| this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
|
74
73
|
|| this.orig[0] instanceof AST_SymbolMethod
|
75
|
-
|| (
|
76
|
-
|
77
|
-
|| this.orig[0] instanceof AST_SymbolDefClass);
|
74
|
+
|| (this.orig[0] instanceof AST_SymbolClass
|
75
|
+
|| this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
|
78
76
|
},
|
79
77
|
mangle: function(options) {
|
80
78
|
var cache = options.cache && options.cache.props;
|
@@ -387,7 +385,9 @@ AST_Symbol.DEFMETHOD("mark_enclosed", function(options) {
|
|
387
385
|
push_uniq(s.enclosed, def);
|
388
386
|
if (options.keep_fnames) {
|
389
387
|
s.functions.each(function(d) {
|
390
|
-
|
388
|
+
if (keep_name(options.keep_fnames, d.name)) {
|
389
|
+
push_uniq(def.scope.enclosed, d);
|
390
|
+
}
|
391
391
|
});
|
392
392
|
}
|
393
393
|
if (s === def.scope) break;
|
package/lib/utils.js
CHANGED
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.8",
|
8
8
|
"engines": {
|
9
9
|
"node": ">=0.8.0"
|
10
10
|
},
|
@@ -22,6 +22,7 @@
|
|
22
22
|
"bin",
|
23
23
|
"lib",
|
24
24
|
"dist",
|
25
|
+
"!dist/bundle.instrumented.js",
|
25
26
|
"tools",
|
26
27
|
"LICENSE"
|
27
28
|
],
|
@@ -38,7 +39,7 @@
|
|
38
39
|
"eslint": "^4.19.1",
|
39
40
|
"istanbul": "^0.4.5",
|
40
41
|
"mocha": "^3.0.0",
|
41
|
-
"mochallel": "^1.7.
|
42
|
+
"mochallel": "^1.7.9",
|
42
43
|
"multiprocess-map": "^1.4.2",
|
43
44
|
"pre-commit": "^1.2.2",
|
44
45
|
"semver": "~5.5.0"
|
package/tools/node.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
var fs = require("fs");
|
2
|
-
var istanbul = require("istanbul");
|
3
2
|
|
4
3
|
var UglifyJS = exports;
|
5
4
|
var FILES = UglifyJS.FILES = [
|
@@ -19,12 +18,15 @@ var FILES = UglifyJS.FILES = [
|
|
19
18
|
return require.resolve(file);
|
20
19
|
});
|
21
20
|
|
22
|
-
|
21
|
+
try {
|
22
|
+
var istanbul = require("istanbul");
|
23
|
+
var instrumenter = new istanbul.Instrumenter();
|
24
|
+
} catch (ex) {}
|
23
25
|
|
24
26
|
new Function("MOZ_SourceMap", "exports", function() {
|
25
27
|
var code = FILES.map(function(file) {
|
26
28
|
var contents = fs.readFileSync(file, "utf8");
|
27
|
-
if (global.__IS_TESTING__) return instrumenter.instrumentSync(contents, file);
|
29
|
+
if (instrumenter && global.__IS_TESTING__) return instrumenter.instrumentSync(contents, file);
|
28
30
|
return contents;
|
29
31
|
});
|
30
32
|
return code.join("\n\n");
|
package/dist/.coverage.lock
DELETED
File without changes
|