CLI tutorial
We provide @rsdoctor/cli for you to use Rsdoctor's features locally through the CLI program.
@rsdoctor/webpack-plugin, @rsdoctor/rspack-plugin, and @rsdoctor/cli should have the same major and minor versions.
Install @rsdoctor/cli
- @rsdoctor/cli & @rsdoctor/webpack-plugin & @rsdoctor/rspack-plugin >= 0.1.3.
- You can also use the non-installation method by using the
npx @rsdoctor/cli <command> [options]command.
Command usage
@rsdoctor/cli currently provides the following commands for different functionalities:
analyze command
The analyze command is mainly used to load the manifest.json file locally and start Rsdoctor's analysis report page without the need to rebuild.
Parameter Definition
manifestFileis the path to the manifest.json file (supports local path)
Usage Example
bundle-diff command
The bundle-diff command loads two manifest.json files locally and compares their build bundles. By default, it opens the Rsdoctor Bundle Diff page in the browser. Use --json [path] to generate a JSON report without starting the report server or opening the browser.
Parameter definitions
--baseline <path>: Path or online URL of the manifest.json used as the baseline.--current <path>: Path or online URL of the manifest.json used as the current build.--json [path]: Generate a JSON diff report. The default output path isrsdoctor-diff.json.
Open the report in the browser
Generate a JSON report
The JSON report contains diff data for assets, modules, and packages. You can consume it in CI workflows or use it to generate pull request comments.
Node API
We provide a Node.js API in @rsdoctor/cli that allows you to make calls during runtime in Node.js.
Importing the Module
execute()
The execute asynchronous function is the execution function of Rsdoctor CLI. By calling the execute function, it will automatically parse process.argv and invoke different commands.
execute('analyze', {...})
If you need to directly execute the analyze command through the Node.js API, you can call it as follows:

