Description
One of the really nifty things about a WebAssembly.Module
object is that it can be posted to web workers in a cheap fashion, avoiding unnecessary recompilation of the internals. One of the primary use cases for this seems to be to help support the upcoming threads proposal where a module can be instantiated in multiple threads.
It seems, though, that if a world is envisioned where wasm modules are all ES modules, this may be difficult to do currently! As proposed I think that there's no way for an wasm-module-as-ES-module to export its own WebAssembly.Module
instance. That means it's not possible, when using native ES module integration for wasm, to cheaply instantiate the module on multiple workers.
Would it be possible to extend this proposal to allow a module to sort of export itself? It'd be cool if as part of wat we could do something like:
(export "module" (module))
(or something like that).
By providing the ability to hook into it that should be enough for various other tools I think to use the natively compiled module as part of ESM integration to send to other threads and such.
Now there's still a lot of weird questions specifically with the threading-related proposal about things like imports, but allowing a handle to the WebAssembly.Module
itself would also allow modules to introspect their own custom sections (I believe) even when integrated with native ESM integration.