Rspack Documentation

website·Indexed 36 days ago

https://rspack.rs

A fast Rust-based web bundler that modernizes the webpack API for seamless replacement. It features built-in support for TypeScript, CSS, JSON, and asset modules, and integrates with the Rstack toolchain, Rsbuild, and Rsdoctor. Rspack provides advanced capabilities including Module Federation, lazy compilation, barrel file optimization, and support for frameworks like React, Vue, Svelte, and Solid.

Tokens
182.8K
Snippets
1.1K
Records
1.4K
Agent score
70%

What's inside Rspack

  1. Overview of builtin:lightningcss-loader

    Rspack provides a built-in builtin:lightningcss-loader based on Lightning CSS, a high-performance Rust-based CSS parser and minifier. It can replace postcss-loader and autoprefixer for CSS syntax downgrading and prefixing.

    Critical Requirement: Lightning CSS strictly requires standards-compliant CSS input. Non-standard or browser-specific proprietary syntax may be ignored or result in undefined behavior.

  2. Overview of ContextReplacementPlugin

    The ContextReplacementPlugin is used to change which modules dynamic require, dynamic import(), and require.context() calls can load, and where Rspack looks for them. It targets 'context modules' (e.g., import('./locales/' + name + '.js')). The plugin can replace the search directory, recursive behavior, request-matching regular expression, or the request map. Additionally, it suppresses the Critical dependency warning for any matched contexts.
  3. Overview of SplitChunksPlugin default behavior

    SplitChunksPlugin is a built-in Rspack plugin that optimizes loading performance and caching by splitting code into multiple chunks. By default, it only affects on-demand (async) chunks to avoid altering the script tags in the initial HTML.

    Rspack provides two default cache groups:

    • default: Extracts modules shared by at least 2 chunks.
    • defaultVendors: Extracts modules from the node_modules folder.

    Automatic splitting occurs if:

    • The module is shared or located in node_modules.
    • The resulting chunk is larger than 20kb (before minification and gzip).
    • The number of parallel requests for on-demand loading is ≤ 30.
    • The number of parallel requests at initial page load is ≤ 30.
  4. Overview of NormalModuleFactory

    NormalModuleFactory is used by the Rspack Compiler to generate NormalModule instances. It recursively resolves dependency requests starting from entry modules to determine final file paths and create the corresponding modules.
  5. Overview of the Rstack ecosystem tools

    The Rstack is a unified set of web development tools centered around Rspack. Key tools in the ecosystem include:

    • Rspack: The core high-performance bundler.
    • Rsbuild: A build tool based on Rspack that supports multi-environment builds.
    • Rsdoctor: A tool for bundle analysis and optimization, providing support for Vue and CI/CD report formats.
    • Rslib: A library building tool based on Rsbuild.
    • Rspress: A documentation site generator (v2.0 based on React 19).
  6. Overview of Rspack

    Rspack is a high-performance, Rust-based JavaScript bundler developed by the ByteDance Web Infra team. It is designed as a drop-in replacement for webpack, focusing on high performance, webpack interoperability, and flexible configuration. It aims to significantly reduce developer startup time (npm run dev) and production build times (npm run build) for large-scale applications.
  7. Overview of Rspack

    Rspack is a fast, Rust-based bundler for the web. It is designed to be a seamless replacement for webpack by modernizing the webpack API while delivering significantly faster build speeds. It leverages Rust's performance and multi-core CPU parallelization to reduce dev mode startup times and production build durations, particularly for large monolithic applications.
  8. Overview of Rspack Module Layers

    Module layers allow you to categorize and manage modules in Rspack. By assigning layers to modules, you can perform differentiated processing, such as using different compilation targets, splitting modules into different output directories, or applying different compilation strategies for different environments (e.g., server-side vs. client-side).
  9. Overview of Module Federation in Rspack

    Module Federation is an architectural pattern for JavaScript application decomposition, similar to microservices. It allows multiple JavaScript applications (micro-frontends) to share code and resources at runtime without recompiling the entire application. Key benefits include reduced code duplication, improved maintainability, smaller application sizes, and better performance.
  10. Overview of CopyRspackPlugin

    The CopyRspackPlugin is used in Rspack to copy individual files or entire directories that already exist into the build directory. It supports simple path strings, arrays of pattern objects, and glob patterns for flexible file selection.
  11. Overview of Rspack IgnorePlugin

    The IgnorePlugin prevents selected module references (via import or require) from being included in the bundle. Unlike some plugins, it does not replace the ignored module with an empty module; instead, it skips resolution entirely. If the code that references the ignored module is executed at runtime, it will throw a MODULE_NOT_FOUND error. This plugin should only be used when omitting the module is safe (e.g., optional features or unused library locales) or when the referencing code handles the missing module.
  12. Overview of Rspack 1.0

    Rspack is a next-generation JavaScript bundler written in Rust that is compatible with the webpack API and ecosystem. It is designed to be significantly faster than webpack (up to 10x) while maintaining compatibility with most webpack plugins and loaders. It supports various frameworks including React, Preact, Vue, Solid, Svelte, and NestJS, and targets all JavaScript runtimes including Browser, Node.js, Deno, and Electron.