Skip to content

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

Description

@tobocop2

Problem

The wasm backend supports hand-written Rust modules in the binding crate (custom_rust_modules emits their pub mod declarations into the generated lib.rs), but the generated Cargo.toml has no way to carry [dev-dependencies]. Hand-written test files therefore cannot compile: an in-crate #[wasm_bindgen_test] suite needs wasm-bindgen-test as a dev-dependency, and the only routes today are hand-editing a DO-NOT-EDIT manifest (reverted on the next alef generate) or abusing extra_dependencies, which ships test-only crates as real dependencies of the published package.

Concretely in kreuzberg: xberg-io/xberg#1259 adds hand-written bridge/engine modules to crates/xberg-wasm through custom_rust_modules. The wasm-bindgen-test suites contributed for that code by @jamon8888 could not be carried into the crate and had to be ported to the JS e2e harness instead, because the generated manifest cannot declare the test harness.

Solution

Add extra_dev_dependencies to [crates.wasm], mirroring the existing per-language extra_dependencies (a name to toml value table). The wasm Cargo.toml 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions