Parcel 2: Rust transformer
See original GitHub issueCreate the @parcel/transformer-rust
package in packages/transforms/rust
. This package is a Parcel 2 transform plugin for Rust to WASM. It should be based on the RustAsset
from Parcel 1.
The @parcel/transformer-rust
package is responsible for the following things:
- Installing the rust toolchain if needed
- Resolving Cargo.toml and running cargo if available.
- Otherwise, running rustc
- Collecting dependencies from the rust compiler and adding them as connected files so Parcel watches them
- Generating WASM
It is possible that the current approach in Parcel 1 is out of date. Additional research on the current Rust/WASM ecosystem is needed here. Some related issues:
There are also some plugins that have been working on some related stuff:
- https://github.com/mysterycommand/parcel-plugin-wasm-pack
- https://github.com/catsigma/parcel-plugin-wasm.rs
- https://github.com/rustwasm/rust-parcel-template
If someone from the community would like to own this feature in Parcel 2 core, that would be very helpful and appreciated! 😍
cc. @xtuc @linclark @littledan @alexcrichton - what’s the current state of WASM + Rust + ESM? What should we be aiming for in Parcel 2?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:28
- Comments:34 (7 by maintainers)
I would just like to point out that in Rust, compilation happens at the crate level, not the file level.
That also means that all
extern
functions in Rust are exported from the crate, not individual files.So it doesn’t make any sense to import an individual
.rs
file, instead you should import theCargo.toml
file (which represents the entire crate).This is something to keep in mind for the new Rust transformer.
Thanks for the cc @devongovett! The current state of Rust/WASM/ESM is that tooling like
wasm-bindgen
andwasm-pack
have a “bundler” target which is intended to be consumed by Parcel/Webpack/etc. This “bundler” target assumes that the output wasm file is interpreted as an ES module and follows the wasm ESM integration spec.From our perspective having Parcel act as a polyfill for the wasm ESM integration spec would cover all our use cases!