wasmerio / wasmer-js

Monorepo for Javascript WebAssembly packages by Wasmer

Home Page:https://wasmerio.github.io/wasmer-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[SDK-43] Re-work the build system and compiled artifacts for `@wasmer/sdk`

Michael-F-Bryan opened this issue · comments

We currently allow users to import two different versions of the @wasmer/sdk package,

  • @wasmer/sdk - a slim version which tries to fetch() the wasmer_js_bg.wasm file at runtime
  • @wasmer/sdk/WasmerSDKBundled - a fat version where wasmer_js_bg.wasm has been stored in the compiled *.js file as a base64 string

We also produce these versions of the package in 3 different module formats,

  • UMD
  • CommonJS
  • ES Modules

This causes quite a few usability problems.

The biggest one is that, out of the box, you can almost never get @wasmer/sdk to load the right wasmer_js_bg.wasm file because of bundler weirdness, so the package becomes unusable without a lot of hacking.

I think we should change it so the bundled version is the default and people can import @wasmer/sdk/slim if they want to use the thin version. That will also give us a chance to mess around with the "slim" version a bit more without pushing out releases that break the package for everyone.

We might also want to consider switching to vite and using their ?url imports rather than depending on rollup or assuming where the wasmer_js_bg.wasm file will be placed by the end user's bundler.

A good resource for doing this sort of thing is Recommendations when publishing a Wasm library

CC: @syrusakbary

SDK-43