For AI agents: the complete documentation index is available at https://rspack.rs/llms.txt, the full documentation bundle is available at https://rspack.rs/llms-full.txt, and this page is available as Markdown at https://rspack.rs/guide/diagnostics/use-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.

Requirements

Rsdoctor 2.0 requires Node.js ^20.19.0 || >=22.12.0 and Rspack 2.0 or later. If your project uses Rspack 1.x or webpack, use Rsdoctor 1.x instead.

How to use

  1. Install @rsdoctor/core:
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. Register RsdoctorRspackPlugin in the Rspack plugins option. Rsdoctor 2.0 packages are ESM-only, so use an ESM config and import:
rspack.config.mjs
import { RsdoctorRspackPlugin } from '@rsdoctor/core';

export default {
  plugins: [
    // Register the plugin only when RSDOCTOR is true, as the plugin increases build time
    process.env.RSDOCTOR &&
      new RsdoctorRspackPlugin({
        // plugin options
      }),
  ],
};
  1. Set RSDOCTOR=true when running Rspack:
RSDOCTOR=true rspack serve
RSDOCTOR=true rspack build

On Windows, use cross-env to set environment variables:

cross-env RSDOCTOR=true rspack serve
cross-env RSDOCTOR=true rspack build

After the build, Rsdoctor opens the analysis page. See the Rsdoctor 2.0 quick start for more details.