mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
Don't give up when servers don't set the application/wasm MIME type
It is quite annoying when using `python -m SimpleHTTPServer` or equivalent.
This commit is contained in:
parent
c8ad85dd0b
commit
4975ca2954
@ -612,7 +612,17 @@ impl<'a> Context<'a> {
|
|||||||
memory = __exports.memory = {init_memory};
|
memory = __exports.memory = {init_memory};
|
||||||
const response = fetch(module_or_path);
|
const response = fetch(module_or_path);
|
||||||
if (typeof WebAssembly.instantiateStreaming === 'function') {{
|
if (typeof WebAssembly.instantiateStreaming === 'function') {{
|
||||||
result = WebAssembly.instantiateStreaming(response, imports);
|
result = WebAssembly.instantiateStreaming(response, imports)
|
||||||
|
.catch(e => {{
|
||||||
|
console.warn(\"`WebAssembly.instantiateStreaming` failed. Assuming this is \
|
||||||
|
because your server does not serve wasm with \
|
||||||
|
`application/wasm` MIME type. Falling back to \
|
||||||
|
`WebAssembly.instantiate` which is slower. Original \
|
||||||
|
error:\\n\", e);
|
||||||
|
return response
|
||||||
|
.then(r => r.arrayBuffer())
|
||||||
|
.then(bytes => WebAssembly.instantiate(bytes, imports));
|
||||||
|
}});
|
||||||
}} else {{
|
}} else {{
|
||||||
result = response
|
result = response
|
||||||
.then(r => r.arrayBuffer())
|
.then(r => r.arrayBuffer())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user