> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# features

- **类型：** [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures>](#rsdoctorrspackpluginfeatures)
- **可选：** `true`
- **默认值：** `["loader", "plugins", "bundle"]`

## 配置项说明

features 属性是用于分析功能开关的，具体的功能项如下：

- **loader**：Loaders 耗时及代码编译变化分析，默认开启。
- **plugins**：Plugins 调用以及耗时分析，默认开启。
- **bundle**：构建产物分析，默认开启。
- **resolver**：Resolver 分析，默认关闭。
- **lite**：启用 lite 模式。`features: { lite: true }` 和 `features: ['lite']` 均受支持。启用后，lite 模式会将报告代码类型强制设置为 `noAssetsAndModuleSource`，覆盖其他 [`output.reportCodeType`](/zh/config/options/output.md#reportcodetype) 配置；仅当 `output.reportCodeType` 显式设置为 `noCode` 时，以 `noCode` 为准。`noAssetsAndModuleSource` 不包含模块源码和 Assets 代码，但保留模块打包后代码。lite 模式默认关闭。

所以，**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin 构建时分析**，没有开启 Resolver 分析能力。如需启用 Resolver 分析，可以在 `features` 中显式配置 `resolver`。

### 类型

- 如果你将 `features` 设置为**数组**类型，该插件**只会开启**你在 `features` 数组中定义的功能。
- 如果你将 `features` 设置为**简单对象**类型，该插件**只会关闭**你在 `features` 对象中值为 `false` 的功能。

### 示例

```js
new RsdoctorRspackPlugin({
  // 只开启 bundle、loader、plugins 的特性分析，数组形式会覆盖默认配置。
  features: ['bundle', 'loader', 'plugins'],
});
```

```js
new RsdoctorRspackPlugin({
  features: {
    // 关闭 bundle 分析，其他特性分析保持默认
    bundle: false,
  },
});
```

### 注意事项

:::tip

**如果出现了 out of memory 的报错，可以尝试：**

1. 将 [`output.reportCodeType`](/zh/config/options/output.md#reportcodetype) 设置为 `noCode` 或 `noAssetsAndModuleSource`。
2. 增大 node 内存上限，例如：NODE\_OPTIONS=--max-old-space-size=8096。

- 原因：构建过程存储源码时可能超过内存限制，减少报告包含的代码数据可以降低内存占用。
- 区别：`noCode` 不包含任何代码，`noAssetsAndModuleSource` 不包含资源代码和模块源码。

:::

## RsdoctorRspackPluginFeatures

`features` 类型如下：

```ts
interface RsdoctorRspackPluginFeatures {
  /**
   * turn off it if you need not to analyze the executions of Rspack loaders.
   * @default true
   */
  loader?: boolean;
  /**
   * turn off it if you need not to analyze the executions of Rspack plugins.
   * @default true
   */
  plugins?: boolean;
  /**
   * turn on it if you need to analyze resolver executions.
   * @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 need to analyze the tree shaking result.
   * @default false
   */
  treeShaking?: boolean;
  /**
   * Enable this if you only use lite mode. Source code is not included.
   * @default false
   */
  lite?: boolean;
}
```
