When compiling client files to webassembly, usually you'll end up with both .js and .wasm files.
By default, most webservers don't know about the wasm MIME type.
You'll likely see the following error:
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
Here is how to add the wasm MIME type (on linux systems, apache + nginx):
Open /etc/mime.types You'll see two columns, media type on the left, file type on the right Add the line application/wasm wasm
Restart your webserver and you're good to go. This will work for Apache and also the Python SimpleHttpServer.
If you're using Nginx, you'll have to edit Nginx's mime types located in /etc/nginx/mime.types Reload nginx for the changes to take effect: sudo systemctl reload nginx
Oh, my bad, it seemsI answered a little too fast. I was absolutely not thinking about the browser handling the un-gzipping.
I think you're right then: sending the file with
Content-Type: application/wasm
&Content-Encoding: gzip
should do the trick: browser receives asset, uncompress it (since it has the associated content encoding), and load it as wasm. Though I'm curious if WebAssembly.instantiateStreaming() can actually stream a gzip-compressed WASM file ? I guess one has to try in order to figure it out... Maybe it will be necessary to fetch & then instantiate().