diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index cecf43499887..977d133dff72 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -451,7 +451,15 @@ impl<'a> Context<'a> { OutputMode::Bundler { .. } | OutputMode::Node { module: true } => { for (id, js) in crate::sorted_iter(&self.wasm_import_definitions) { let import = self.module.imports.get_mut(*id); - import.module = format!("./{}_bg.js", module_name); + import.module = format!( + "./{}_bg.{}", + module_name, + if self.config.mode.nodejs() { + "jsm" + } else { + "js" + } + ); if let Some(body) = js.strip_prefix("function") { footer.push_str("\nexport function "); footer.push_str(&import.name);