Exceptions FAQ

Find ESNext code in the compiled files?

By default, Rsbuild does not compile JavaScript files under node_modules. If an npm package used in the project contains ESNext syntax, it will be bundled into the output.

When this happens, you can specify directories or modules that need to be compiled additionally through the source.include configuration option.

Compile error Error: [object Object] is not a PostCSS plugin ?

Currently, Rsbuild is using PostCSS v8. If you encounter the Error: [object Object] is not a PostCSS plugin error during the compilation process, it is usually caused by referencing the wrong version of PostCSS, for example, the version of postcss (peerDependencies) in cssnano does not meet expectations.

You can find the dependencies of UNMET PEER DEPENDENCY through npm ls postcss, and then install the correct version of dependencies by specifying the PostCSS version in package.json.

npm ls postcss ├─┬ css-loader@6.3.0 │ └── UNMET PEER DEPENDENCY postcss@8.3.9 ├─┬ css-minimizer-webpack-plugin@3.0.0 │ └── UNMET PEER DEPENDENCY postcss@8.3.9

Compile error You may need additional loader?

If the following error message is encountered during the compilation process, it means that there are individual files that cannot be compiled correctly.

Module parse failed: Unexpected token
File was processed with these loaders:
 * some-loader/index.js

You may need an additional loader to handle the result of these loaders.

Please check if any file formats not supported by Rsbuild are being referenced, and configure the corresponding Rspack loader to compile them.

Compilation error export 'foo' (imported as 'foo') was not found in './utils'?

If you encounter this error during the compilation process, it means that your code is referencing an export that does not 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.

// utils.ts
export const bar = 'bar';

// index.ts
import { foo } from './utils';

In this case, Rsbuild will throw the following error:

Compile Error:
File: ./src/index.ts
export 'foo' (imported as 'foo') was not found in './utils' (possible exports: bar)

If you encounter this issue, the first step is to check the import/export statements in your code and correct any invalid code.

There are some common mistakes:

  • Importing a non-existent variable:
// utils.ts
export const bar = 'bar';

// index.ts
import { foo } from './utils';
  • Re-exporting a type without adding the type modifier, causing transpilers like SWC or Babel to fail in recognizing the type export, resulting in compilation errors.
// utils.ts
export type Foo = 'bar';

// index.ts
export { Foo } from './utils'; // Incorrect
export type { Foo } from './utils'; // Correct

In some cases, the error may be caused by a third-party dependency that you cannot modify directly. In this situation, if you are sure that the issue does not affect your application, you can add the following configuration to change the log level from error to warn:

export default {
  tools: {
    rspack: {
      module: {
        parser: {
          javascript: {
            exportsPresence: 'warn',

However, it is important to contact the developer of the third-party dependency immediately to fix the issue.

You can refer to the Rspack documentation for more details on module.parser.javascript.exportsPresence.

Tree shaking does not take effect?

Rsbuild will enable the tree shaking of Rspack by default during the production build. Whether tree shaking can take effect depends on whether the code can meet the conditions of Rspack's tree shaking.

If you find that tree shaking is not working as expected, you can check whether the sideEffects config of the related npm package is correct. If you do not understand the role of sideEffects, or if you are interested in the principles behind tree shaking, you can read Rspack Official Documentation - Tree Shaking.

JavaScript heap out of memory when compiling?

This error indicates that there is a memory overflow problem during the packaging process. In most cases, it is because the bundled content exceeds the default memory limit of Node.js.

In case of OOM issues, the easiest way to fix this is by increasing the memory cap, Node.js provides the --max-old-space-size option to set this. You can set this parameter by adding NODE_OPTIONS before the CLI command.

For example, add parameters before the rsbuild build command:

  "scripts": {
-   "build": "rsbuild build"
+   "build": "NODE_OPTIONS=--max_old_space_size=16384 rsbuild build"

If you are executing other commands, such as rsbuild dev, please add parameters before the corresponding command.

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:

In addition to increasing the memory limit, it is also a solution to improve efficiency by enabling some compilation strategies, please refer to Improve Build Performance.

If the above methods cannot solve your problem, it may be that some abnormal logic in the project has caused memory overflow. You can debug recent code changes and locate the root cause of problems. If it cannot be located, please contact us.

Can't resolve 'core-js/modules/abc.js' when compiling?

If you get an error similar to the following when compiling, it means that core-js cannot be resolved properly in the project.

Module not found: Can't resolve 'core-js/modules/es.error.cause.js'

Usually, you don't need to install core-js in the project, because the Rsbuild already has a built-in core-js v3.

If there is an error that core-js cannot be found, there may be several reasons:

  1. The current project overrides the built-in alias configuration of Rsbuild, causing the incorrect resolution of the core-js path when referenced. In this case, you can check the alias configuration of the project.
  2. Some code in the project depends on core-js v2. In this case, you usually need to find out the corresponding code and upgrade core-js to the v3.
  3. An npm package in node_modules imported core-js, but does not declare the core-js dependency in dependencies. In this case, you need to declare the core-js dependency in the corresponding npm package, or install a copy of core-js in the project root directory.