mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
feat(js): add check to no_modules gen js for cloudflare workers
This commit is contained in:
parent
0e864a4855
commit
3e814a6824
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user