Skip to content

feat(wasm): support extra_dev_dependencies in the generated binding Cargo.toml#182

Merged
Goldziher merged 1 commit into
xberg-io:mainfrom
tobocop2:feat/wasm-extra-dev-dependencies
Jul 19, 2026
Merged

feat(wasm): support extra_dev_dependencies in the generated binding Cargo.toml#182
Goldziher merged 1 commit into
xberg-io:mainfrom
tobocop2:feat/wasm-extra-dev-dependencies

Conversation

@tobocop2

@tobocop2 tobocop2 commented Jul 18, 2026

Copy link
Copy Markdown
Member

Closes #181.

Problem

The wasm backend supports hand-written modules in the binding crate through custom_rust_modules, but the generated Cargo.toml cannot carry [dev-dependencies]. Hand-written test files don't compile: an in-crate #[wasm_bindgen_test] suite needs wasm-bindgen-test, and the only routes were hand-editing a DO-NOT-EDIT manifest or shipping test-only crates as real dependencies through extra_dependencies.

In xberg-io/xberg#1259 this forced the contributed wasm-bindgen suites out of the crate and into the JS e2e harness.

Solution

A new [crates.wasm.extra_dev_dependencies] table, mirroring the per-language extra_dependencies. When it is non-empty, the cargo generator emits a [dev-dependencies] section between [dependencies] and the target-specific block: sorted, string values quoted, structured values passed through.

An empty table emits nothing, so existing projects regenerate byte-identically.

Verification

A unit test covers both value shapes and the empty-table case (cargo test -p alef --lib backends::wasm::gen_bindings::tests, 9 passed). cargo clippy --lib --tests -- -D warnings and cargo fmt --check are clean.

…argo.toml

The wasm backend supports hand-written modules in the binding crate via
custom_rust_modules, but the generated Cargo.toml had no way to carry
dev-dependencies, so hand-written test files could not compile: an
in-crate #[wasm_bindgen_test] suite needs wasm-bindgen-test, and the only
routes were hand-editing a DO-NOT-EDIT manifest or shipping test-only
crates as real dependencies through extra_dependencies.

Adds [crates.wasm.extra_dev_dependencies], mirroring the per-language
extra_dependencies table. The cargo generator emits a [dev-dependencies]
section between [dependencies] and the target-specific block when the
table is non-empty: sorted, string values quoted, structured values
passed through. An empty table emits nothing, so existing projects
regenerate byte-identically.
@tobocop2

tobocop2 commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

@jamon8888 tagging you here too. This closes the generator gap that kept your wasm-bindgen test suites out of xberg-io/xberg#1259. Once it ships, they move back into the crate.

@Goldziher
Goldziher merged commit c5e5a0f into xberg-io:main Jul 19, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasm: generated Cargo.toml cannot declare dev-dependencies for hand-written test files

2 participants