terser 5.27.0 → 5.27.1

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,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.27.1
4
+ - Fixed case where `collapse_vars` inlines `await` expressions into non-async functions.
5
+
3
6
  ## v5.27.0
4
7
  - Created `minify_sync()` alternative to `minify()` since there's no async code left.
5
8
 
@@ -16725,6 +16725,14 @@ function tighten_body(statements, compressor) {
16725
16725
  return found;
16726
16726
  }
16727
16727
 
16728
+ function arg_is_injectable(arg) {
16729
+ if (arg instanceof AST_Expansion) return false;
16730
+ const contains_await = walk(arg, (node) => {
16731
+ if (node instanceof AST_Await) return walk_abort;
16732
+ });
16733
+ if (contains_await) return false;
16734
+ return true;
16735
+ }
16728
16736
  function extract_args() {
16729
16737
  var iife, fn = compressor.self();
16730
16738
  if (is_func_expr(fn)
@@ -16733,7 +16741,8 @@ function tighten_body(statements, compressor) {
16733
16741
  && !fn.pinned()
16734
16742
  && (iife = compressor.parent()) instanceof AST_Call
16735
16743
  && iife.expression === fn
16736
- && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
16744
+ && iife.args.every(arg_is_injectable)
16745
+ ) {
16737
16746
  var fn_strict = compressor.has_directive("use strict");
16738
16747
  if (fn_strict && !member(fn_strict, fn.body))
16739
16748
  fn_strict = false;
@@ -574,6 +574,14 @@ export function tighten_body(statements, compressor) {
574
574
  return found;
575
575
  }
576
576
 
577
+ function arg_is_injectable(arg) {
578
+ if (arg instanceof AST_Expansion) return false;
579
+ const contains_await = walk(arg, (node) => {
580
+ if (node instanceof AST_Await) return walk_abort;
581
+ });
582
+ if (contains_await) return false;
583
+ return true;
584
+ }
577
585
  function extract_args() {
578
586
  var iife, fn = compressor.self();
579
587
  if (is_func_expr(fn)
@@ -582,7 +590,8 @@ export function tighten_body(statements, compressor) {
582
590
  && !fn.pinned()
583
591
  && (iife = compressor.parent()) instanceof AST_Call
584
592
  && iife.expression === fn
585
- && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
593
+ && iife.args.every(arg_is_injectable)
594
+ ) {
586
595
  var fn_strict = compressor.has_directive("use strict");
587
596
  if (fn_strict && !member(fn_strict, fn.body))
588
597
  fn_strict = false;
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.27.0",
7
+ "version": "5.27.1",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },