Welcome to rust-wasmpack-loader
rust-wasmpack-loader is a powerful Webpack and Bun loader that enables seamless integration of Rust resources into your JavaScript/TypeScript projects through WebAssembly (WASM).
What is rust-wasmpack-loader?β
rust-wasmpack-loader is a native WASM loader for .rs
(Rust) resources that works with:
Key Featuresβ
π Easy Integration β Import .rs
files directly in your .js
or .ts
files without any headache
π§ Flexible Configuration β Supports both wasm_bindgen
and regular functions
π¦ Smart Discovery β Dynamically finds the Cargo.toml
file for building the WASM source
π Multi-Target Webpack Support β Works with web
and node
applications
β‘ Bun Compatible β Full support for Bun runtime (node target only for now)
Why Use rust-wasmpack-loader?β
- Simplicity: The most obvious one β No complex build setups, import and use
- Write computation-heavy code in Rust: Leverage Rust's performance for CPU-intensive tasks
- Ecosystem: Access the rich Rust ecosystem from your any projects
Quick Exampleβ
// Import Rust code directly
import wasmModule from './fibonacci.rs';
// Use the compiled WASM module
const result = wasmModule.fibonacci(10);
console.log(result); // Output: 55
// fibonacci.rs
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn fibonacci(n: u32) -> u32 {
match n {
0 => 0,
1 => 1,
_ => fibonacci(n - 1) + fibonacci(n - 2),
}
}
Getting Startedβ
Ready to boost your projects with native WebAssembly support? Let us get started!
π Installation Guide
π Quick Start Tutorial
Examplesβ
Check the example folder in the repository for a better understanding of how the loader works with different setups:
- Web Webpack - Browser applications
- Node.js Webpack - Server-side applications
- Bun Node.js - High-performance Bun runtime
Contributingβ
Contributions are always welcome!
See CONTRIBUTING.md for ways to get started.
Please feel free to:
- π Report bugs and issues
- π‘ Suggest new features
- π Improve documentation
- π§ Submit pull requests
Acknowledgementsβ
Special thanks to the projects that inspired and helped make rust-wasmpack-loader possible:
- @wasm-tool/wasm-pack-plugin - Original inspiration for WebAssembly integration
- wasm-pack - The amazing tool that makes Rust-to-WASM compilation seamless
Licenseβ
This project is licensed under the MIT License.
See the LICENSE file for details.
Community & Supportβ
- π Documentation
- π Report Issues
- π¬ GitHub Discussions
- π¦ NPM Package
Built with β€οΈ by Yehor Brodskiy