terser 5.36.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.
@@ -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/lib/parse.js CHANGED
@@ -2690,6 +2690,7 @@ function parse($TEXT, options) {
2690
2690
  } else if (
2691
2691
  is("name")
2692
2692
  || is("privatename")
2693
+ || is("punc", "[")
2693
2694
  || is("operator", "*")
2694
2695
  || is("punc", ";")
2695
2696
  || is("punc", "}")
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.36.0",
7
+ "version": "5.38.0",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },