terser 5.7.1 → 5.7.2

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/lib/output.js CHANGED
@@ -159,7 +159,7 @@ import {
159
159
  is_basic_identifier_string,
160
160
  is_identifier_string,
161
161
  PRECEDENCE,
162
- RESERVED_WORDS,
162
+ ALL_RESERVED_WORDS,
163
163
  } from "./parse.js";
164
164
 
165
165
  const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
@@ -1717,7 +1717,11 @@ function OutputStream(options) {
1717
1717
  // https://github.com/mishoo/UglifyJS2/issues/60
1718
1718
  if (noin) {
1719
1719
  parens = walk(node, node => {
1720
- if (node instanceof AST_Scope) return true;
1720
+ // Don't go into scopes -- except arrow functions:
1721
+ // https://github.com/terser/terser/issues/1019#issuecomment-877642607
1722
+ if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
1723
+ return true;
1724
+ }
1721
1725
  if (node instanceof AST_Binary && node.operator == "in") {
1722
1726
  return walk_abort; // makes walk() return true
1723
1727
  }
@@ -1787,7 +1791,7 @@ function OutputStream(options) {
1787
1791
  var expr = self.expression;
1788
1792
  expr.print(output);
1789
1793
  var prop = self.property;
1790
- var print_computed = RESERVED_WORDS.has(prop)
1794
+ var print_computed = ALL_RESERVED_WORDS.has(prop)
1791
1795
  ? output.option("ie8")
1792
1796
  : !is_identifier_string(
1793
1797
  prop,
@@ -1968,7 +1972,7 @@ function OutputStream(options) {
1968
1972
  }
1969
1973
  return output.print(make_num(key));
1970
1974
  }
1971
- var print_string = RESERVED_WORDS.has(key)
1975
+ var print_string = ALL_RESERVED_WORDS.has(key)
1972
1976
  ? output.option("ie8")
1973
1977
  : (
1974
1978
  output.option("ecma") < 2015 || output.option("safari10")
@@ -1995,7 +1999,7 @@ function OutputStream(options) {
1995
1999
  output.option("ecma") >= 2015 || output.option("safari10")
1996
2000
  ) &&
1997
2001
  get_name(self.value) === self.key &&
1998
- !RESERVED_WORDS.has(self.key)
2002
+ !ALL_RESERVED_WORDS.has(self.key)
1999
2003
  ) {
2000
2004
  print_property_name(self.key, self.quote, output);
2001
2005
 
package/lib/parse.js CHANGED
@@ -166,13 +166,15 @@ var LATEST_TEMPLATE_END = true;
166
166
 
167
167
  var KEYWORDS = "break case catch class const continue debugger default delete do else export extends finally for function if in instanceof let new return switch throw try typeof var void while with";
168
168
  var KEYWORDS_ATOM = "false null true";
169
- var RESERVED_WORDS = "enum implements import interface package private protected public static super this " + KEYWORDS_ATOM + " " + KEYWORDS;
169
+ var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
170
+ var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
170
171
  var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
171
172
 
172
173
  KEYWORDS = makePredicate(KEYWORDS);
173
174
  RESERVED_WORDS = makePredicate(RESERVED_WORDS);
174
175
  KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
175
176
  KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
177
+ ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
176
178
 
177
179
  var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
178
180
 
@@ -3339,6 +3341,6 @@ export {
3339
3341
  JS_Parse_Error,
3340
3342
  parse,
3341
3343
  PRECEDENCE,
3342
- RESERVED_WORDS,
3344
+ ALL_RESERVED_WORDS,
3343
3345
  tokenizer,
3344
3346
  };
package/lib/scope.js CHANGED
@@ -107,7 +107,7 @@ import {
107
107
  walk
108
108
  } from "./ast.js";
109
109
  import {
110
- RESERVED_WORDS,
110
+ ALL_RESERVED_WORDS,
111
111
  js_error,
112
112
  } from "./parse.js";
113
113
 
@@ -669,7 +669,7 @@ function next_mangled(scope, options) {
669
669
  var ext = scope.enclosed;
670
670
  out: while (true) {
671
671
  var m = base54(++scope.cname);
672
- if (RESERVED_WORDS.has(m)) continue; // skip over "do"
672
+ if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
673
673
 
674
674
  // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
675
675
  // shadow a name reserved from mangling.
@@ -817,7 +817,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
817
817
  let name;
818
818
  do {
819
819
  name = base54(++lname);
820
- } while (RESERVED_WORDS.has(name));
820
+ } while (ALL_RESERVED_WORDS.has(name));
821
821
  node.mangled_name = name;
822
822
  return true;
823
823
  }
@@ -893,7 +893,7 @@ AST_Toplevel.DEFMETHOD("expand_names", function(options) {
893
893
  var name;
894
894
  do {
895
895
  name = base54(cname++);
896
- } while (avoid.has(name) || RESERVED_WORDS.has(name));
896
+ } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
897
897
  return name;
898
898
  }
899
899
 
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.7.1",
7
+ "version": "5.7.2",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },
@@ -93,7 +93,7 @@
93
93
  "eslintConfig": {
94
94
  "parserOptions": {
95
95
  "sourceType": "module",
96
- "ecmaVersion": "2020"
96
+ "ecmaVersion": 2020
97
97
  },
98
98
  "env": {
99
99
  "node": true,
package/tools/terser.d.ts CHANGED
@@ -138,6 +138,7 @@ export enum OutputQuoteStyle {
138
138
  export interface MinifyOptions {
139
139
  compress?: boolean | CompressOptions;
140
140
  ecma?: ECMA;
141
+ enclose?: boolean | string;
141
142
  ie8?: boolean;
142
143
  keep_classnames?: boolean | RegExp;
143
144
  keep_fnames?: boolean | RegExp;
package/bin/terser.mjs DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- "use strict";
4
-
5
- import "../tools/exit.cjs";
6
-
7
- import fs from "fs"
8
- import path from "path"
9
- import program from "commander"
10
-
11
- import { run_cli } from "../lib/cli.js"
12
-
13
- const packageJson = {
14
- name: "terser",
15
- version: "experimental module CLI"
16
- }
17
-
18
- run_cli({ program, packageJson, fs, path }).catch((error) => {
19
- console.error(error);
20
- process.exitCode = 1;
21
- });