Repository navigation
feat: support multiple and private #[wasm_bindgen(start)] functions - #5081
Merged
Merged
Conversation
guybedford
force-pushed
the
feat/multiple-start-functions
branch
5 times, most recently
from
April 3, 2026 02:32
ccf22dc to
a50adec
Compare
#[wasm_bindgen(start)] functions#[wasm_bindgen(start)] functions
guybedford
force-pushed
the
feat/multiple-start-functions
branch
from
April 3, 2026 02:34
a50adec to
9392b9d
Compare
guybedford
force-pushed
the
feat/multiple-start-functions
branch
from
April 6, 2026 18:16
459ad06 to
c151ba5
Compare
…_bindgen(start, private)]` Previously, specifying more than one `#[wasm_bindgen(start)]` function would error with "cannot specify two `start` functions". This removes that restriction and chains multiple start functions together. Also adds support for `#[wasm_bindgen(start, private)]` which registers the function as a start function without exporting it to JS. The `start: bool` field in the shared schema is replaced with a `StartKind` enum (None, Public, Private).
guybedford
force-pushed
the
feat/multiple-start-functions
branch
from
April 6, 2026 22:40
5da733f to
93635bc
Compare
Contributor
|
How do you tell what order multiple start functions should run in? |
Contributor
Author
|
We basically have zero ordering guarantees. |
Contributor
|
Is it fair to call it a start function anymore then? I think that is more like a C constructor. Does Rust allow similar things on other platforms? |
Contributor
Author
|
The use case is more about the JS embedding - JavaScript modules participate in initialization steps that are able to interact with the host environment. This gives that capacity to separate Rust code, without requiring a singular coordination point, just like modules in JS don't need to register their top-level initializations to access things like globals. |
Contributor
Author
|
I'm open to giving it a new alias, but this does match the |
hoodmane
reviewed
Apr 6, 2026
hoodmane
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for multiple start functions by chaining them together when registered, including an end-to-end CLI test to verify execution order.
Also adds support for
#[wasm_bindgen(start, private)]to declare private start functions which are not exported by the Wasm exports. This one implies a schema bump.