{"id":16872,"library":"parcel-plugin-wasm.rs","title":"Parcel 1.x wasm-bindgen plugin for Rust","description":"parcel-plugin-wasm.rs is a Parcel 1.x bundler plugin designed to integrate Rust projects compiled to WebAssembly (Wasm) using `wasm-bindgen`. It streamlines the development workflow by automatically compiling Rust code with `wasm-pack` when Parcel 1.x builds the project. The latest stable version available is 1.3.0. A key differentiator was its ability to provide zero-configuration Rust/Wasm compilation for Parcel projects at a time when such integration was less mature. However, it is explicitly designed for `parcel-bundler` (Parcel 1.x), which has been officially deprecated and is no longer maintained. Parcel 2.x includes its own `@parcel/transformer-rust` for native Rust/Wasm support, rendering this plugin obsolete for modern Parcel environments.","status":"abandoned","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/catsigma/parcel-plugin-wasm.rs","tags":["javascript"],"install":[{"cmd":"npm install parcel-plugin-wasm.rs","lang":"bash","label":"npm"},{"cmd":"yarn add parcel-plugin-wasm.rs","lang":"bash","label":"yarn"},{"cmd":"pnpm add parcel-plugin-wasm.rs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; this plugin only works with Parcel 1.x, which is unmaintained.","package":"parcel-bundler","optional":false},{"reason":"External tool required for compiling Rust code. Must be installed globally.","package":"cargo","optional":false},{"reason":"External tool required for generating WebAssembly from Rust. Must be installed globally.","package":"wasm-pack","optional":false}],"imports":[{"note":"Named imports are used for functions exported from Rust via `#[wasm_bindgen]`.","symbol":"foo","correct":"import { foo } from 'path/to/Cargo.toml'"},{"note":"Default import provides access to the raw WASM module and its exports, including `memory`.","symbol":"lib","correct":"import lib from 'path/to/Cargo.toml'"},{"note":"TypeScript type imports for the generated WASM module structure.","symbol":"WasmModule","correct":"import type { WasmModule } from 'path/to/Cargo.toml'"}],"quickstart":{"code":"/* file: my-crate/src/lib.rs */\nextern crate wasm_bindgen;\nuse wasm_bindgen::prelude::*;\n\n#[wasm_bindgen]\npub fn greet(name: &str) -> String {\n  format!(\"Hello, {}!\", name)\n}\n\n/* file: src/index.js */\nimport { greet } from '../my-crate/Cargo.toml';\n\ndocument.getElementById('app').innerHTML = `\n  <h1>Rust + WebAssembly in Parcel 1.x</h1>\n  <p>${greet('Parcel user')}</p>\n`;\n\nconsole.log('Greeting from Rust:', greet('world'));\n\n/* file: package.json (relevant part) */\n{\n  \"name\": \"my-parcel-wasm-app\",\n  \"version\": \"1.0.0\",\n  \"devDependencies\": {\n    \"parcel-bundler\": \"^1.12.5\",\n    \"parcel-plugin-wasm.rs\": \"^1.3.0\"\n  },\n  \"scripts\": {\n    \"start\": \"parcel src/index.html\",\n    \"build\": \"parcel build src/index.html\"\n  }\n}\n\n/* file: src/index.html */\n<!DOCTYPE html>\n<html>\n<head>\n  <title>Parcel WASM Example</title>\n</head>\n<body>\n  <div id=\"app\"></div>\n  <script src=\"index.js\"></script>\n</body>\n</html>","lang":"javascript","description":"Demonstrates a basic setup for integrating a Rust project compiled to WebAssembly with Parcel 1.x using `parcel-plugin-wasm.rs`. It includes the necessary Rust, JavaScript, and `package.json` configurations to greet a user from WebAssembly."},"warnings":[{"fix":"For new projects or migration, use Parcel 2.x and its built-in `@parcel/transformer-rust`. For existing Parcel 1.x projects, consider migrating to Parcel 2.x or remaining on Parcel 1.x with caution regarding security and updates.","message":"This plugin targets `parcel-bundler` (Parcel 1.x), which is officially unmaintained. It is not compatible with Parcel 2.x. Using it with Parcel 2.x will lead to build failures or incorrect behavior. Parcel 2.x has its own native support for Rust/Wasm via `@parcel/transformer-rust`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure `cargo` (Rust toolchain) and `wasm-pack` are installed and available in your system's PATH. Check installation instructions for Rust and `wasm-pack`.","message":"Requires external tools `cargo` and `wasm-pack` to be installed globally on the system where Parcel is running. Missing these tools will result in compilation errors during the Parcel build process.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set the environment variable explicitly before your Parcel command, for example: `WASM_PACK_PROFILE=dev parcel src/index.html` or `cross-env WASM_PACK_PROFILE=dev parcel src/index.html` for cross-platform compatibility.","message":"The `WASM_PACK_PROFILE` environment variable is used to control the `wasm-pack build` profile (e.g., `dev`, `release`). This variable needs to be set in the shell before running Parcel commands.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Verify the path to `Cargo.toml` is correct. Ensure `parcel-plugin-wasm.rs` is listed in `devDependencies` in `package.json`. Confirm that `cargo` and `wasm-pack` are installed and working. Check Parcel's build logs for underlying Rust/Wasm compilation errors.","cause":"Parcel 1.x cannot locate or process the Rust crate defined by the `Cargo.toml` path, often due to incorrect pathing, missing `parcel-plugin-wasm.rs` in `devDependencies`, or issues with `cargo`/`wasm-pack` installation preventing the WASM module from being generated.","error":"Error: Cannot find module 'path/to/Cargo.toml'"},{"fix":"Install the appropriate C++ build tools for your platform, usually by installing 'Desktop development with C++' from Visual Studio Installer on Windows, or `build-essential` on Linux/macOS. Ensure the Rust toolchain is properly configured for your target.","cause":"Rust compilation failed because the linker required by the Rust toolchain is not found. This often occurs on Windows systems if a C++ build environment (like MSVC) is not installed or configured correctly.","error":"error: linker `link.exe` not found"},{"fix":"Try clearing Parcel's cache (`rm -rf .parcel-cache dist`) and rebuilding. Review your Rust project's `build.rs` or `Cargo.toml` for any non-standard configurations. This may also be a plugin-specific bug that has not been resolved.","cause":"This error, reported in issue #37 on the plugin's GitHub, indicates a problem with Parcel's caching mechanism interacting with Rust's build system, possibly related to `build.rs` files or project structure.","error":"🚨 Error writing to cache: ENOENT: no such file or directory, stat 'build.rs'"}],"ecosystem":"npm","meta_description":null}