Vscode-live-server: Please fixe content-type for .wasm (WebAssembly)

Created on 23 Sep 2018  路  6Comments  路  Source: ritwickdey/vscode-live-server

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[x] Feature request
[ ] Documentation issue or request
[ ] Other: <!-- Please describe: -->

Current behavior


I'm compiling WebAssembly (*.wasm) files and can't serve these properly to the browser.
Any ".wasm"-file is of content-type: "application/octet-stream"

Expected behavior

The proper content-type should be "application/wasm"

Environment

Browser:

- [ ] Chrome (desktop) version XX
- [x] Firefox version 62.0.2
- [ ] Safari (desktop) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:

- Live Server: 5.1.1
- Platform:  Windows, compiling in WSL-ubuntu
- Visual Studio Code: 1.27.2

Others

Most helpful comment

I also still have this problem. Here is a quick work around though, if you need it:

I only have the MIME-type issue, when I try to load my wasm-module via the WebAssembly.instantiateStreaming(fetch('path/to/my_module.wasm')) -API.
With the slightly more verbose an less efficient API: WebAssembly.instantiate(bytes) the import works completely fine.

Both in comparison:

```
// Desired API-usage (Currently apparently not working with Live-Server plugin)
async function getModuleFunctions() {
const resultObject = await WebAssembly.instantiateStreaming(fetch('path/to/my_module.wasm'));
return resultObj.instance.exports;
}

// Older API as work-around
async function getModuleFunctions() {
const fetchResult = await fetch('path/to/my_module.wasm');
const bytes = await fetchResult.arrayBuffer();
const resultObj = await WebAssembly.instantiate(bytes);
// The functions reside in the exports section on the resultObject.instance
return resultObj.instance.exports;
}

All 6 comments

This *feature is required in Chrome v79 too.

Please tell me when it will be ok :)

I'm still having this issue on chrome 83 and mac os

I also still have this problem. Here is a quick work around though, if you need it:

I only have the MIME-type issue, when I try to load my wasm-module via the WebAssembly.instantiateStreaming(fetch('path/to/my_module.wasm')) -API.
With the slightly more verbose an less efficient API: WebAssembly.instantiate(bytes) the import works completely fine.

Both in comparison:

```
// Desired API-usage (Currently apparently not working with Live-Server plugin)
async function getModuleFunctions() {
const resultObject = await WebAssembly.instantiateStreaming(fetch('path/to/my_module.wasm'));
return resultObj.instance.exports;
}

// Older API as work-around
async function getModuleFunctions() {
const fetchResult = await fetch('path/to/my_module.wasm');
const bytes = await fetchResult.arrayBuffer();
const resultObj = await WebAssembly.instantiate(bytes);
// The functions reside in the exports section on the resultObject.instance
return resultObj.instance.exports;
}

how is this still not fixed...

697 The issue will be fixed once this is merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zerotask picture Zerotask  路  4Comments

julesmqz picture julesmqz  路  7Comments

mpower02 picture mpower02  路  6Comments

Josee9988 picture Josee9988  路  3Comments

iAdesanyaDaniel picture iAdesanyaDaniel  路  3Comments