{"id":26604,"library":"vite-plugin-workers-rs-unofficial","title":"vite-plugin-workers-rs-unofficial","description":"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.","status":"active","version":"0.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/aquilacf/workers-rs","tags":["javascript","vite","vite-plugin","cloudflare","cloudflare-workers","rust","wasm","worker-build","workers-rs","typescript"],"install":[{"cmd":"npm install vite-plugin-workers-rs-unofficial","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-workers-rs-unofficial","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-workers-rs-unofficial","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for Cloudflare integration and dev server proxying.","package":"@cloudflare/vite-plugin","optional":false},{"reason":"Peer dependency; supports Vite 6, 7, and 8.","package":"vite","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require is not supported.","wrong":"const cloudflareRustWorker = require('vite-plugin-workers-rs-unofficial')","symbol":"cloudflareRustWorker","correct":"import { cloudflareRustWorker } from 'vite-plugin-workers-rs-unofficial'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { cloudflareRustWorker } from 'vite-plugin-workers-rs-unofficial';\n\nexport default defineConfig({\n  plugins: [cloudflareRustWorker()],\n  environments: {\n    worker: {\n      consumer: 'server',\n      build: { outDir: 'dist/worker', emptyOutDir: false },\n    },\n  },\n});","lang":"typescript","description":"This config sets up the Rust worker plugin with Vite, specifying the worker environment and build output directory."},"warnings":[{"fix":"Ensure `rustBuild.outDir` (default 'build') matches wrangler.jsonc's `main` directory.","message":"The `outDir` option in `rustBuild` must match the directory specified in `wrangler.jsonc` `main` field.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Review the plugin source and verify compatibility with your Cloudflare Workers setup.","message":"The plugin is unofficial and not affiliated with Cloudflare. No official support or guarantees.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Adjust `debounceMs` and `maxRetries` options to reduce unnecessary restarts.","message":"During development, the plugin restarts the Vite dev server after each successful rebuild, which may cause brief interruptions.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install -D vite-plugin-workers-rs-unofficial` or ensure it is in package.json devDependencies.","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'vite-plugin-workers-rs-unofficial'"},{"fix":"Change `const { cloudflareRustWorker } = require(...)` to `import { cloudflareRustWorker } from 'vite-plugin-workers-rs-unofficial'`.","cause":"Using CommonJS `require` instead of ESM import.","error":"TypeError: (0 , vite_plugin_workers_rs_unofficial.cloudflareRustWorker) is not a function"},{"fix":"Install worker-build: `cargo install worker-build` and ensure it is on your PATH.","cause":"The `worker-build` CLI is not installed or not in PATH.","error":"Error: worker-build not found. Install with `cargo install worker-build`"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}