diff --git a/.changeset/brave-pillows-tan.md b/.changeset/brave-pillows-tan.md new file mode 100644 index 000000000000..166242c5339c --- /dev/null +++ b/.changeset/brave-pillows-tan.md @@ -0,0 +1,5 @@ +--- +"@rspack/core": patch +--- + +fix: cjs transfrom preset env diff --git a/crates/rspack_plugin_javascript/src/visitors/mod.rs b/crates/rspack_plugin_javascript/src/visitors/mod.rs index 2c6692750ed2..350891e781f0 100644 --- a/crates/rspack_plugin_javascript/src/visitors/mod.rs +++ b/crates/rspack_plugin_javascript/src/visitors/mod.rs @@ -75,6 +75,7 @@ pub fn run_before_pass( } let mut pass = chain!( + strict_mode(build_info, build_meta), swc_visitor::resolver(unresolved_mark, top_level_mark, syntax.typescript()), // swc_visitor::lint( // &ast, @@ -153,7 +154,6 @@ pub fn run_before_pass( // The ordering of these two is important, `expr_simplifier` goes first and `dead_branch_remover` goes second. swc_visitor::expr_simplifier(unresolved_mark, Default::default()), swc_visitor::dead_branch_remover(unresolved_mark), - strict_mode(build_info, build_meta), ); program.fold_with(&mut pass); @@ -255,7 +255,7 @@ pub fn run_after_pass( if build_meta.esm { Some(ImportInterop::Swc) } else { - None + Some(ImportInterop::None) }, allow_top_level_this: true, ..Default::default() diff --git a/packages/rspack/tests/configCases/target/mix-cjs-esm/webpack.config.js b/packages/rspack/tests/configCases/target/mix-cjs-esm/webpack.config.js index e25efe761283..d2a298b16da7 100644 --- a/packages/rspack/tests/configCases/target/mix-cjs-esm/webpack.config.js +++ b/packages/rspack/tests/configCases/target/mix-cjs-esm/webpack.config.js @@ -1,3 +1,8 @@ module.exports = { - target: ["node", "es5"] + target: ["node", "es5"], + builtins: { + presetEnv: { + targets: ["> 0.01%"] + } + } };