From 3cd802f150b9d870ea5f75827e846cc8fd8859f1 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 3 Jan 2020 12:41:51 +0100 Subject: [PATCH 1/2] Add default module to `init` for `no-modules` output mode. --- crates/cli-support/src/js/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 4a78dadc4ef..bd0c3e58ec5 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') + }" + } _ => "", }; From 28041b9e5697ec72e4a39ce25cfb115899d43938 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 6 Jan 2020 21:40:48 +0100 Subject: [PATCH 2/2] Add semicolons. --- crates/cli-support/src/js/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index bd0c3e58ec5..5104233dfea 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -440,13 +440,13 @@ impl<'a> Context<'a> { OutputMode::NoModules { .. } => { "\ if (typeof module === 'undefined') { - let src + let src; if (self.document === undefined) { - src = self.location.href + src = self.location.href; } else { - src = self.document.currentScript.src + src = self.document.currentScript.src; } - module = src.replace(/\\.js$/, '_bg.wasm') + module = src.replace(/\\.js$/, '_bg.wasm'); }" } _ => "",