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 analyzer tailored for the Rspack ecosystem.

Rsdoctor is committed to being a one-stop, intelligent build analyzer that makes the build process transparent, predictable, and optimizable through visualization and smart analysis, helping development teams precisely identify bottlenecks, optimize performance, and improve engineering quality.

If you need to debug the build outputs or build process, you can use Rsdoctor for troubleshooting.

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
  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

As Windows does not support the above usage, you can also use cross-env to set environment variables. This ensures compatibility across different systems:

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.

Upgrading from Rsdoctor 1.x

Replace @rsdoctor/rspack-plugin with @rsdoctor/core and update the import shown above. Remove experiments.enableNativePlugin if configured; the Rspack native plugin is always enabled in Rsdoctor 2.0. For other configuration changes, see the Rsdoctor 2.0 migration guide.