Farm is a super fast, light-weight web building tool written in Rust. Farm is much faster than existing tools, benchmark(Using Turbo pack's benchmark, 1000 React components) as below:
Test Repo:https://github.com/farm-fe/performance-compare
Test Machine(Linux Mint 21.1 Cinnamon, 11th Gen Intel© Core™ i5-11400 @ 2.60GHz × 6, 15.5 GiB)
- ⚡ Super Fast: Written in Rust, start a react / vue(incoming) project in milliseconds, perform a HMR update within 10ms for the most situations.
- 🧰 Fully Pluggable: Everything inside Farm is powered by plugins, achieve anything you want by creating a plugin. Support both rust plugins and js plugins.
- ⚙️ Powerful: Support compiling JS/TS/JSX/TSX, css, html and static assets out of box.
- ⏱️ Lazy Compilation: Dynamic imported resources are compiled only when they are requested.
- 📦 Partial Bundling: Bundle your project into a few reasonable bundles, speed up the resources loading without losing the caching granularity.
- 🔒 Consistency: What you see in development will be exactly the same as what you've got in production.
- 🌳 Compatibility: Support both legacy(es5) and modern browsers.
Note:
- See RFC-001 for design motivation and principle.
- This project is still under development. Contributions are welcome.
This project is built on the SWC Project, using swc for html/css/js/tsx/ts/jsx parsing, transforming, optimizing and codegen.
Create a new Farm Project
npx @farmfe/cli@latest createStart the project:
cd farm-react && npm i && npm startRefer to Documentation to learn more about Farm.
Farm has implemented all basic features for a web building tool:
- Resolving, loading, transforming and resource generating for web assets(html, css, js/jsx/ts/tsx, static asset and so on).
- Lazy Compilation
- Dev Server and HMR(support react fast fresh)
- Partial Bundling
- Both Rust and Js Plugin System
Next Farm will provide:
- Production Optimization like Minimize and Tree Shake
- Css modules
- Source Map
- Official Plugins Like Sass
- Persistent Cache
See milestones: https://github.com/farm-fe/farm/milestones
Looking forward to more contributions. Our goal is to provide a real high quality and performant web build tool for the community.
Farm is divided into two parts: the js side and the rust side:
- the js side: see code in
packagesdir, contains core(dev server, file watcher and compiler wrapper), cli, runtime and runtime plugins(module system, hmr) - the rust side: see code in
cratesdir, contains core(compilation context, plugin drivers...), compiler(compile process, HMR update...) and plugins.
Steps to develop Farm:
- Install Rust Toolchain(If you are new to Rust, search
Rustup Book) and node 16 or above. - Install dependencies with
pnpm i. - Build the compiler binary:
cd packages/core && npm run build:rs - Build packages(open a new terminal):
cd packages/cli && npm start - Work with examples(open a new terminal):
cd examples/react && npm start, report an issue if the example do not start normally. - If you changed Rust code, run
npm run build:rsunderpackages/coreagain to get the newest binary.
brightwu(吴明亮), worked at Bytedance and Tencent, major in frontend architecture.