Build
This page collects build-time error codes and common troubleshooting guidance.
Error Codes
BUILD-001
Failed to find expose module.
- Error Code:
BUILD-001
Reasons
Failed to find the Expose module resource.
There are two possible reasons:
- The exposeModules file path configured in
exposesis incorrect and points to a non-existing path. - When using
Next.jsor other frameworks with built-in webpack, the webpack path used by MF does not match the framework's webpack path.
Solutions
- Check whether the module file path in exposes is correct, paying attention to case sensitivity.
- Check whether FEDERATION_WEBPACK_PATH matches the webpack path used by the framework. If not, verify dependencies are installed correctly or set process.env.FEDERATION_WEBPACK_PATH to the actual webpack path.
BUILD-002
PublicPath is required in prod mode.
- Error Code:
BUILD-002
Reasons
When building an Rspress producer, the project must set publicPath, otherwise it cannot be loaded normally by other consumers.
Solutions
Set publicPath via one of the following methods:
- Set builderConfig.output.assetPrefix in
rspress.config.ts
- Set builderConfig.tools.rspack in
rspress.config.js
Common Issues (No Error Code)
CORS warn
When exposes is set in the project, it will be regarded as a producer. To ensure that the producer resources can be loaded normally by consumers, @module-federation/modern-js and @module-federation/rsbuild-plugin will set Access-Control-Allow-Origin to * and issue a warning at the same time.
Solutions
-
[Modern.js]: Set devServer.headers value to the specified domain whitelist instead of
* -
[Rsbuild]: Set server.cors.origin value to the specified domain whitelist instead of
*
Multiple assets emit different content to the same filename mf-manifest.json
Reason
In Rspack 1.6.0-beta.0, we ported the manifest implementation to Rust. Upgrading Rspack without upgrading the MF-related packages will cause this error.
Solution
Upgrade the @module-federation scoped npm package to version 0.21.0 or later.