For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/config/options/features.md.
close
  • 简体中文
  • features

    配置项说明

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

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

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

    类型

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

    示例

    new RsdoctorRspackPlugin({
      // 只开启 bundle、loader、plugins 的特性分析,数组形式会覆盖默认配置。
      features: ['bundle', 'loader', 'plugins'],
    });
    new RsdoctorRspackPlugin({
      features: {
        // 关闭 bundle 分析,其他特性分析保持默认
        bundle: false,
      },
    });

    注意事项

    Tip

    如果出现了 out of memory 的报错,可以尝试:

    1. output.reportCodeType 设置为 noCodenoAssetsAndModuleSource
    2. 增大 node 内存上限,例如:NODE_OPTIONS=--max-old-space-size=8096。
    • 原因:构建过程存储源码时可能超过内存限制,减少报告包含的代码数据可以降低内存占用。
    • 区别:noCode 不包含任何代码,noAssetsAndModuleSource 不包含资源代码和模块源码。

    RsdoctorRspackPluginFeatures

    features 类型如下:

    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;
      /**
       * turn on it if you just use lite mode. This mode do not have source codes.
       * @default false
       * @deprecated
       */
      lite?: boolean;
    }