diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 4a78dadc4ef..5104233dfea 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -437,6 +437,18 @@ impl<'a> Context<'a> { module = import.meta.url.replace(/\\.js$/, '_bg.wasm'); }" } + OutputMode::NoModules { .. } => { + "\ + if (typeof module === 'undefined') { + let src; + if (self.document === undefined) { + src = self.location.href; + } else { + src = self.document.currentScript.src; + } + module = src.replace(/\\.js$/, '_bg.wasm'); + }" + } _ => "", };