deno: add static ESM export for the webassembly bytes#88
Conversation
|
Thanks @kunring! I'm currently on mobile but will look into this, if the initialization is synchronous I'd probably do it either automatically in the module or lazily once. Would be important to see how this performs as it does the base64 decode on every run (although not sure how expensive it'd be, and definitely would be faster than a download), and it would mean creating new versions would be a bit more involved, but if the alternative is downloading the Wasm module on every run it may be worth it (does Deno not cache these at all?) |
|
Measured with Deno doesn't seem to cache |
|
I added a Deno script to generate the |
Description
Currently the .wasm file is only importable dynamically. This is a problem for multiple reasons. In the spirit of Deno's ecosystem, all imports that can be static should be static. Deno's native bundler won't be able to resolve dynamic imports, but instead leaves them as dynamic. This means that the .wasm has to be loaded from the internet every time the program is ran.
This change doesn't touch the current system, but instead adds an alternative static way to import the .wasm. Usage is as follows:
This is compliant with the static imports of the Deno ecosystem and Deno's bundler and compiler are able to resolve this to standalone files that don't require an internet connection to execute:

There should probably be a mention of this in the documentation, or this should be the only way to import the wasm in the deno module.
Type of change