CLI Tutorial

We provide @rsdoctor/cli for you to use Rsdoctor's features locally through the CLI program.

TIP

@rsdoctor/webpack-plugin, @rsdoctor/rspack-plugin, and @rsdoctor/cli should have the same major and minor versions.

Install @rsdoctor/cli

TIP
  • @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.
npm
yarn
pnpm
bun
npm add @rsdoctor/cli -D

Command Usage

rsdoctor <command> [options]

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

rsdoctor analyze --profile <manifestFile>

Parameter Definition

  • manifestFile is the path to the manifest.json file (supports local path)

Usage Example

rsdoctor analyze --profile "./dist/.rsdoctor/manifest.json"

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

cjs
esm
const { execute } = require('@rsdoctor/cli');

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:

execute('analyze', {
  profile: 'input the manifest.json path or url',
}).then((sdk) => {
  console.log('execute "anaylze" command success');
  // you can stop the Rsdoctor's dev-server by calling the sdk'api below:
  // sdk.dispose();
});