For AI agents: the complete documentation index is available at https://rslib.rs/llms.txt, the full documentation bundle is available at https://rslib.rs/llms-full.txt, and this page is available as Markdown at https://rslib.rs/guide/advanced/rsdoctor.md.
close
  • English
  • 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

    In an Rslib 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": {
        "build:rsdoctor": "RSDOCTOR=true rslib"
      }
    }

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

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

    After running these scripts, Rslib 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, you can manually register the plugin:

    rslib.config.ts
    import { RsdoctorRspackPlugin } from '@rsdoctor/core';
    import { defineConfig } from '@rslib/core';
    
    export default defineConfig({
      tools: {
        rspack: {
          plugins: [
            process.env.RSDOCTOR === 'true' &&
              new RsdoctorRspackPlugin({
                // plugin options
              }),
          ],
        },
      },
    });