Skip to content

Commit 93fedf8

Browse files
daxpeddaalexcrichton
authored andcommitted
Add default module to init for no-modules output mode. (#1938)
* Add default module to `init` for `no-modules` output mode. * Add semicolons.
1 parent 56e4d7d commit 93fedf8

File tree

1 file changed

+12
-0
lines changed
  • crates/cli-support/src/js

1 file changed

+12
-0
lines changed

crates/cli-support/src/js/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,18 @@ impl<'a> Context<'a> {
437437
module = import.meta.url.replace(/\\.js$/, '_bg.wasm');
438438
}"
439439
}
440+
OutputMode::NoModules { .. } => {
441+
"\
442+
if (typeof module === 'undefined') {
443+
let src;
444+
if (self.document === undefined) {
445+
src = self.location.href;
446+
} else {
447+
src = self.document.currentScript.src;
448+
}
449+
module = src.replace(/\\.js$/, '_bg.wasm');
450+
}"
451+
}
440452
_ => "",
441453
};
442454

0 commit comments

Comments
 (0)