By default, Rsbuild does not compile JavaScript files under node_modules. If an npm package contains ESNext syntax, it will be bundled into the output.
To compile these files, use the source.include configuration to specify additional directories or modules.
Error: [object Object] is not a PostCSS plugin ?Rsbuild uses PostCSS v8. If you encounter the Error: [object Object] is not a PostCSS plugin error during compilation, it's usually caused by using an incompatible version of PostCSS. For example, the postcss peer dependency version in cssnano may not match the expected version.
To find unmet peer dependencies, run npm ls postcss. Then fix the issue by specifying the correct PostCSS version in your package.json.
You may need additional loader?If you see this error during compilation, it means some files cannot be compiled correctly.
Check whether you're referencing unsupported file formats, and configure the appropriate Rspack loader to handle them.
export 'foo' (imported as 'foo') was not found in './utils'?This error means your code is importing an export that doesn't exist.
For example, in the following code, index.ts is importing the foo variable from utils.ts, but utils.ts only exports the bar variable.
In this case, Rsbuild will throw the following error:
To fix this, check your import/export statements and correct any errors.
There are some common mistakes:
type modifier, which prevents transpilers like SWC or Babel from recognizing the type export.In some cases, a third-party dependency you can't modify causes this error. If you're certain the issue doesn't affect your application, you can change the log level from error to warn:
However, you should still contact the dependency maintainer to report the issue.
You can refer to the Rspack documentation for more details on module.parser.javascript.exportsPresence.
Rsbuild enables Rspack's tree shaking by default during production builds. Whether tree shaking works depends on whether your code meets Rspack's tree shaking requirements.
If tree shaking isn't working as expected, check the sideEffects configuration in the related npm package. To learn more about sideEffects and tree shaking principles, see Rspack - Tree shaking.
JavaScript heap out of memory when compiling?This error indicates a memory overflow during the build process. This typically happens when the bundled content exceeds Node.js's default memory limit.
To fix out-of-memory issues, the easiest solution is to increase the memory limit using Node.js's --max-old-space-size option. Set this by adding NODE_OPTIONS before your CLI command.
For example, add parameters before the rsbuild build command:
For other commands like rsbuild dev, add the parameters before that command instead.
The value of the max_old_space_size parameter represents the upper limit of the memory size (MB). Generally, it can be set to 16384 (16GB).
The following parameters are explained in more detail in the official Node.js documentation:
Besides increasing the memory limit, you can also improve efficiency by enabling optimization strategies. See Improve Build Performance for details.
If these methods don't solve your problem, unusual logic in your project may be causing the overflow. Debug recent code changes to find the root cause. If you can't locate it, please contact us.
Can't resolve 'core-js/modules/abc.js' when compiling?If you see an error like this during compilation, it means core-js cannot be resolved in your project.
Usually, you don't need to install core-js because Rsbuild includes core-js v3 by default.
If core-js cannot be found, the issue may be:
alias configuration, causing incorrect core-js path resolution. Check your alias configuration.core-js v2. Find the corresponding code and upgrade to core-js v3.node_modules imports core-js but doesn't declare it in dependencies. Either add the core-js dependency to that package, or install core-js in your project root.