Description
There are a lot of questions around the precise workflow and metadata expression for integrating Cargo and npm packages.
Design constraints
-
Consumers of Rust/wasm-based packages should be completely unaware that Rust
is involved. In particular, using such a package should not require a local
Rust toolchain.- This means that publication to npm is done in binary form: we upload a
.wasm
file containing the fully-compiled Rust code.
- This means that publication to npm is done in binary form: we upload a
-
You should be able to work on the Rust portion of the library using standard
Cargo workflows. -
There should be a straightforward way to express npm metadata (i.e. the
contents ofpackage.json
) for a Rust/wasm project.- That means, in particular, that a Rust project might pull in several crates,
each of which pulls in their own npm package dependencies.
- That means, in particular, that a Rust project might pull in several crates,
-
There should be an easy way to publish such a project to npm, handling all
needed transitive dependencies. -
Ultimately, JS bundlers (like WebPack and Parcel) will need to understand
wasm-based npm packages and generate the appropriate module instantiation.