Apply the instantiateStreaming incorrect MIME type recovery for no-modules

It was incorrectly only enabled for the multithreading glue previously.
This commit is contained in:
Nick Fitzgerald 2019-02-12 10:41:53 -08:00
parent c30dbc3179
commit b858875d49

View File

@ -672,7 +672,17 @@ impl<'a> Context<'a> {
}} else {{
const data = fetch(path_or_module);
if (typeof WebAssembly.instantiateStreaming === 'function') {{
instantiation = WebAssembly.instantiateStreaming(data, imports);
instantiation = WebAssembly.instantiateStreaming(data, 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 data
.then(r => r.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, imports));
}});
}} else {{
instantiation = data
.then(response => response.arrayBuffer())