Skip to content
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

Add application/wasm Web Assembly mime type #300

Merged
merged 1 commit into from
Jan 5, 2021

Conversation

daboross
Copy link
Contributor

@daboross daboross commented Jan 4, 2021

This adds the application/wasm mime type, which is used to represent compiled Web Assembly files, and registers it with the associated file extension, .wasm.

It's not a registered standard mimetype, but it is widely recognized. It's the mimetype listed in the official WebAssembly conventions document, and all major browsers recognize it.

My main motivation for this is so that I can use the WebAssembly.instantiateStreaming browser API on wasm files served by lwan. This api specifically requires the application/wasm mimetype, otherwise the browser won't instantiate streaming and instead requires loading the wasm file as a binary value before initializing. See the MDN documentation mentioning this requirement: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming#Instantiating_streaming

Hopefully this will be an official mimetype at some point - there's an issue for that here: WebAssembly/spec#573.

However, until then - I saw this file listed both "official" and "widely recognized" mimetypes, and I'm hoping application/wasm falls into the second one.

This adds the application/wasm mime type, which is used to represent
compiled Web Assembly files, and registers it with the associated file
extension, .wasm.

While this isn't a registered standard, it's a widely recognized
mimetype, and is the one officially set out by the WASM committee and
current JavaScript standards.

It's concretely useful to use this mimetype, as it enables use of the
"WebAssembly.instantiateStreaming" browser API.

References:

https://webassembly.github.io/spec/core/binary/conventions.html
 - the webassembly document recommending application/wasm

WebAssembly/spec#573
 - progress on getting this registered as an official mimetype

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming#Instantiating_streaming
 - JS API which requires the application/wasm mimetype to function
@lpereira
Copy link
Owner

lpereira commented Jan 5, 2021

LGTM. Quite curious on what you're working on with Lwan and WASM; is it something public?

@lpereira lpereira merged commit 595b5d1 into lpereira:master Jan 5, 2021
@daboross daboross deleted the add-wasm-mime-type branch January 9, 2021 08:04
@daboross
Copy link
Contributor Author

daboross commented Jan 9, 2021

Thanks!

I'm using lwan as a local deployment server for wasm game development. I figure it isn't exactly the intended use case, but it's A) quick to configure, B) an actually fully featured web server, and C) nicely efficient. I don't have anything public yet, but it's been really nice to use for local web development & prototyping out rust-wasm-based games.

@fabiomen10
Copy link

I thank you @daboross for your explanation and information. @lpereira I'm learning to make the same use that @daboross has been doing. I and many others, I believe, need wasm support at LWAN. I may be getting it wrong and LWAN already has that.

@lpereira
Copy link
Owner

@daboross Awesome! Good to know it's working for you!

@fabiomen10 Sort of adding the MIME Type in Lwan, like @daboross did, there's nothing much I can think of that could use WASM in Lwan (well, maybe some sort of CGI scripts and whatnot, but that's implementable using what's already there, and won't need changes in Lwan itself; considering there's not much of a standard here, I don't see the point at this time in implementing this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants