For AI agents: the complete documentation index is available at https://rsbuild.rs/llms.txt, the full documentation bundle is available at https://rsbuild.rs/llms-full.txt, and this page is available as Markdown at https://rsbuild.rs/guide/debug/rsdoctor.md.
close

Use Rsdoctor

Rsdoctor is a build analysis tool for the Rspack ecosystem. It visualizes the build process and output to help developers investigate build issues and identify performance bottlenecks. It also provides build data to agents for automated diagnosis and optimization of JavaScript programs.

Quick start

Tip

This guide applies to Rsbuild v2.2.6 and later. For Rsbuild v1, see the v1 documentation.

In an Rsbuild project, enable Rsdoctor as follows:

  1. Install the Rsdoctor plugin:
npm
yarn
pnpm
bun
deno
npm add @rsdoctor/core@latest -D

To upgrade from Rsdoctor 1.x, see the Rsdoctor 2.0 migration guide.

  1. Set the RSDOCTOR=true environment variable before running the CLI command:
package.json
{
  "scripts": {
    "dev:rsdoctor": "RSDOCTOR=true rsbuild",
    "build:rsdoctor": "RSDOCTOR=true rsbuild build"
  }
}

Because Windows does not support this syntax, you can use cross-env to set environment variables across different systems:

package.json
{
  "scripts": {
    "dev:rsdoctor": "cross-env RSDOCTOR=true rsbuild",
    "build:rsdoctor": "cross-env RSDOCTOR=true rsbuild build"
  },
  "devDependencies": {
    "cross-env": "^7.0.0"
  }
}

After running these scripts, Rsbuild automatically registers the Rsdoctor plugin and opens the build analysis page when the build finishes. See the Rsdoctor documentation for all features.

Options

To configure the options exposed by the Rsdoctor plugin, manually register the plugin:

rsbuild.config.ts
import { RsdoctorRspackPlugin } from '@rsdoctor/core';

export default {
  tools: {
    rspack: {
      plugins: [
        process.env.RSDOCTOR === 'true' &&
          new RsdoctorRspackPlugin({
            // plugin options
          }),
      ],
    },
  },
};