-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Automatically start execution on import. #1940
Conversation
Thanks for the PR here! I'm a bit wary to land this though because initialization can often require some form of configuration or tweaking, and I'm not sure we can reliable automatically start it on import all the time. It'd certainly be a nice goal to move towards though! (this is what es6 module integration is all about fwiw) |
What kind of configuration or tweaking do you mean?
Basically just user reasons that can be disabled with the flag, I can't figure out if there is something more technical, is there? In any case this PR enables automatic start by default, I don't think we should merge this because its going to break most builds, at least until we get more feedback. |
Yes primarily that hosting reasons mean that we don't actually know the structure of files 100% of the time, it may be tweaked from time to time. I believe contexts like web workers and such may also throw a wrench into the issue. |
What if we make a flag called This would be an ad-hoc solution, I don't know how else we would solve this issue. The alternative is of course to just wait for ES module integration of wasm. If this suggestion is not acceptable, and we can't come up with better alternatives, maybe we should do exactly that: leave everything as it is and wait for ES module integration, e.g. close this PR. |
I think I would personally prefer to wait for ES module integration to propagate more. The fact that you need to pass in a file is specific to the output type, and part of the output type is that simply you need to pass in a file of what to load. |
Alright. |
This changes
wasm-bindgen
to start execution when importing thejs
file by default and adds a flag to disable this behaviour.The
no-modules
part currently relies on #1938, I can change that if necessary.Currently what this does is change
init
/wasm_bindgen
from a function into a promise. The original function is now in an exportedinit
or respectively inwasm_bindgen
init.Having worked on this PR a little, made me realize that there is some bigger design work necessary, I can't change this PR in a draft, but discussion is obviously in #1939.
I would like to get some feedback on the documentation/description of the added flag.
Fixes #1939.