terser 5.38.2 → 5.39.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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.39.0
4
+
5
+ - Remove unnecessary `console.assert` calls (#1590)
6
+
3
7
  ## v5.38.2
4
8
 
5
9
  - internal: Flatten inheritance tree for object/class members
@@ -13045,7 +13045,6 @@ const TRUTHY = 0b00000010;
13045
13045
  const FALSY = 0b00000100;
13046
13046
  const UNDEFINED = 0b00001000;
13047
13047
  const INLINED = 0b00010000;
13048
-
13049
13048
  // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
13050
13049
  const WRITE_ONLY = 0b00100000;
13051
13050
 
@@ -19029,6 +19028,7 @@ class Compressor extends TreeWalker {
19029
19028
  }
19030
19029
  }
19031
19030
 
19031
+
19032
19032
  function def_optimize(node, optimizer) {
19033
19033
  node.DEFMETHOD("optimize", function(compressor) {
19034
19034
  var self = this;
@@ -20253,6 +20253,23 @@ def_optimize(AST_Call, function(self, compressor) {
20253
20253
  self.args.length = last;
20254
20254
  }
20255
20255
 
20256
+ if (
20257
+ exp instanceof AST_Dot
20258
+ && exp.expression instanceof AST_SymbolRef
20259
+ && exp.expression.name === "console"
20260
+ && exp.expression.definition().undeclared
20261
+ && exp.property === "assert"
20262
+ ) {
20263
+ const condition = self.args[0];
20264
+ if (condition) {
20265
+ const value = condition.evaluate(compressor);
20266
+
20267
+ if (value === 1 || value === true) {
20268
+ return make_node(AST_Undefined, self);
20269
+ }
20270
+ }
20271
+ }
20272
+
20256
20273
  if (compressor.option("unsafe") && !exp.contains_optional()) {
20257
20274
  if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
20258
20275
  const [argument] = self.args;
@@ -48,7 +48,6 @@ export const TRUTHY = 0b00000010;
48
48
  export const FALSY = 0b00000100;
49
49
  export const UNDEFINED = 0b00001000;
50
50
  export const INLINED = 0b00010000;
51
-
52
51
  // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
53
52
  export const WRITE_ONLY = 0b00100000;
54
53
 
@@ -188,7 +188,6 @@ import {
188
188
  UNUSED,
189
189
  TRUTHY,
190
190
  FALSY,
191
-
192
191
  has_flag,
193
192
  set_flag,
194
193
  clear_flag,
@@ -497,6 +496,7 @@ class Compressor extends TreeWalker {
497
496
  }
498
497
  }
499
498
 
499
+
500
500
  function def_optimize(node, optimizer) {
501
501
  node.DEFMETHOD("optimize", function(compressor) {
502
502
  var self = this;
@@ -1721,6 +1721,23 @@ def_optimize(AST_Call, function(self, compressor) {
1721
1721
  self.args.length = last;
1722
1722
  }
1723
1723
 
1724
+ if (
1725
+ exp instanceof AST_Dot
1726
+ && exp.expression instanceof AST_SymbolRef
1727
+ && exp.expression.name === "console"
1728
+ && exp.expression.definition().undeclared
1729
+ && exp.property === "assert"
1730
+ ) {
1731
+ const condition = self.args[0];
1732
+ if (condition) {
1733
+ const value = condition.evaluate(compressor);
1734
+
1735
+ if (value === 1 || value === true) {
1736
+ return make_node(AST_Undefined, self);
1737
+ }
1738
+ }
1739
+ }
1740
+
1724
1741
  if (compressor.option("unsafe") && !exp.contains_optional()) {
1725
1742
  if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
1726
1743
  const [argument] = self.args;
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.38.2",
7
+ "version": "5.39.0",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },