terser 5.39.1 → 5.39.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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.39.2
4
+
5
+ - Fix crash when parsing bare `yield` inside a template string.
6
+ - Update internally used acorn version requirement
7
+
3
8
  ## v5.39.1
4
9
 
5
10
  - Fix bitwise operations that could mix `BigInt` and `number`
@@ -843,7 +843,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
843
843
  } else if (ch == "$" && peek() == "{") {
844
844
  next(true, true);
845
845
  S.brace_counter++;
846
- tok = token(begin ? "template_head" : "template_substitution", content);
846
+ tok = token(begin ? "template_head" : "template_cont", content);
847
847
  TEMPLATE_RAWS.set(tok, raw);
848
848
  tok.template_end = false;
849
849
  return tok;
@@ -860,7 +860,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
860
860
  content += ch;
861
861
  }
862
862
  S.template_braces.pop();
863
- tok = token(begin ? "template_head" : "template_substitution", content);
863
+ tok = token(begin ? "template_head" : "template_cont", content);
864
864
  TEMPLATE_RAWS.set(tok, raw);
865
865
  tok.template_end = true;
866
866
  return tok;
@@ -2111,11 +2111,6 @@ function parse($TEXT, options) {
2111
2111
  }
2112
2112
 
2113
2113
  function _yield_expression() {
2114
- // Previous token must be keyword yield and not be interpret as an identifier
2115
- if (!is_in_generator()) {
2116
- croak("Unexpected yield expression outside generator function",
2117
- S.prev.line, S.prev.col, S.prev.pos);
2118
- }
2119
2114
  var start = S.token;
2120
2115
  var star = false;
2121
2116
  var has_expression = true;
@@ -2130,10 +2125,12 @@ function parse($TEXT, options) {
2130
2125
  // Note 1: It isn't allowed for yield* to close without an expression
2131
2126
  // Note 2: If there is a nlb between yield and star, it is interpret as
2132
2127
  // yield <explicit undefined> <inserted automatic semicolon> *
2133
- if (can_insert_semicolon() ||
2134
- (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
2128
+ if (
2129
+ can_insert_semicolon()
2130
+ || is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value)
2131
+ || is("template_cont")
2132
+ ) {
2135
2133
  has_expression = false;
2136
-
2137
2134
  } else if (is("operator", "*")) {
2138
2135
  star = true;
2139
2136
  next();
@@ -32837,7 +32834,7 @@ async function run_cli({ program, packageJson, fs, path }) {
32837
32834
  if (program.parse.acorn) {
32838
32835
  files = convert_ast(function(toplevel, name) {
32839
32836
  return require("acorn").parse(files[name], {
32840
- ecmaVersion: 2018,
32837
+ ecmaVersion: 2024,
32841
32838
  locations: true,
32842
32839
  program: toplevel,
32843
32840
  sourceFile: name,
package/lib/cli.js CHANGED
@@ -202,7 +202,7 @@ export async function run_cli({ program, packageJson, fs, path }) {
202
202
  if (program.parse.acorn) {
203
203
  files = convert_ast(function(toplevel, name) {
204
204
  return require("acorn").parse(files[name], {
205
- ecmaVersion: 2018,
205
+ ecmaVersion: 2024,
206
206
  locations: true,
207
207
  program: toplevel,
208
208
  sourceFile: name,
package/lib/parse.js CHANGED
@@ -698,7 +698,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
698
698
  } else if (ch == "$" && peek() == "{") {
699
699
  next(true, true);
700
700
  S.brace_counter++;
701
- tok = token(begin ? "template_head" : "template_substitution", content);
701
+ tok = token(begin ? "template_head" : "template_cont", content);
702
702
  TEMPLATE_RAWS.set(tok, raw);
703
703
  tok.template_end = false;
704
704
  return tok;
@@ -715,7 +715,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
715
715
  content += ch;
716
716
  }
717
717
  S.template_braces.pop();
718
- tok = token(begin ? "template_head" : "template_substitution", content);
718
+ tok = token(begin ? "template_head" : "template_cont", content);
719
719
  TEMPLATE_RAWS.set(tok, raw);
720
720
  tok.template_end = true;
721
721
  return tok;
@@ -1966,11 +1966,6 @@ function parse($TEXT, options) {
1966
1966
  }
1967
1967
 
1968
1968
  function _yield_expression() {
1969
- // Previous token must be keyword yield and not be interpret as an identifier
1970
- if (!is_in_generator()) {
1971
- croak("Unexpected yield expression outside generator function",
1972
- S.prev.line, S.prev.col, S.prev.pos);
1973
- }
1974
1969
  var start = S.token;
1975
1970
  var star = false;
1976
1971
  var has_expression = true;
@@ -1985,10 +1980,12 @@ function parse($TEXT, options) {
1985
1980
  // Note 1: It isn't allowed for yield* to close without an expression
1986
1981
  // Note 2: If there is a nlb between yield and star, it is interpret as
1987
1982
  // yield <explicit undefined> <inserted automatic semicolon> *
1988
- if (can_insert_semicolon() ||
1989
- (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
1983
+ if (
1984
+ can_insert_semicolon()
1985
+ || is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value)
1986
+ || is("template_cont")
1987
+ ) {
1990
1988
  has_expression = false;
1991
-
1992
1989
  } else if (is("operator", "*")) {
1993
1990
  star = true;
1994
1991
  next();
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.39.1",
7
+ "version": "5.39.2",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },
@@ -45,7 +45,7 @@
45
45
  ],
46
46
  "dependencies": {
47
47
  "@jridgewell/source-map": "^0.3.3",
48
- "acorn": "^8.8.2",
48
+ "acorn": "^8.14.0",
49
49
  "commander": "^2.20.0",
50
50
  "source-map-support": "~0.5.20"
51
51
  },