Skip to content

Commit

Permalink
feat(js): add check to no_modules gen js for cloudflare workers
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleygwilliams committed Mar 21, 2019
1 parent 0e864a4 commit 3e814a6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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') {{
Expand All @@ -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;
Expand Down

0 comments on commit 3e814a6

Please sign in to comment.