You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an experimental way to export a "static" ES module.
Adds a new mode -sMODULARIZE=static which will change the output to be more of
a static ES module. As mentioned in the docs, there will be a default async
init function exported and named exports that correspond to Wasm and runtime
exports. See the docs and test for an example.
Internally, the module will now have an init function that wraps nearly all
of the code except some top level variables that will be exported. When the
init function is run, the top level variables are then updated which will
in turn update the module exports. E.g.
```
async function init(moduleArgs) {
function foo() {};
x_foo = foo;
x_bar = wasmExports['bar'];
}
var x_foo, x_bar;
export {x_foo as foo, x_bar as bar};
```
Note: I alternatively tried to keep everything at the top level scope and move
only the code that reads from moduleArg into an init function. This would make
it possible to get rid of the `x_func` vars and directly add `export` to
vars/functions we want to export. However, there are lots of things that read
from moduleArg in many different spots and ways which makes this challenging.
0 commit comments