Farm Documentation

repository·main·Indexed 26 days ago

https://github.com/farm-fe/farm

A fast, Vite-compatible web build tool written in Rust designed for large-scale projects. Includes documentation for core functionality, E2E testing infrastructure, and various JS plugins such as @farmfe/js-plugin-babel, @farmfe/js-plugin-electron, @farmfe/js-plugin-less, @farmfe/js-plugin-postcss, and @farmfe/js-plugin-qiankun.

Tokens
191.5K
Snippets
663
Records
1.2K
Agent score
90%

What's inside Farm

  1. Overview of Farm features

    main

    Farm is a high-performance web build engine written in Rust that is compatible with the Vite plugin ecosystem. Key features include:

    • Super Fast: Millisecond-level startup for React/Vue projects and ~10ms HMR updates.
    • Incremental Builds: Supports persistent caching at the module level to avoid re-compiling unchanged modules.
    • Pluggable Architecture: Supports Vite plugins, Farm compilation plugins (Rust, JS, and Swc), Farm Runtime plugins, and Farm Dev Server plugins.
    • Rich Compilation Support: Out-of-the-box support for JS/TS/JSX/TSX, CSS, CSS Modules, Sass, Less, PostCSS, HTML, and static assets.
    • Lazy Compilation: Only compiles dynamic imports when they are requested, speeding up large projects.
    • Partial Bundling: Automatically bundles resources based on dependency relationships and size to optimize loading and cache hits.
    • Consistency: Ensures consistent behavior between development and production environments.
    • Compatibility: Supports both modern and legacy (ES5) browsers.
  2. Overview of @farmfe/plugin-vue Phase 2 capabilities

    main

    The Phase 2 update for @farmfe/plugin-vue expands the plugin from basic Vue 3 SFC (Single File Component) compilation to a full development workflow. Key features include:

    • HMR Foundations: Support for Hot Module Replacement (HMR) via defined architecture for descriptor caching and invalidation.
    • Scoped Styles: Preservation of scoped CSS semantics, even when using preprocessors (like Sass or Less).
    • Custom Block Routing: Support for custom SFC blocks, which are routed through virtual modules to allow external Farm plugins to process them.
    • Virtual Module Semantics: Clearer handling of virtual modules for styles and custom blocks.
    • Reference Implementation: A complete Vue reference example including Router, Pinia, scoped CSS, and preprocessed styles.
  3. Overview of Farm build tool

    main
    Farm is a high-performance, Rust-based web build tool designed for building web/nodejs applications. It handles the resolution, loading, and transformation of various assets including js/jsx/ts/tsx, css/sass/less, html, static assets, and json, bundling them into deployable files.
  4. Overview of Rust Plugin Hooks

    main

    Farm plugins use Rollup-style hooks categorized into three execution types:

    • first: Hooks execute in serial and return immediately when a hook returns a non-null value (equivalent to None in Rust).
    • serial: Hooks execute in serial, and each hook's result is passed to the next one.
    • parallel: Hooks execute in parallel within a thread pool and must be isolated.

    All hooks accept a CompilationContext parameter, which contains shared compilation information.