@esmx/rsbuild
The Rsbuild package provides a set of APIs for creating and configuring Rsbuild applications, supporting the building and development of standard applications and HTML applications. It is built on the Rspack kernel and emits native ESM module-federation artifacts consumed by @esmx/core, with real HMR in development.
Installation
Use package manager to install @esmx/rsbuild as a development dependency:
Type Exports
BuildTarget
Build target environment type that defines the application's build target environment:
node: Build code to run in Node.js environmentclient: Build code to run in browser environmentserver: Build code to run in server environment
RsbuildAppConfigContext
Rsbuild application configuration context interface, provides context information accessible in the configuration hook function:
esmx: Esmx framework instancebuildTarget: Current build target (client/server/node)config: RsbuildRsbuildConfigobject — mutate it to customize the build (e.g. add an Rsbuild plugin)options: Application configuration options
RsbuildAppOptions
Rsbuild application configuration options interface:
minimize: Whether to enable code minification;trueto enable,falseto disable,undefinedto automatically decide based on environment (enabled in production, disabled in development)config: Configuration hook function called for each build target before the build starts, used to mutate the resolved Rsbuild configuration. It also applies to the development server.
RsbuildHtmlAppOptions
Options for a no-framework HTML application. Rsbuild handles TypeScript, CSS and assets out of the box, so no extra loader options are exposed.
Function Exports
createRsbuildApp
Create a standard Rsbuild application instance.
Parameters:
esmx— Esmx framework instanceoptions— Rsbuild application configuration options
Returns:
- Returns a
Promisethat resolves to the created application instance
createRsbuildHtmlApp
Create an HTML-type Rsbuild application instance (no UI framework).
Parameters:
esmx— Esmx framework instanceoptions— HTML application configuration options
Returns:
- Returns a
Promisethat resolves to the created HTML application instance
Module Exports
rspack
Re-exports rspack from @rsbuild/core, providing access to the underlying Rspack core functionality.