question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parcel 2: Rust transformer

See original GitHub issue

Create 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:

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:open
  • Created 4 years ago
  • Reactions:28
  • Comments:34 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
Pauancommented, Jan 8, 2020

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 the Cargo.toml file (which represents the entire crate).

This is something to keep in mind for the new Rust transformer.

8reactions
alexcrichtoncommented, Aug 12, 2019

Thanks for the cc @devongovett! The current state of Rust/WASM/ESM is that tooling like wasm-bindgen and wasm-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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parcel 2 beta 3
Parcel's new JavaScript transformer is written in Rust on top of the SWC compiler. SWC provides JavaScript parsing and code generation, ...
Read more >
Parcel 2: Rust-Based 10x Faster JavaScript Compiler ... - InfoQ
Parcel's new JavaScript transformer is written in Rust, on top of swc. Besides JavaScript, swc also replaces Babel by default for ...
Read more >
@parcel/transformer-yaml v2.6.2 Bundlephobia
Size of @parcel/transformer-yaml v2.6.2 is 171.6 kB (minified), and 41.5 kB when compressed using GZIP. Bundlephobia helps you find the performance impact ...
Read more >
What you need to know about Parcel 2 - LogRocket Blog
Parcel 2 has been in the works for three years, and it's essentially a full remake of Parcel from the ground up. Its...
Read more >
parcel/transformer-webmanifest NPM
Parcel supports many different languages and file types out of the box, from web technologies like HTML, CSS, and JavaScript, to lower level...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found