Note: This page covers Parcel 1, the documentation for Parcel 2 is being worked on here:


Supported extensions: rs

Rust is a systems programming language developed by Mozilla, which offers native performance with some interesting memory and thread safety characteristics. Rust recently added support for compiling to WebAssembly, and now Parcel makes it super easy to get started with zero configuration!

You can now simply import .rs files just like any other file type in Parcel! Assuming you have Rustup installed, Parcel automatically takes care of installing the right toolchains, targets, and other build pre-requisites. It works with Cargo projects, as well as straight-up Rust source files, automatically tracks your dependencies so files are watched and rebuilds happen when you save, and more!

Just like with .wasm files, .rs files can be imported with either synchronous or asynchonous imports.

// synchronous import
import { add } from './'
console.log(add(2, 3))
// asynchronous import
const { add } = await import('./')
console.log(add(2, 3))

On the Rust side, you just need to make sure that function names aren’t mangled and are public.

pub fn add(a: i32, b: i32) -> i32 {
  return a + b

You can also import rust project by importing src/ or src/, Parcel will call cargo to build the project.

import { sub } from './sub/src/'
console.log(sub(2, 3))

in ./sub/Cargo.toml:



crate-type = ["cdylib"]

in ./sub/src/

pub fn sub(a: i32, b: i32) -> i32 {
    a - b

See also this complete example.

Help us improve the docs

If something is missing or not entirely clear, please file an issue on the website repository or edit this page.