Options

RsdoctorRspackPlugin

RsdoctorRspackPlugin class are exported by @rsdoctor/rspack-plugin, and the option is RsdoctorRspackPluginOptions.

cjs
esm
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');

new RsdoctorRspackPlugin({
  /** RsdoctorRspackPluginOptions */
});

RsdoctorWebpackPlugin

RsdoctorWebpackPlugin class are exported by @rsdoctor/webpack-plugin, and the option is RsdoctorWebpackPluginOptions.

cjs
esm
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');

new RsdoctorWebpackPlugin({
  /** RsdoctorWebpackPluginOptions */
});

Options

Type: Object

This is the options for the RsdoctorWebpackPlugin and RsdoctorRspackPlugin. It contains these properties:

disableClientServer

  • Type: boolean
  • Optional: true
  • Default: false

Whether to automatically open the Rsdoctor report page. If you do not need to view the analysis report provided by Rsdoctor in the browser, you can enable this configuration item.

features

features values

The features attribute is used to analyze the function switches, and the specific functional items are as follows:

  • loader: Analysis of Loader time consumption and code compilation changes, enabled by default.
  • plugins: Analysis of Plugins calls and time consumption, enabled by default.
  • bundle: Analysis of build bundles, enabled by default.
  • resolver: resolver analysis, disabled by default.
  • lite: [deprecated, please use mode.lite] lite mode. The difference between lite mode and normal mode is that source code information is no longer cached, only packaged code information is cached, so the code analyzed on the page will also be packaged. The default is normal mode.

Therefore, the default configuration enables bundle analysis capabilities and Loader and Plugin build-time analysis. The Resolver analysis capability is not enabled, and Rspack does not currently support Resolver analysis capabilities.

TIP

If an "out of memory" error occurs, you can try the following:

  1. Open the lite mode.mode.lite
  2. Increase the node memory limit, for example: NODE_OPTIONS=--max-old-space-size=8096.
  • Reason: During the build process, source code information is cached, which exceeds memory. Therefore, enabling the "lite" mode can help alleviate the problem.
  • Difference: The difference between the "lite" mode and the normal mode is that source code information is no longer cached, only packaged code information is cached. Thus, the code analyzed on the page will also only be packaged.

features types

  • if the features is set as an Array, it will open the features which you define in this array only.
  • if the features is set as an Object, it will close the features which you set the value is false.

RsdoctorWebpackPluginFeatures

features type:

interface RsdoctorWebpackPluginFeatures {
  /**
   * turn off it if you need not to analyze the executions of webpack loaders.
   * @default true
   */
  loader?: boolean;
  /**
   * turn off it if you need not to analyze the executions of webpack plugins.
   * @default true
   */
  plugins?: boolean;
  /**
   * turn off it if you need not to analyze the executions of resolver.
   * @default false
   */
  resolver?: boolean;
  /**
   * turn off it if you need not to analyze the output bundle.
   * @default true
   */
  bundle?: boolean;
  /**
   * turn on it if you just use lite mode. This mode do not have source codes.
   * @default false
   * @deprecated
   */
  lite?: boolean;
}

RsdoctorRspackPluginFeatures

features type:

interface RsdoctorRspackPluginFeatures {
  /**
   * turn off it if you need not to analyze the executions of webpack loaders.
   * @default true
   */
  loader?: boolean;
  /**
   * turn off it if you need not to analyze the executions of webpack plugins.
   * @default true
   */
  plugins?: boolean;
  /**
   * turn off it if you need not to analyze the output bundle.
   * @default true
   */
  bundle?: boolean;
  /**
   * turn on it if you just use lite mode. This mode do not have source codes.
   * @default false
   * @deprecated
   */
  lite?: boolean;
}

mode

Version: 0.4.0
  • Type: normal | brief | lite
  • Optional: true
  • Default: normal

Choose the Rsdoctor build report mode to use, which includes the following options:

  • normal mode: Generates a .rsdoctor folder in the build output directory, which contains various data files and displays code in the report page. The output directory can be configured via reportDir.

  • brief mode: Generates an HTML report file in the .rsdoctor folder within the build output directory. All build analysis data will be consolidated into this HTML file, which can be viewed by opening it in a browser. Brief mode also has additional configuration options, detailed at: brief.

  • lite mode: Based on the normal mode, this mode does not display source code and product code, only showing the information of the bundled code.

reportDir

Version: 0.4.0
  • Type: string
  • Optional: true
  • Default: undefined

The output directory for Rsdoctor reports. By default, it is the build output directory.

brief

Version: 0.4.0
  • Type: BriefType
  • Optional: true
  • Default: undefined

More configurations for Brief mode are as follows:

  • reportHtmlName: Configures the name of the HTML report for Brief mode. The default value is report-rsdoctor.html.
  • writeDataJson: By default, in Brief mode, the analysis data is injected into the HTML file, so no additional build analysis data is generated. If you want to generate additional local data, you need to configure writeDataJson: true.

briefType

interface BriefConfig {
  reportHtmlName?: string | undefined;
  writeDataJson: boolean;
}

reportCodeType

  • Type: { noModuleSource?: boolean; noAssetsAndModuleSource?: boolean }

  • Optional: true

  • Default: undefined

  • Description

    • Select the output analysis data:

      • default is all complete data;

      • noModuleSource: true is the output of data other than module code; Module code is the packaged module code of a file disassembled in the Bundle.

      • noAssetsAndModuleSource: true is the output of data other than module code and Assets product code.

  • Example

new RsdoctorRspackPlugin({
  reportCodeType: { noModuleSource: true } // { noAssetsAndModuleSource: true }
}),

supports

This option is used to configure whether Rsdoctor enables support for certain detailed feature analysis capabilities, such as whether to enable compatibility with BannerPlugin.

Supports types

type ISupport = {
  banner?: boolean;
  parseBundle?: boolean;
  generateTileGraph?: boolean;
};
DANGER

When enabling the analysis of BannerPlugin, Rsdoctor should not be used in production versions.

  • default: false.
  • type: boolean.

If supports.banner is enabled, Rsdoctor will enable compatibility logic for BannerPlugin. For more details, please refer to: Supports BannerPlugin

parseBundle

  • default: true.
  • type: boolean.

In some large repositories, the execution time of parsing the bundle is too long. Since the Parse Bundle analysis utilizes AST parsing and processing, it can be time-consuming when there are a large number of output files. If this capability is not necessary, it can be selectively disabled using the supports.parseBundle configuration. An example is shown below:

chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
  {
    supports: {
      parseBundle: false,
    },
  },
]);

Disabling the Parse Bundle capability will only affect the visibility of the Bundled Size and Bundled Code of the modules in the bundle:

generateTileGraph

  • default: true. The default value in rspack is false.
  • type: boolean.

Whether to enable the ability to generate tile graphs, which affects whether the Bundle Size page has a tile graph from webpack-bundle-analyzer.

port

  • Type: number
  • Optional: true
  • Default: random(3000, 8999)

Configure the port for the Rsdoctor server.