Registry / devops / vite-plugin-workers-rs-unofficial

vite-plugin-workers-rs-unofficial

JSON →
library0.3.0jsnpmunverified

An unofficial community-maintained Vite plugin (v0.3.0) that integrates Rust worker-build with @cloudflare/vite-plugin, enabling development and deployment of Cloudflare Workers written in Rust using Vite's dev server, HMR, and build pipeline. Key differentiators: it automatically compiles Rust to WebAssembly via worker-build, handles file watching with debounce, and configures @cloudflare/vite-plugin for seamless dev and build workflows. Requires Rust toolchain, wasm32-unknown-unknown target, and worker-build CLI. Release cadence is rapid, with multiple minor versions per months.

npm install vite-plugin-workers-rs-unofficial
INSTALL
IMPORT
SIG · VITE-PLUGIN-WORKER
V
vite-plugin-workers-rs-unofficial
devopsjavascriptv0.3.0
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.

cloudflareRustWorker
import { cloudflareRustWorker } from 'vite-plugin-workers-rs-unofficial'
const cloudflareRustWorker = require('vite-plugin-workers-rs-unofficial')
ESM-only package; CommonJS require is not supported.

This config sets up the Rust worker plugin with Vite, specifying the worker environment and build output directory.

// vite.config.ts import { defineConfig } from 'vite'; import { cloudflareRustWorker } from 'vite-plugin-workers-rs-unofficial'; export default defineConfig({ plugins: [cloudflareRustWorker()], environments: { worker: { consumer: 'server', build: { outDir: 'dist/worker', emptyOutDir: false }, }, }, });
Debug
Known issues
gotchaThe `outDir` option in `rustBuild` must match the directory specified in `wrangler.jsonc` `main` field.
fix
Ensure `rustBuild.outDir` (default 'build') matches wrangler.jsonc's `main` directory.
affects: >=0.1.0
gotchaThe plugin is unofficial and not affiliated with Cloudflare. No official support or guarantees.
fix
Review the plugin source and verify compatibility with your Cloudflare Workers setup.
affects: >=0.1.0
gotchaDuring development, the plugin restarts the Vite dev server after each successful rebuild, which may cause brief interruptions.
fix
Adjust `debounceMs` and `maxRetries` options to reduce unnecessary restarts.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-workers-rs-unofficial'
Package not installed or missing from node_modules.
fix
Run `npm install -D vite-plugin-workers-rs-unofficial` or ensure it is in package.json devDependencies.
TypeError: (0 , vite_plugin_workers_rs_unofficial.cloudflareRustWorker) is not a function
Using CommonJS `require` instead of ESM import.
fix
Change `const { cloudflareRustWorker } = require(...)` to `import { cloudflareRustWorker } from 'vite-plugin-workers-rs-unofficial'`.
Error: worker-build not found. Install with `cargo install worker-build`
The `worker-build` CLI is not installed or not in PATH.
fix
Install worker-build: `cargo install worker-build` and ensure it is on your PATH.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
@cloudflare/vite-pluginrequiredPeer dependency required for Cloudflare integration and dev server proxying.
viterequiredPeer dependency; supports Vite 6, 7, and 8.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-workers-rs-unofficial — npm install vite-plugin-workers-rs-unofficial · libregistry