From 963b0881f9e027fd9ca6ed7b59a3b1f284bf688e Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Mon, 3 Feb 2025 20:28:18 +0800 Subject: [PATCH] fix(es/transforms): Pass `unresolved_mark` to `simplifier` instead of `top_level_mark` (#9989) **Related issue:** - Closes https://github.com/swc-project/swc/issues/9981 --- .changeset/fuzzy-kangaroos-help.md | 5 +++++ .changeset/many-camels-chew.md | 6 ++++++ crates/swc/src/config/mod.rs | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/fuzzy-kangaroos-help.md create mode 100644 .changeset/many-camels-chew.md diff --git a/.changeset/fuzzy-kangaroos-help.md b/.changeset/fuzzy-kangaroos-help.md new file mode 100644 index 000000000000..ee7e36df7571 --- /dev/null +++ b/.changeset/fuzzy-kangaroos-help.md @@ -0,0 +1,5 @@ +--- +preset_env_base: patch +--- + +fix(es/transforms): Pass `unresolved_mark` to `simplifier` instead of `top_level_mark` diff --git a/.changeset/many-camels-chew.md b/.changeset/many-camels-chew.md new file mode 100644 index 000000000000..94971acefb79 --- /dev/null +++ b/.changeset/many-camels-chew.md @@ -0,0 +1,6 @@ +--- +swc: patch +swc_core: patch +--- + +fix(es/transforms): Pass `unresolved_mark` to `simplifier` instead of `top_level_mark` diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index 96303157ebc0..61f2af59e714 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -470,13 +470,13 @@ impl Options { match opts { SimplifyOption::Bool(allow_simplify) => { if *allow_simplify { - Some(simplifier(top_level_mark, Default::default())) + Some(simplifier(unresolved_mark, Default::default())) } else { None } } SimplifyOption::Json(cfg) => Some(simplifier( - top_level_mark, + unresolved_mark, SimplifyConfig { dce: DceConfig { preserve_imports_with_side_effects: cfg