Introduction
Farm is a web build tool written in Rust that aims to be a faster drop-in replacement for Vite. It compiles TypeScript, JSX, CSS, and static assets with native speed while maintaining compatibility with the Vite plugin ecosystem. Farm handles both development with instant HMR and production builds with tree shaking and code splitting.
What Farm Does
- Compiles TypeScript, JSX, CSS modules, and static assets using a Rust-native pipeline
- Provides Vite-compatible plugin support so existing Vite plugins work with minimal changes
- Delivers sub-millisecond hot module replacement during development
- Performs tree shaking, code splitting, and minification for optimized production builds
- Supports partial bundling: a strategy between full bundling and unbundled ESM for optimal loading
Architecture Overview
Farm uses a Rust-native compilation pipeline where parsing, transforming, and code generation all happen in Rust. It supports a plugin system compatible with Vite's rollup-style hooks, with a JavaScript plugin adapter for running existing Vite/Rollup plugins. The partial bundling strategy groups modules into optimally-sized chunks based on dependency analysis, avoiding both the waterfall problem of unbundled ESM and the monolithic output of full bundling.
Self-Hosting & Configuration
- Scaffold a project with
npm create farm@latestand pick a framework template - Configure in
farm.config.tswithdefineConfig()for type-safe options - Add Vite plugins via the
vitePluginsconfig array for compatibility - Set
compilation.minifyandcompilation.treeShakingfor production optimization - Use
server.proxyfor API proxying during development
Key Features
- Rust-native core delivers build speeds measured in milliseconds, not seconds
- Vite plugin compatibility allows reuse of the existing Vite ecosystem
- Partial bundling optimizes chunk sizes without manual splitting configuration
- Built-in support for TypeScript, JSX, CSS modules, and PostCSS
- Persistent cache across builds for near-instant rebuilds on incremental changes
Comparison with Similar Tools
- Vite — uses esbuild + Rollup; Farm is fully Rust-native and faster for large projects
- Rspack — Webpack-compatible; Farm is Vite-compatible with a different plugin model
- Turbopack — Vercel-specific, Next.js focused; Farm is framework-agnostic
- esbuild — fast but limited CSS and plugin support; Farm is a full-featured build tool
- Rolldown — Rust Rollup replacement; Farm is a complete build tool, not just a bundler
FAQ
Q: Can I use my existing Vite plugins with Farm? A: Yes. Farm supports Vite plugins through a compatibility layer. Most Vite plugins work without modification.
Q: How does partial bundling work? A: Farm analyzes the module graph and groups modules into chunks optimized for parallel loading, balancing between too many requests and too-large bundles.
Q: Does Farm support React, Vue, and Svelte? A: Yes. Farm provides official plugins for React, Vue, Svelte, and Solid with starter templates for each.
Q: Is Farm ready for production use? A: Farm has reached stable releases and is used in production projects, with active development and growing adoption.