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
Especially after #1843, I think it would make a lot of sense that on importing the js file, it would immediately start init and therefore execute main.
This would solve a couple of issues:
Less boilerplate: <script src="wasm.js" type="module"></script> would be enough.
No need to call init.
No need to preload the js file (the wasm still needs to be preloaded).
Can be directly used with Worker, because it starts itself.
It should only start itself when main or wasm_bindgen(start) is used in rust, which should be pretty intuitive.
Behaving like other output modes, bundler and nodejs already do that.
Proposed Solution
Call init after its definition if needs_manual_start is true in cli-support.
Additionally we should add a flag to disable this functionality.
Alternatives
Potentially we could always call init to start loading the wasm file, even if there is no start function.
Hide this functionality behind a flag instead of making it default and disabling it by a flag.
Additional Context
I am afraid there was some reason that this functionality wasn't implemented already, I just can't figure out why.
EDIT: Just started to implement this when I found the other output modes already do that, only no-modules and web don't.
The text was updated successfully, but these errors were encountered:
Motivation
Especially after #1843, I think it would make a lot of sense that on importing the
js
file, it would immediately startinit
and therefore executemain
.This would solve a couple of issues:
<script src="wasm.js" type="module"></script>
would be enough.init
.js
file (thewasm
still needs to be preloaded).Worker
, because it starts itself.main
orwasm_bindgen(start)
is used in rust, which should be pretty intuitive.bundler
andnodejs
already do that.Proposed Solution
Call
init
after its definition ifneeds_manual_start
is true incli-support
.Additionally we should add a flag to disable this functionality.
Alternatives
init
to start loading thewasm
file, even if there is no start function.Additional Context
I am afraid there was some reason that this functionality wasn't implemented already, I just can't figure out why.
EDIT: Just started to implement this when I found the other output modes already do that, only
no-modules
andweb
don't.The text was updated successfully, but these errors were encountered: