Registry / devops / vite-plugin-rsw

vite-plugin-rsw

JSON →
library2.0.11jsnpmunverified

A wasm-pack plugin for Vite that enables WebAssembly integration via Rust crates. v2.0.11 requires Vite >=2.8.0 and supports HMR, friendly error messages, and automatic rebuilding. It relies on the `rsw` CLI tool (cargo install rsw) to manage Rust crate generation and linking. Differentiated by its seamless Vite plugin approach vs manual wasm-pack setup. Active development.

npm install vite-plugin-rsw
INSTALL
IMPORT
SIG · VITE-PLUGIN-RSW
V
vite-plugin-rsw
devopsjavascriptv2.0.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ViteRsw
import { ViteRsw } from 'vite-plugin-rsw'
import ViteRsw from 'vite-plugin-rsw'
Named export, not default.
ViteRsw (CommonJS)
const { ViteRsw } = require('vite-plugin-rsw')
const ViteRsw = require('vite-plugin-rsw')
CommonJS requires destructuring.
ViteRsw (type import)
import type { ViteRswOptions } from 'vite-plugin-rsw'
Option type available for TypeScript users.

Shows basic setup: import plugin, add to Vite config, install rsw CLI, generate and link a Rust crate.

// vite.config.ts import { defineConfig } from 'vite'; import { ViteRsw } from 'vite-plugin-rsw'; export default defineConfig({ plugins: [ViteRsw()], }); // Then ensure rsw tool is installed: // cargo install rsw // Initialize: yarn rsw init // Generate crate: yarn rsw new rsw-hello // Configure rsw.toml with [[crates]] name and link=true
Debug
Known issues
gotchaRequires rsw CLI to be installed via cargo before use
fix
Run `cargo install rsw`
affects: >=2.0.0
gotcharsw.toml must have link=true for the crate to be linked
fix
Set link = true under [[crates]] in rsw.toml
affects: >=2.0.0
breakingVite peer dependency changed from >=2.4.0 to >=2.8.0 in v2.0.0
fix
Upgrade Vite to >=2.8.0
affects: >=2.0.0
gotchaMust run `rsw watch` and Vite separately for dev with HMR
fix
Use script: 'rsw watch & vite' (or concurrently)
affects: >=2.0.0
gotchaBuild script requires running `rsw build` before Vite build
fix
Use script: 'rsw build && tsc && vite build'
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-rsw'
Package not installed or import path wrong
fix
Install via npm/yarn: npm i -D vite-plugin-rsw
error[E0554]: `#![feature]` may not be used on the stable release channel
Rust nightly feature required by generated crate
fix
Switch to Rust nightly: rustup default nightly
Error: wasm-pack build failed
Missing Rust toolchain or crate errors
fix
Ensure Rust, wasm-pack, and required target (e.g., wasm32-unknown-unknown) are installed
Error: rsw.toml not found
Missing configuration file in project root
fix
Run `yarn rsw init` to generate rsw.toml
Upgrade
Version history
2.0.11latest on npm
Audit
Dependencies
viterequiredpeer dependency: required as plugin host, version >=2.8.0
Agent activity
2 hits · last 30 days
node
2
Resources
vite-plugin-rsw — npm install vite-plugin-rsw · libregistry