terser 5.19.4 → 5.20.0
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 +6 -0
- package/README.md +3 -4
- package/dist/bundle.min.js +261 -19
- package/lib/compress/index.js +24 -13
- package/lib/minify.js +3 -0
- package/lib/mozilla-ast.js +3 -5
- package/package.json +1 -1
- package/tools/domprops.js +231 -1
- package/tools/terser.d.ts +4 -1
- package/bin/terser.mjs +0 -18
package/lib/compress/index.js
CHANGED
@@ -385,7 +385,7 @@ class Compressor extends TreeWalker {
|
|
385
385
|
this._toplevel.figure_out_scope(mangle);
|
386
386
|
if (pass === 0 && this.option("drop_console")) {
|
387
387
|
// must be run before reduce_vars and compress pass
|
388
|
-
this._toplevel = this._toplevel.drop_console();
|
388
|
+
this._toplevel = this._toplevel.drop_console(this.option("drop_console"));
|
389
389
|
}
|
390
390
|
if (pass > 0 || this.option("reduce_vars")) {
|
391
391
|
this._toplevel.reset_opt_flags(this);
|
@@ -464,19 +464,30 @@ def_optimize(AST_Node, function(self) {
|
|
464
464
|
return self;
|
465
465
|
});
|
466
466
|
|
467
|
-
AST_Toplevel.DEFMETHOD("drop_console", function() {
|
467
|
+
AST_Toplevel.DEFMETHOD("drop_console", function(options) {
|
468
|
+
var isArray = Array.isArray(options);
|
469
|
+
|
468
470
|
return this.transform(new TreeTransformer(function(self) {
|
469
|
-
if (self.TYPE
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
471
|
+
if (self.TYPE !== "Call") {
|
472
|
+
return;
|
473
|
+
}
|
474
|
+
|
475
|
+
var exp = self.expression;
|
476
|
+
|
477
|
+
if (!(exp instanceof AST_PropAccess)) {
|
478
|
+
return;
|
479
|
+
}
|
480
|
+
|
481
|
+
if (isArray && options.indexOf(exp.property) === -1) {
|
482
|
+
return;
|
483
|
+
}
|
484
|
+
|
485
|
+
var name = exp.expression;
|
486
|
+
while (name.expression) {
|
487
|
+
name = name.expression;
|
488
|
+
}
|
489
|
+
if (is_undeclared_ref(name) && name.name == "console") {
|
490
|
+
return make_node(AST_Undefined, self);
|
480
491
|
}
|
481
492
|
}));
|
482
493
|
});
|
package/lib/minify.js
CHANGED
package/lib/mozilla-ast.js
CHANGED
@@ -166,17 +166,15 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
166
166
|
(function() {
|
167
167
|
|
168
168
|
var normalize_directives = function(body) {
|
169
|
-
var in_directive = true;
|
170
|
-
|
171
169
|
for (var i = 0; i < body.length; i++) {
|
172
|
-
if (
|
170
|
+
if (body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
|
173
171
|
body[i] = new AST_Directive({
|
174
172
|
start: body[i].start,
|
175
173
|
end: body[i].end,
|
176
174
|
value: body[i].body.value
|
177
175
|
});
|
178
|
-
} else
|
179
|
-
|
176
|
+
} else {
|
177
|
+
return body;
|
180
178
|
}
|
181
179
|
}
|
182
180
|
|