terser 5.37.0 → 5.38.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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.38.0
4
+
5
+ - Remove `console` method-of-method calls (eg `console.log.apply()`) when `drop_console` option is used (#1585)
6
+ - Remove more object spreads, such as `{ ...void !0 }` (#1142)
7
+
3
8
  ## v5.37.0
4
9
 
5
10
  - Reserved object properties from chrome extensions (domprops)
package/README.md CHANGED
@@ -647,7 +647,7 @@ console.log(result.map); // source map
647
647
  Note that the source map is not saved in a file, it's just returned in
648
648
  `result.map`. The value passed for `sourceMap.url` is only used to set
649
649
  `//# sourceMappingURL=out.js.map` in `result.code`. The value of
650
- `filename` is only used to set `file` attribute (see [the spec][sm-spec])
650
+ `filename` is only used to set `file` attribute (see [the spec](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k))
651
651
  in source map file.
652
652
 
653
653
  You can set option `sourceMap.url` to be `"inline"` and source map will
@@ -1233,7 +1233,7 @@ Terser has its own abstract syntax tree format; for
1233
1233
  we can't easily change to using the SpiderMonkey AST internally. However,
1234
1234
  Terser now has a converter which can import a SpiderMonkey AST.
1235
1235
 
1236
- For example [Acorn][acorn] is a super-fast parser that produces a
1236
+ For example [Acorn](https://github.com/acornjs/acorn) is a super-fast parser that produces a
1237
1237
  SpiderMonkey AST. It has a small CLI utility that parses one file and dumps
1238
1238
  the AST in JSON on the standard output. To use Terser to mangle and
1239
1239
  compress that:
@@ -1257,9 +1257,6 @@ Acorn is really fast (e.g. 250ms instead of 380ms on some 650K code), but
1257
1257
  converting the SpiderMonkey tree that Acorn produces takes another 150ms so
1258
1258
  in total it's a bit more than just using Terser's own parser.
1259
1259
 
1260
- [acorn]: https://github.com/ternjs/acorn
1261
- [sm-spec]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k
1262
-
1263
1260
  ### Terser Fast Minify Mode
1264
1261
 
1265
1262
  It's not well known, but whitespace removal and symbol mangling accounts
@@ -14575,8 +14575,13 @@ AST_Node.DEFMETHOD("is_constant", function () {
14575
14575
  return !(this instanceof AST_RegExp);
14576
14576
  } else {
14577
14577
  return this instanceof AST_UnaryPrefix
14578
- && this.expression instanceof AST_Constant
14579
- && unaryPrefix.has(this.operator);
14578
+ && unaryPrefix.has(this.operator)
14579
+ && (
14580
+ // `this.expression` may be an `AST_RegExp`,
14581
+ // so not only `.is_constant()`.
14582
+ this.expression instanceof AST_Constant
14583
+ || this.expression.is_constant()
14584
+ );
14580
14585
  }
14581
14586
  });
14582
14587
 
@@ -18982,17 +18987,19 @@ AST_Toplevel.DEFMETHOD("drop_console", function(options) {
18982
18987
  return;
18983
18988
  }
18984
18989
 
18985
- if (isArray && !options.includes(exp.property)) {
18986
- return;
18987
- }
18988
-
18989
18990
  var name = exp.expression;
18991
+ var property = exp.property;
18990
18992
  var depth = 2;
18991
18993
  while (name.expression) {
18994
+ property = name.property;
18992
18995
  name = name.expression;
18993
18996
  depth++;
18994
18997
  }
18995
18998
 
18999
+ if (isArray && !options.includes(property)) {
19000
+ return;
19001
+ }
19002
+
18996
19003
  if (is_undeclared_ref(name) && name.name == "console") {
18997
19004
  if (
18998
19005
  depth === 3
@@ -117,8 +117,13 @@ AST_Node.DEFMETHOD("is_constant", function () {
117
117
  return !(this instanceof AST_RegExp);
118
118
  } else {
119
119
  return this instanceof AST_UnaryPrefix
120
- && this.expression instanceof AST_Constant
121
- && unaryPrefix.has(this.operator);
120
+ && unaryPrefix.has(this.operator)
121
+ && (
122
+ // `this.expression` may be an `AST_RegExp`,
123
+ // so not only `.is_constant()`.
124
+ this.expression instanceof AST_Constant
125
+ || this.expression.is_constant()
126
+ );
122
127
  }
123
128
  });
124
129
 
@@ -524,17 +524,19 @@ AST_Toplevel.DEFMETHOD("drop_console", function(options) {
524
524
  return;
525
525
  }
526
526
 
527
- if (isArray && !options.includes(exp.property)) {
528
- return;
529
- }
530
-
531
527
  var name = exp.expression;
528
+ var property = exp.property;
532
529
  var depth = 2;
533
530
  while (name.expression) {
531
+ property = name.property;
534
532
  name = name.expression;
535
533
  depth++;
536
534
  }
537
535
 
536
+ if (isArray && !options.includes(property)) {
537
+ return;
538
+ }
539
+
538
540
  if (is_undeclared_ref(name) && name.name == "console") {
539
541
  if (
540
542
  depth === 3
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://terser.org",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "5.37.0",
7
+ "version": "5.38.0",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },