-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronous access to module compiled with WASM=0 #12647
Comments
It looks like this was done in #10697, perhaps? Maybe @lourd has some advise on how to proceed. Its not just JS that allows for synchronous access, small wasm modules can also be loaded synchronously? Is it possible that your users could synchronously import h3-js but that those functions that come from emscripten would not be available to them right away? |
When |
Thanks for the quick response! That looks great.
I did consider this, but "Here's a library, when you call its functions they may fail non-deterministically" didn't seem like the best developer experience 😁 . |
MODULARIZE + WASM_ASYNC_COMPILATION=0, that is, modularize mode but with async compilation turned off, so that startup is synchronous, should return the Module object from the factory function (as it would not make sense to return a Promise without async startup). Fixes #12647
I'm using emscripten to compile C code for the h3-js library. The library is currently compiled as JS, not WASM (though we'd like to also add a WASM version as well in the future). We're currently using emscripten
v1.38.43
, and I was planning to upgrade, but after some digging I can see that there's a breaking change inv1.39.16
to return a Promise instead of the module itself when usingMODULARIZE
.I can't use the async approach without forcing all of my library consumers to import
h3-js
in an async manner as well, which is a breaking change and contrary to the goals of the library and expectations of the users, which assume that the library is just a set of pure functions.My assumption is that if I'm not using WASM, the initialization of the module is actually synchronous. Is there a way to synchronously access it in this case? The alternative seems to be to stay on our current version of Emscripten indefinitely.
The text was updated successfully, but these errors were encountered: