1 unstable release
| 0.1.0 | Nov 14, 2025 |
|---|
#34 in #rust-cli
66KB
1.5K
SLoC
r2n - Rust to npm
A library for rapidly shipping Rust projects to npm.
This library provides programmatic APIs for:
- Initializing new Rust projects configured for npm
- Building cross-platform binaries, NAPI modules, and WASM packages
- Managing monorepo workspaces (npm and Cargo)
- Publishing to npm with various distribution strategies
Usage
use r2n::{InitProject, InitOptions, PackageType};
let options = InitOptions {
name: "my-tool".into(),
package_type: PackageType::Cli,
..Default::default()
};
let project = InitProject::new(options)?;
project.create()?;
r2n
Ship Rust CLI tools to npm.
⚠️ EXPERIMENTAL: This package is experimental and should not be used in production. APIs and behavior may change without notice.
Install
cargo install r2n
Usage
Create a new project
r2n init my-tool
cd my-tool
Add to existing Rust project
cd my-rust-project
r2n add
Build
r2n build
This cross-compiles your Rust binary and creates an npm package ready to publish.
What it does
- Creates
package.jsonwith proper bin configuration - Generates a Node.js wrapper script
- Cross-compiles your Rust binary for multiple platforms
- Outputs to
dist/ready for npm publish
License
MIT OR Apache-2.0
Dependencies
~4–14MB
~139K SLoC