Couldn't find a plugin to load web assembly modules so I wrote one. Posting it here in case anyone else needs it whenever:
./wasm.js:
exports.fetch = () => ""
exports.instantiate = function (load) {
const loader = this
return fetch(load.address).then(r => {
const contentType = r.headers.get("content-type")
if (contentType === "application/wasm") {
return WebAssembly.instantiateStreaming(r)
}
// does the same thing but slightly slower and won't fail because of the MIME type check:
return r.arrayBuffer().then(b => WebAssembly.instantiate(b))
}).then(m => {
return {
deps: [],
execute: () => loader.newModule(m)
}
})
}
then in your project:
import { instance, module } from "../src/myWebAssemblyModule.wasm!wasm"