From 3e814a682475073546e250ac79e43a3aff0d6c46 Mon Sep 17 00:00:00 2001 From: Ashley Williams Date: Thu, 21 Mar 2019 16:39:03 -0500 Subject: [PATCH] feat(js): add check to no_modules gen js for cloudflare workers --- crates/cli-support/src/js/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 83c667de4df..a2eaa2be6e6 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -860,13 +860,7 @@ impl<'a> Context<'a> { function init(module_or_path, maybe_memory) {{ let result; const imports = {{ './{module}': __exports }}; - if (module_or_path instanceof WebAssembly.Module) {{ - {init_memory1} - result = WebAssembly.instantiate(module_or_path, imports) - .then(instance => {{ - return {{ instance, module: module_or_path }}; - }}); - }} else {{ + if (module_or_path instanceof URL || typeof module_or_path === 'string' || module_or_path instanceof Request) {{ {init_memory2} const response = fetch(module_or_path); if (typeof WebAssembly.instantiateStreaming === 'function') {{ @@ -886,6 +880,12 @@ impl<'a> Context<'a> { .then(r => r.arrayBuffer()) .then(bytes => WebAssembly.instantiate(bytes, imports)); }} + }} else {{ + {init_memory1} + result = WebAssembly.instantiate(module_or_path, imports) + .then(instance => {{ + return {{ instance, module: module_or_path }}; + }}); }} return result.then(({{instance, module}}) => {{ wasm = instance.exports;