This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Farm is an extremely fast, Vite-compatible web build tool written in Rust (v2.x beta). It is a hybrid Rust + TypeScript monorepo using pnpm workspaces and Cargo workspace. The Rust compiler is exposed to Node.js via napi-rs.
| Command | Purpose |
|---|---|
pnpm bootstrap |
First-time setup: install deps + build core packages |
pnpm run ready |
Full CI gate (install, clean, build, lint, type-check, test, e2e) |
pnpm run test |
TypeScript unit tests (vitest) |
pnpm run test-e2e |
E2E tests (vitest + Playwright) |
cargo test |
Rust unit tests |
cargo test -p farmfe_compiler |
Run tests for a specific Rust crate |
cargo test --profile ci-test |
Run Rust tests with CI-optimized profile |
pnpm run check |
Biome lint + format |
cargo clippy |
Rust linter |
cargo check --all --all-targets |
Type-check all Rust code without building |
pnpm run spell-check |
cspell across all files |
INSTA_UPDATE=always cargo testto update snapshots- Or set
INSTA_UPDATE=alwaysenv var on Windows
farmfe_core(crates/core/) — Central type system:Config,Module,ModuleGraph, thePlugintrait, caching infrastructure. Everything depends on it.farmfe_toolkit(crates/toolkit/) — SWC-based transformation engine (parse, codegen, minify, transpile for JS/CSS/HTML).- Builtin plugins (
crates/plugin_*) — 16+ crates implementing thePlugintrait, compiled statically into the compiler. Pipeline-critical ones:plugin_resolve,plugin_script,plugin_css,plugin_html,plugin_runtime,plugin_tree_shake. Optimization:plugin_minify,plugin_partial_bundling. farmfe_compiler(crates/compiler/) — Orchestrator that wires all builtin plugins together based on config.farmfe_node(crates/node/) — napi-rs cdylib bridging Rust to Node.js. The primary delivery vehicle.rust-plugins/— External plugins compiled to cdylib and loaded dynamically at runtime (react, sass, tailwindcss, dts, replace-dirname). Other directories here are JS-only.
packages/core(@farmfe/core) — Main package: dev server, file watcher, compiler JS wrapper, plugin bridge. Wraps the native Rust binding.packages/cli(@farmfe/cli) — CLI entry point (farmbin), uses cac.packages/runtime(@farmfe/runtime) — Browser runtime (module system, HMR).js-plugins/— Official JS plugins (postcss, less, sass, svgr, dts, visualizer, tailwindcss, electron). Each uses Farm itself as its build tool (dogfooding).
User Code → @farmfe/cli → @farmfe/core (resolveConfig, createCompiler)
→ Compiler (JS wrapper) → BindingCompiler (napi-rs native addon)
→ farmfe_node cdylib → Rust compiler pipeline → Results as JS objects
The native binding is built via napi build --platform -p farmfe_node --manifest-path ../../crates/node/Cargo.toml and outputs packages/core/binding/binding.cjs + binding.d.ts.
- Rust: edition 2021, toolchain pinned in
rust-toolchain.toml, format withrustfmt.toml, lint withcargo clippy - TypeScript: Biome for format+lint (
biome.json), ESM source with dual CJS+ESM output,tsconfig.base.jsonas base - Git: Conventional Commits (
feat:,fix:,chore:), changesets for versioning (npx changeset), PR titles must match Conventional Commits - Package manager: pnpm v9.4.0 (enforced)
- Node: >=20
- Force push or hard reset without explicit approval
- Edit
pnpm-lock.yamlmanually - Edit generated files (
.d.tsindist/, binding files) - Bypass hooks with
--no-verify