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/dist/bundle.js
CHANGED
@@ -292,6 +292,9 @@
|
|
292
292
|
if (p instanceof AST_Sequence && p.expressions[0] === node || "Call" == p.TYPE && p.expression === node || p instanceof AST_Dot && p.expression === node || p instanceof AST_Sub && p.expression === node || p instanceof AST_Conditional && p.condition === node || p instanceof AST_Binary && p.left === node || p instanceof AST_UnaryPostfix && p.expression === node) node = p; else return false;
|
293
293
|
}
|
294
294
|
}
|
295
|
+
function keep_name(keep_setting, name) {
|
296
|
+
return true === keep_setting || keep_setting instanceof RegExp && keep_setting.test(name);
|
297
|
+
}
|
295
298
|
function DEFNODE(type, props, methods, base) {
|
296
299
|
if (arguments.length < 4) base = AST_Node;
|
297
300
|
if (!props) props = []; else props = props.split(/\s+/);
|
@@ -3780,7 +3783,7 @@
|
|
3780
3783
|
SymbolDef.prototype = {
|
3781
3784
|
unmangleable: function(options) {
|
3782
3785
|
if (!options) options = {};
|
3783
|
-
return this.global && !options.toplevel || this.export || this.undeclared || !options.eval && this.scope.pinned() || (
|
3786
|
+
return this.global && !options.toplevel || this.export || this.undeclared || !options.eval && this.scope.pinned() || (this.orig[0] instanceof AST_SymbolLambda || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name) || this.orig[0] instanceof AST_SymbolMethod || (this.orig[0] instanceof AST_SymbolClass || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
|
3784
3787
|
},
|
3785
3788
|
mangle: function(options) {
|
3786
3789
|
var cache = options.cache && options.cache.props;
|
@@ -3994,7 +3997,7 @@
|
|
3994
3997
|
while (s) {
|
3995
3998
|
push_uniq(s.enclosed, def);
|
3996
3999
|
if (options.keep_fnames) s.functions.each(function(d) {
|
3997
|
-
push_uniq(def.scope.enclosed, d);
|
4000
|
+
if (keep_name(options.keep_fnames, d.name)) push_uniq(def.scope.enclosed, d);
|
3998
4001
|
});
|
3999
4002
|
if (s === def.scope) break;
|
4000
4003
|
s = s.parent_scope;
|
@@ -8278,10 +8281,8 @@
|
|
8278
8281
|
}
|
8279
8282
|
}
|
8280
8283
|
if (scope !== self) return;
|
8281
|
-
|
8282
|
-
|
8283
|
-
if (!(def.id in in_use_ids) || def.orig.length > 1) node.name = null;
|
8284
|
-
}
|
8284
|
+
var def;
|
8285
|
+
if (node.name && (node instanceof AST_ClassExpression && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name) || node instanceof AST_Function && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) if (!(def.id in in_use_ids) || def.orig.length > 1) node.name = null;
|
8285
8286
|
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
8286
8287
|
var trim = !compressor.option("keep_fargs");
|
8287
8288
|
for (var a = node.argnames, i = a.length; --i >= 0; ) {
|
@@ -8870,8 +8871,15 @@
|
|
8870
8871
|
self = if_break_in_loop(self, compressor);
|
8871
8872
|
}
|
8872
8873
|
}
|
8874
|
+
function use_increment(self) {
|
8875
|
+
if (self.step instanceof AST_Assign && "+=" === self.step.operator && self.step.left instanceof AST_Symbol && "1" === self.step.right.print_to_string()) self.step = make_node(AST_UnaryPrefix, self.step, {
|
8876
|
+
operator: "++",
|
8877
|
+
expression: self.step.left
|
8878
|
+
});
|
8879
|
+
}
|
8873
8880
|
OPT(AST_For, function(self, compressor) {
|
8874
8881
|
if (!compressor.option("loops")) return self;
|
8882
|
+
use_increment(self);
|
8875
8883
|
if (compressor.option("side_effects") && self.init) self.init = self.init.drop_side_effect_free(compressor);
|
8876
8884
|
if (self.condition) {
|
8877
8885
|
var cond = self.condition.evaluate(compressor);
|
@@ -9547,7 +9555,7 @@
|
|
9547
9555
|
if (value) expressions.push(make_node(AST_Assign, self, {
|
9548
9556
|
operator: "=",
|
9549
9557
|
left: sym,
|
9550
|
-
right: value
|
9558
|
+
right: value.clone(true)
|
9551
9559
|
}));
|
9552
9560
|
}
|
9553
9561
|
function flatten_args(decls, expressions) {
|