-
-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebAssembly files should be served with Content-Type=application/wasm #229
Comments
shouldn't this feature be asked in the mime project, considering https://github.com/webpack/webpack-dev-middleware/blob/master/middleware.js#L72? |
yes the mime project should add support for .wasm. I will report that. but the middleware also adds a charset to the MIME type which does not work |
Support for the wasm content type is now available in mime 1.5.0. I have updated the pull request to use this new version and removed the temporary workaround. |
Closed by #230 |
Thank you. It works now when working from source. It would be great if you could publish a new version to npm. |
Thanks for fixing this, also ran into this issue. Slightly off-topic but in order to properly serve wasm with karma, I also had to put this in the karma config: mime: {
'application/wasm': ['wasm']
} allowing you to specify the type in files = [
{pattern: 'node_modules/opus-recorder/dist/*.wasm', included: false, served: true, type: 'wasm'},
] |
I'm still having trouble with this. Using Create-React-App's Typescript version. When I run npm ls mime:
Are these the right versions of webpack, webpack-dev-server, and mime to make this work? Should I eject CRA and edit or replace certain files? |
Same here, when will the merged pull request be available? I'm still experiencing the problem in webpack-dev-server 3.1.5 which uses webpack-dev-middleware 3.1.3 (released on Apr 26, 2018), but the merge was carried out on Nov 22, 2017. Thanks! |
just updated to webpack-dev-server @ 3.1.6 Still the same error. Thanks. |
Ended up using this devServer: {
// webpack-dev-server middleware
before(app) {
// use proper mime-type for wasm files
app.get('*.wasm', function(req, res, next) {
var options = {
root: contentBase,
dotfiles: 'deny',
headers: {
'Content-Type': 'application/wasm'
}
};
res.sendFile(req.url, options, function (err) {
if (err) {
next(err);
}
});
});
}
} |
@thijstriemstra i have tired copy pasting exactlly you devServer config but i am getting different error then i deleted to root:contentBase and dotfile: denies, and i still get "Error: ENOENT: no such file or directory, stat '/dist/mainTest.wasm'. could you please post your whole webpack.confg.js? |
Code
I have created a project for testing the new webassembly support in the next branch of webpack.
https://github.com/rhmoller/webpack-webassembly-tester
Expected Behavior
The webpack-dev-server should serve the .wasm file with a Content-Type header = "application/wasm"
Actual Behavior
The .wasm file is served with "application/octet-stream; charset=UTF-8"
It has the wrong mime-type and the charset specification should not be there.
For Bugs; How can we reproduce the behavior?
Instructions are in https://github.com/rhmoller/webpack-webassembly-tester
For Features; What is the motivation and/or use-case for the feature?
To be able to use webpacks wasm support when serving the project with webpack-dev-server
The text was updated successfully, but these errors were encountered: