Rstest
@module-federation/rstest provides the federation() Rsbuild plugin used by
Rstest to enable Module Federation compatibility mode for Node/JSDOM test
environments and browser mode.
Quick Start
Installation
You can install the plugin using the following command:
Register plugin
Node / JSDOM test environments
rstest.config.ts
By default, federation() applies Node-safe Module Federation settings:
target: async-node- CommonJS library output (
library.type = 'commonjs-module') remoteType = 'script'when remotes are present- Node runtime plugin resolved from the
@module-federation/rstestpackage experiments.optimization.target = 'node'
Browser mode
rstest.config.ts
In browser target mode, node-only defaults are not applied.
Notes
- Node-target configs automatically inject the Node runtime plugin from the
package context, so consuming test apps do not need to install
@module-federation/nodedirectly. - Use
federation: truein your Rstest config when you want Rstest to enable this compatibility mode.