Skip to content

Automatically camelify names #1818

@Pauan

Description

@Pauan

Motivation

Right now you can use js_name to convert a Rust foo_bar into JS fooBar (or vice versa). But 99% of the time you want it to be camel case, so this just ends up being repetitive boilerplate:

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_name = fooBar)]
    fn foo_bar(...);

    #[wasm_bindgen(js_name = quxCorge)]
    fn qux_corge(...);

    #[wasm_bindgen(js_name = yesNo)]
    fn yes_no(...);
}

Proposed Solution

wasm-bindgen should automatically camelify JS names, so foo_bar will be translated into fooBar on import/export.

It will still be possible to use js_name to manually override that if the user does not want camel-case.

This is a breaking change, so we should batch it together with other breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeTracking breaking changes for the next major version bump (if ever)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions