Skip to content

Commit 34a58b4

Browse files
Merge pull request #1 from daxpedda/script-url
Fix `no-modules` output
2 parents 27df7a9 + d9dc1c5 commit 34a58b4

File tree

1 file changed

+7
-5
lines changed
  • crates/cli-support/src/js

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ impl<'a> Context<'a> {
379379
OutputMode::NoModules { global } => {
380380
js.push_str("const __exports = {};\n");
381381
js.push_str("let script_src;\n");
382+
js.push_str("\
383+
if (typeof document === 'undefined') {
384+
script_src = location.href;
385+
} else {
386+
script_src = document.currentScript.src;
387+
}"
388+
);
382389
js.push_str("let wasm;\n");
383390
init = self.gen_init(needs_manual_start, None)?;
384391
footer.push_str(&format!("{} = Object.assign(init, __exports);\n", global));
@@ -701,11 +708,6 @@ impl<'a> Context<'a> {
701708
stem = self.config.stem()?
702709
),
703710
OutputMode::NoModules { .. } => "\
704-
if (typeof document === 'undefined') {
705-
script_src = location.href;
706-
} else {
707-
script_src = document.currentScript.src;
708-
}
709711
if (typeof input === 'undefined') {
710712
input = script_src.replace(/\\.js$/, '_bg.wasm');
711713
}"

0 commit comments

Comments
 (0)