Skip to content

Commit

Permalink
Add default module to init for no-modules output mode. (#1938)
Browse files Browse the repository at this point in the history
* Add default module to `init` for `no-modules` output mode.

* Add semicolons.
  • Loading branch information
daxpedda authored and alexcrichton committed Jan 6, 2020
1 parent 56e4d7d commit 93fedf8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}"
}
_ => "",
};

Expand Down

0 comments on commit 93fedf8

Please sign in to comment.