Emscripten wasm - ES Module for npm package
We build spritely into a wasm file via emscripten. We are using the EXPORT_ES6=1 -s MODULARIZE=1 flags so the index.js file is an esmodule. In spritely.js we import that index.js file and add more glue-code to make a few more functions available.
This is a bit messy because we expect the loadSpritely function to be ran which pollutes the global scope with these functions.
One problem with this is that it loads the wasm file asyncronously.
Could we take advantage of webpack with the top level await feature enabled? https://webpack.js.org/configuration/experiments/
It would be nice if we could publish this as an npm package so that someone could easily run npm install spritely and then just import it as a standard library.