How web-infra-dev/rsbuild works
Main building blocks and their roles
a. CLI & Entry points – The “packages/core/src/cli” and “packages/create‑rsbuild” sections show that Rsbuild has a user‐facing CLI that reads configuration, dispatches commands (e.g., “build”, “dev server”) and triggers the build pipeline.
b. Configuration subsystem – Notice files such as “packages/core/src/config.ts”, “packages/core/src/mergeConfig.ts”, and several config templates. This portion parses user and default configurations, merges them and exposes a semantic API.
d. Build pipeline and integration – There is a “packages/core” layer that includes code for:
• Loaders (“packages/core/src/loader/transformLoader.ts”, etc.)
• Bundler integration with Rspack (see “packages/core/src/rspack” and associated provider modules)
• Build output, caching, performance, and analysis modules (plugins for bundle analyzer, cache, file size, etc.)
e. Development server – The “packages/core/src/server” directory provides the modules for the dev server (supporting HMR, proxy, overlay, static file serving, etc.).
f. Compatibility and ecosystem support – The “packages/compat” and the plugin categories (webpack compatibility plugins) expose that Rsbuild can leverage the existing ecosystem (webpack plugins and even module federation patterns).
Interactions and data flow between components
• User input flows from the CLI (or API invocations) into the configuration subsystem to parse and merge user settings.
• The configuration subsystem then initializes the context and passes it to the Plugin Manager.
• The Plugin Manager dynamically loads plugins (each representing a feature like Babel transformation, Sass processing, etc.) which then register hooks into the build pipeline.
• The core build pipeline orchestrates the sequence of tasks. It calls into loaders, transformation and bundling steps through the Rspack integration layer.
• In development mode, the dev server subsystem is activated; it sets up middleware for HMR, file watching, overlay display, and so on.
• Final output (bundled artifacts, static assets) is produced after passing through transformations and optimizations, which may be handled by plugins such as “minimize”, “sri”, and “mergeConfig”.