@rsdoctor/docs 1.2.3 → 1.2.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/docs/en/{_meta.json → _nav.json} +5 -0
  2. package/docs/en/blog/release/release-note-1_0.mdx +2 -2
  3. package/docs/en/config/options/_meta.json +13 -1
  4. package/docs/en/config/options/brief.mdx +35 -0
  5. package/docs/en/config/options/disableClientServer.mdx +11 -0
  6. package/docs/en/config/options/experiments.mdx +21 -0
  7. package/docs/en/config/options/features.mdx +70 -0
  8. package/docs/en/config/options/mode.mdx +20 -0
  9. package/docs/en/config/options/options-v2.mdx +40 -0
  10. package/docs/en/config/options/options.mdx +61 -266
  11. package/docs/en/config/options/output.mdx +162 -0
  12. package/docs/en/config/options/port.mdx +7 -0
  13. package/docs/en/config/options/supports.mdx +72 -0
  14. package/docs/en/config/options/term.mdx +35 -2
  15. package/docs/en/guide/more/faq.mdx +14 -14
  16. package/docs/en/guide/rules/rule-custom.mdx +1 -11
  17. package/docs/en/guide/start/cli.mdx +5 -5
  18. package/docs/en/guide/start/intro.mdx +1 -1
  19. package/docs/en/guide/start/quick-start-shared.mdx +1 -1
  20. package/docs/en/guide/usage/bundle-size.mdx +1 -1
  21. package/docs/en/guide/usage/module-analysis.mdx +1 -2
  22. package/docs/en/shared/mode-intro.md +2 -1
  23. package/docs/public/netlify.toml +12 -0
  24. package/docs/zh/{_meta.json → _nav.json} +5 -0
  25. package/docs/zh/blog/release/release-note-1_0.mdx +1 -1
  26. package/docs/zh/config/options/_meta.json +13 -1
  27. package/docs/zh/config/options/brief.mdx +35 -0
  28. package/docs/zh/config/options/disableClientServer.mdx +11 -0
  29. package/docs/zh/config/options/experiments.mdx +21 -0
  30. package/docs/zh/config/options/features.mdx +70 -0
  31. package/docs/zh/config/options/mode.mdx +20 -0
  32. package/docs/zh/config/options/options-v2.mdx +40 -0
  33. package/docs/zh/config/options/options.mdx +61 -265
  34. package/docs/zh/config/options/output.mdx +162 -0
  35. package/docs/zh/config/options/port.mdx +7 -0
  36. package/docs/zh/config/options/supports.mdx +71 -0
  37. package/docs/zh/config/options/term.mdx +33 -0
  38. package/docs/zh/guide/more/faq.mdx +12 -12
  39. package/docs/zh/guide/rules/rule-custom.mdx +1 -11
  40. package/docs/zh/guide/start/cli.mdx +5 -5
  41. package/docs/zh/guide/start/intro.mdx +1 -1
  42. package/docs/zh/guide/start/quick-start-shared.mdx +1 -1
  43. package/docs/zh/guide/usage/module-analysis.mdx +1 -2
  44. package/docs/zh/shared/mode-intro.md +1 -0
  45. package/package.json +17 -14
@@ -0,0 +1,70 @@
1
+ # features
2
+
3
+ - **类型:** [RsdoctorWebpackPluginFeatures](#rsdoctorwebpackpluginfeatures) | [Array\<keyof RsdoctorWebpackPluginFeatures\>](#rsdoctorwebpackpluginfeatures) | [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures\>](#rsdoctorrspackpluginfeatures)
4
+ - **可选:** `true`
5
+ - **默认值:** `["loader", "plugins", "bundle"]`
6
+
7
+ ## 配置项说明
8
+
9
+ features 属性是用于分析功能开关的,具体的功能项如下:
10
+
11
+ - **loader**:Loaders 耗时及代码编译变化分析,默认开启。
12
+ - **plugins**:Plugins 调用以及耗时分析,默认开启。
13
+ - **bundle**:构建产物分析,默认开启。
14
+ - **resolver**:resolver 分析,默认关闭。
15
+ - **lite**: **(lite 模式即将在 V2 废弃,参考[lite 模式废弃说明](/config/options/options-v2#lite))** lite 模式。lite 模式和普通模式的区别就是不再展示源码信息,只展示打包后的代码信息,这样分析页面上的代码也将是打包后的。默认普通模式。
16
+
17
+ 所以,**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin 构建时分析**。没有开启 Resolver 分析能力, Rspack 暂不支持 Resolver 分析能力。
18
+
19
+ ### 类型
20
+
21
+ - 如果你将 `features` 设置为**数组**类型,该插件**只会开启**你在 `features` 数组中定义的功能。
22
+ - 如果你将 `features` 设置为**简单对象**类型,该插件**只会关闭**你在 `features` 对象中值为 `false` 的功能。
23
+
24
+ ### 示例
25
+
26
+ ```js
27
+ new RsdoctorRspackPlugin({
28
+ // 只开启 bundle、loader、plugins 的特性分析,数组形式会覆盖默认配置。
29
+ features: ['bundle', 'loader', 'plugins'],
30
+ });
31
+ ```
32
+
33
+ ```js
34
+ new RsdoctorRspackPlugin({
35
+ features: {
36
+ // 关闭 bundle 分析,其他特性分析保持默认
37
+ bundle: false,
38
+ },
39
+ });
40
+ ```
41
+
42
+ ### 注意事项
43
+
44
+ :::tip
45
+
46
+ **如果出现了 out of memory 的报错,可以尝试:**
47
+
48
+ 1. 打开 **lite** 模式。
49
+ 2. 增大 node 内存上限,例如:NODE_OPTIONS=--max-old-space-size=8096。
50
+
51
+ - 原因:因为构建过程中,缓存了源码信息,超过了内存,所以开启 `lite` 模式可以缓解。
52
+ - 区别:`lite` 模式和普通模式的区别就是不再缓存源码信息,只缓存打包后的代码信息,这样分析页面上的代码也将是打包后的。
53
+
54
+ :::
55
+
56
+ ## RsdoctorWebpackPluginFeatures
57
+
58
+ `features` 类型如下:
59
+
60
+ import Features from '@zh/shared/features.md';
61
+
62
+ <Features />
63
+
64
+ ## RsdoctorRspackPluginFeatures
65
+
66
+ `features` 类型如下:
67
+
68
+ import FeaturesRspack from '@zh/shared/features-rspack.md';
69
+
70
+ <FeaturesRspack />
@@ -0,0 +1,20 @@
1
+ import { Badge } from '@theme';
2
+
3
+ # mode
4
+
5
+ :::warning
6
+
7
+ - V2 中即将废弃,请使用 [output.mode](/config/options/output#mode) 代替。参考 [mode 配置迁移](/config/options/options-v2#mode)。
8
+
9
+ :::
10
+
11
+ - **类型:** `"normal" | "brief" | "lite"`
12
+ - lite 模式即将在 V2 废弃,参考[lite 模式废弃说明](/config/options/options-v2#lite)
13
+ - **可选:** `true`
14
+ - **默认值:** `normal`
15
+
16
+ 选择使用的 Rsdoctor 构建报告模式,有以下几种:
17
+
18
+ import ModeIntro from '@zh/shared/mode-intro.md';
19
+
20
+ <ModeIntro />
@@ -0,0 +1,40 @@
1
+ # 配置迁移说明
2
+
3
+ **Rsdoctor 在 1.2.4 版本中引入了新的配置项,新的配置项更易于配置,更好扩展,与以后发布的 v2.0 版本兼容**。
4
+
5
+ 1.2.3 及之前版本的配置项仍会保留,**但在 Rsdoctor v2 时会完全废弃掉**,推荐迁移到 `1.2.4` 的新版配置。
6
+
7
+ | 原配置 | 新配置 |
8
+ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
9
+ | mode | 改为配置 `output.mode`。 |
10
+ | brief | 改为配置 `mode: 'brief'`,同时,配置 `output.options` 的 `type` 为 `html`。 |
11
+ | output.compressData | 改为配置 `mode: 'brief'`,同时,配置 `output.options.type` 为 `json`。 |
12
+ | `mode: 'lite'` 或 `feature: 'lite'` | 改为配置 `mode: 'normal'`,同时,配置 `output.options.reportCodeType` 为 `noCode` 或 `noAssetsAndModuleSource`。 |
13
+ | 无 | 新增 `output.options.jsonOptions.section` 配置 |
14
+
15
+ ## 配置改动详情
16
+
17
+ ### mode
18
+
19
+ 原有配置中的 `mode` 迁移为嵌套的 `output.mode`,便于与其他输出相关的配置整合。
20
+
21
+ ### brief
22
+
23
+ 目前的 brief 简报模式输出一个 html 文件为报告页,新增的 brief 模式还是支持 JSON 格式,同时也为了相同配置统一管理,所以 brief 配置前移到了 output.options 中。
24
+ 原有的 `brief` 配置改为配置 `output.mode: 'brief'`,同时配置 `output.options` 的 `type` 为 `html`。
25
+
26
+ ### output.compressData
27
+
28
+ 原有的 `output.compressData` 配置改为配置 `mode: 'brief'`,同时配置 `output.options.type` 为 `json`。
29
+
30
+ ### lite
31
+
32
+ lite 模式的内部逻辑等同于 `output.options.reportCodeType` 为 `noCode` 或 `noAssetsAndModuleSource`,主要是为了解决大项目在打开报告时过慢或者构建时 OOM 的问题。
33
+
34
+ 考虑到用户并不能清楚分辨 lite 模式的实际含义,mode 太多也不利于管理和配置,同时,`output.options.reportCodeType` 配置更加清晰,所以未来 V2 版本中会废弃掉 `mode: 'lite'`。
35
+
36
+ 原有的 `mode: 'lite'` 和 `feature: 'lite'` 配置改为配置 `mode: 'normal'`,同时配置 `output.options.reportCodeType` 为 `noCode` 或 `noAssetsAndModuleSource`。
37
+
38
+ ### 新增 output.options.jsonOptions.section
39
+
40
+ 支持新增的 `output.options.jsonOptions.section` 配置,用于更细粒度的 JSON 输出选项定制。具体 sections 配置项参考[output.options.jsonOptions.section](/config/options/output#jsonoptionssection)。
@@ -1,17 +1,17 @@
1
- import { Badge } from '@theme';
1
+ import { Badge, Tab, Tabs } from '@theme';
2
2
 
3
- # Options 配置
3
+ # 总览
4
4
 
5
5
  ## RsdoctorRspackPlugin 插件
6
6
 
7
- **RsdoctorRspackPlugin** 类由 `@rsdoctor/rspack-plugin` 导出,配置项是 [RsdoctorRspackPluginOptions](#options-1)。
7
+ **RsdoctorRspackPlugin** 类由 `@rsdoctor/rspack-plugin` 导出,配置项是 [RsdoctorRspackPluginOptions](#rsdoctorrspackpluginoptions)。
8
8
 
9
9
  <Tabs>
10
10
 
11
- <Tab label="cjs">
11
+ <Tab label="esm">
12
12
 
13
- ```js
14
- const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
13
+ ```ts
14
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
15
15
 
16
16
  new RsdoctorRspackPlugin({
17
17
  /** RsdoctorRspackPluginOptions */
@@ -20,10 +20,10 @@ new RsdoctorRspackPlugin({
20
20
 
21
21
  </Tab>
22
22
 
23
- <Tab label="esm">
23
+ <Tab label="cjs">
24
24
 
25
- ```ts
26
- import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
25
+ ```js
26
+ const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
27
27
 
28
28
  new RsdoctorRspackPlugin({
29
29
  /** RsdoctorRspackPluginOptions */
@@ -36,16 +36,14 @@ new RsdoctorRspackPlugin({
36
36
 
37
37
  ## RsdoctorWebpackPlugin 插件
38
38
 
39
- **RsdoctorWebpackPlugin** 类由 `@rsdoctor/webpack-plugin` 导出,配置项是 [RsdoctorWebpackPluginOptions](#options-1)。
40
-
41
- import { Tab, Tabs } from '@theme';
39
+ **RsdoctorWebpackPlugin** 类由 `@rsdoctor/webpack-plugin` 导出,配置项是 [RsdoctorWebpackPluginOptions](#rsdoctorwebpackpluginoptions)。
42
40
 
43
41
  <Tabs>
44
42
 
45
- <Tab label="cjs">
43
+ <Tab label="esm">
46
44
 
47
- ```js
48
- const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
45
+ ```ts
46
+ import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
49
47
 
50
48
  new RsdoctorWebpackPlugin({
51
49
  /** RsdoctorWebpackPluginOptions */
@@ -54,10 +52,10 @@ new RsdoctorWebpackPlugin({
54
52
 
55
53
  </Tab>
56
54
 
57
- <Tab label="esm">
55
+ <Tab label="cjs">
58
56
 
59
- ```ts
60
- import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
57
+ ```js
58
+ const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
61
59
 
62
60
  new RsdoctorWebpackPlugin({
63
61
  /** RsdoctorWebpackPluginOptions */
@@ -68,269 +66,67 @@ new RsdoctorWebpackPlugin({
68
66
 
69
67
  </Tabs>
70
68
 
71
- ## Options
69
+ ## 配置项
72
70
 
73
71
  **类型:** `Object`
74
72
 
75
- 这个 `Options` 是 [RsdoctorWebpackPlugin](#rsdoctorwebpackplugin-%E6%8F%92%E4%BB%B6) 和 [RsdoctorRspackPlugin](#rsdoctorrspackplugin-%E6%8F%92%E4%BB%B6) 的配置项。它包含以下属性值:
76
-
77
- - [brief](#brief)
78
- - [disableClientServer](#disableclientserver)
79
- - [experiments](#experiments)
80
- - [features](#features)
81
- - [mode](#mode)
82
- - [output](#output)
83
- - [port](#port)
84
- - [supports](#supports)
85
-
86
- ### brief
87
-
88
- <Badge text="Version: 0.4.0" type="warning" />
73
+ 这个 `Options` 是 [RsdoctorRspackPlugin](#rsdoctorrspackplugin-%E6%8F%92%E4%BB%B6) 和 [RsdoctorWebpackPlugin](#rsdoctorwebpackplugin-%E6%8F%92%E4%BB%B6) 的配置项。它包含以下属性值:
89
74
 
90
- - **类型:** [BriefType](#brieftype)
91
- - **可选:** `true`
92
- - **默认值:** `undefined`
75
+ - [disableClientServer](./disableClientServer.mdx) - **客户端服务控制**:是否在分析完成后不自动打开 Rsdoctor 报告服务。
76
+ - [experiments](./experiments.mdx) - **实验性功能配置**:启用 Rspack 插件的实验性功能,如原生插件性能优化。
77
+ - [features](./features.mdx) - **特性开关配置**:控制 Rsdoctor 的各项分析功能,如 loader 分析、bundle 分析、规则检查等
78
+ - [output](./output.mdx) - **输出相关配置**:控制报告的输出格式、目录等选项,包括 mode、options、reportCodeType 等
79
+ - [port](./port.mdx) - **服务端口配置**:设置 Rsdoctor 开发服务器的端口号,用于本地开发时的报告预览
80
+ - [supports](./supports.mdx) - **特性支持配置**:启用特定构建工具的兼容性支持,如 BannerPlugin 等
81
+ - [brief](./brief.mdx) - **Brief 模式的配置**:控制简要模式报告的生成,包括 HTML 文件名和是否生成 JSON 数据文件
82
+ - [mode](./mode.mdx) - **构建报告数据输出模式**:选择报告的输出模式,支持 normal(普通模式)和 brief(简要模式)
93
83
 
94
- Brief 模式更多配置,如下:
95
-
96
- - **reportHtmlName:** 配置 Brief 的 HTML 报告的名称,默认 `report-rsdoctor.html`。
97
- - **writeDataJson:** 默认 Brief 模式下将分析数据注入到 HTML 文件中,所以不会再产生构建分析数据。如果想要而外本地生成数据则需要配置 `writeDataJson: true`。
98
-
99
- #### briefType
84
+ ### RsdoctorRspackPluginOptions
100
85
 
101
86
  ```ts
102
- interface BriefConfig {
103
- reportHtmlName?: string | undefined;
104
- writeDataJson: boolean;
105
- }
106
- ```
107
-
108
- ### disableClientServer
109
-
110
- - **类型:** `boolean`
111
- - **可选:** `true`
112
- - **默认值:** `false`
113
-
114
- :::tip
115
- 建议在 CI 环境下将 disableClientServer 设置为 true,否则启动的服务会卡住 pipeline 流程.
116
- :::
117
-
118
- 是否需要自动打开 Rsdoctor 报告页面。如果你不需要在浏览器内查看本次 Rsdoctor 提供的分析报告,则可以开启这个配置项。
119
-
120
- ### experiments
121
-
122
- <Badge text="Version: 1.0.0" type="warning" />
123
-
124
- #### enableNativePlugin
125
-
126
- - **类型:** `boolean`
127
- - **可选:** `true`
128
- - **默认值:** `false`
129
-
130
- ##### Description
131
-
132
- 通过在 Rspack 中集成 Rsdoctor 的原生插件,我们将 Rsdoctor 中耗时较大的数据处理逻辑前置到 Rspack 的构建阶段。这一特性显著提升了 Rspack 中 Rsdoctor 的构建分析效率,减少了整体分析时间。
133
-
134
- - enableNativePlugin:是否开启 Rspack 原生插件,开启后可大幅降低 Rsdoctor 自身的分析耗时。
135
-
136
- - **示例:**
137
-
138
- ```js
139
- new RsdoctorRspackPlugin({
140
- experiments: { enableNativePlugin: true }
141
- }),
142
- ```
143
-
144
- ### features
145
-
146
- - **类型:** [RsdoctorWebpackPluginFeatures](#rsdoctorwebpackpluginfeatures) | [Array\<keyof RsdoctorWebpackPluginFeatures\>](#rsdoctorwebpackpluginfeatures) | [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures\>](#rsdoctorrspackpluginfeatures)
147
- - **可选:** `true`
148
- - **默认值:** `['loader', 'plugins', 'bundle']`
149
-
150
- #### features values
151
-
152
- features 属性是用于分析功能开关的,具体的功能项如下:
153
-
154
- - **loader**:Loaders 耗时及代码编译变化分析,默认开启。
155
- - **plugins**:Plugins 调用以及耗时分析,默认开启。
156
- - **bundle**:构建产物分析,默认开启。
157
- - **resolver**:resolver 分析,默认关闭。
158
- - **lite**: **(废弃,使用 [mode.lite](#mode))** lite 模式。lite 模式和普通模式的区别就是不再展示源码信息,只展示打包后的代码信息,这样分析页面上的代码也将是打包后的。默认普通模式。
159
-
160
- 所以,**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin 构建时分析**。没有开启 Resolver 分析能力, Rspack 暂不支持 Resolver 分析能力。
161
-
162
- :::tip
163
- **如果出现了 out of memory 的报错,可以尝试:**
87
+ interface RsdoctorWebpackPluginOptions<
88
+ Rules extends LinterType.ExtendRuleData[],
89
+ > {
90
+ linter?: LinterType.Options<Rules, InternalRules>;
164
91
 
165
- 1. 打开 **lite** 模式。
166
- 2. 增大 node 内存上限,例如:NODE_OPTIONS=--max-old-space-size=8096。
92
+ /** Rsdoctor 功能开关 */
93
+ features?:
94
+ | Plugin.RsdoctorWebpackPluginFeatures
95
+ | Array<keyof Plugin.RsdoctorWebpackPluginFeatures>;
167
96
 
168
- - 原因:因为构建过程中,缓存了源码信息,超过了内存,所以开启 `lite` 模式可以缓解。
169
- - 区别:`lite` 模式和普通模式的区别就是不再缓存源码信息,只缓存打包后的代码信息,这样分析页面上的代码也将是打包后的。
97
+ /**
98
+ * @deprecated 使用 `output.mode` 代替,如果使用 `lite` 模式,请使用 `output.reportCodeType: 'noCode' or 'noAssetsAndModuleSource'` 代替
99
+ * Rsdoctor 模式选项:
100
+ * - normal: 普通模式
101
+ * - brief: 简要模式,仅显示持续时间分析和构建产物分析结果,不显示任何代码部分
102
+ */
103
+ mode?: 'brief' | 'normal' | 'lite';
170
104
 
171
- :::
105
+ disableClientServer?: boolean;
172
106
 
173
- #### features types
107
+ supports?: ISupport;
174
108
 
175
- - 如果你将 `features` 设置为**数组**类型,该插件**只会开启**你在 `features` 数组中定义的功能。
176
- - 如果你将 `features` 设置为**简单对象**类型,该插件**只会关闭**你在 `features` 对象中值为 `false` 的功能。
109
+ port?: number;
177
110
 
178
- #### RsdoctorWebpackPluginFeatures
111
+ /**
112
+ * @deprecated 使用 `output.options.htmlOptions` 代替
113
+ */
114
+ brief?: Config.BriefConfig;
179
115
 
180
- `features` 类型如下:
116
+ output?: Config.IOutput<'brief' | 'normal'>;
181
117
 
182
- import Features from '@zh/shared/features.md';
183
-
184
- <Features />
185
-
186
- #### RsdoctorRspackPluginFeatures
187
-
188
- `features` 类型如下:
189
-
190
- import FeaturesRspack from '@zh/shared/features-rspack.md';
191
-
192
- <FeaturesRspack />
193
-
194
- ### mode
195
-
196
- <Badge text="Version: 0.4.0" type="warning" />
197
-
198
- - **类型:** `normal | brief | lite`
199
- - **可选:** `true`
200
- - **默认值:** `normal`
201
-
202
- 选择使用的 Rsdoctor 构建报告模式,有以下几种:
203
-
204
- import ModeIntro from '@zh/shared/mode-intro.md';
205
-
206
- <ModeIntro />
207
-
208
- ### output
209
-
210
- <Badge text="Version: 1.0.0" type="warning" />
211
-
212
- #### compressData
213
-
214
- - **类型:** `boolean`
215
- - **可选:** `true`
216
- - **默认值:** `true`
217
-
218
- compressData 用于配置是否将 [outputDir]/.rsdoctor 下的分析数据进行压缩处理。
219
-
220
- #### reportCodeType
221
-
222
- - **类型:** `{ noModuleSource?: boolean; noAssetsAndModuleSource?: boolean }`
223
- - **可选:** `true`
224
- - **默认值:** `undefined`
225
- - **描述:**
226
-
227
- - 选择输出的分析数据:
228
- - 默认是所有完整数据;
229
- - noModuleSource: true 是输出除了 module 代码之外的数据,Module 代码即 Bundle 内一个一个文件的打包模块代码。
230
- - noAssetsAndModuleSource: true 是输出除了 module 代码和 Assets 产物代码之外的数据。
231
-
232
- - **示例:**
233
-
234
- ```js
235
- new RsdoctorRspackPlugin({
236
- reportCodeType: { noModuleSource: true } // { noAssetsAndModuleSource: true }
237
- }),
238
- ```
239
-
240
- #### reportDir
241
-
242
- - **类型:** `string`
243
- - **可选:** `true`
244
- - **默认值:** `undefined`
245
-
246
- Rsdoctor 报告输出目录,默认是构建产物输出目录。
247
-
248
- ### port
249
-
250
- - **类型:** `number`
251
- - **可选:** `true`
252
- - **默认值:** `random(3000, 8999)`
253
-
254
- 配置 Rsdoctor 服务的端口。
255
-
256
- ### ~~reportCodeType [**Deprecated**]~~
257
-
258
- <Badge text="Deprecated" type="warning" />
259
-
260
- 请看 [output.reportCodeType](#reportcodetype)
261
-
262
- ### ~~reportDir [**Deprecated**]~~
263
-
264
- <Badge text="Deprecated" type="warning" />
265
-
266
- 请看 [output.reportDir](#reportdir)
267
-
268
- ### supports
269
-
270
- - **类型:** [Supports Types](#supports-types)
271
- - **可选:** `true`
272
- - **默认值:** `undefined`
273
-
274
- 该选项是配置 Rsdoctor 是否开启某些细节特性分析能力支持的,例如:是否开启对 BannerPlugin 的兼容能力。
275
-
276
- #### supportsTypes
118
+ experiments?: RsdoctorRspackPluginExperiments;
119
+ }
277
120
 
278
- ```ts
279
- type ISupport = {
280
- banner?: boolean;
281
- parseBundle?: boolean;
282
- generateTileGraph?: boolean;
283
- };
121
+ interface RsdoctorRspackPluginExperiments {
122
+ /**
123
+ * 是否启用原生插件以提高性能
124
+ * @default false
125
+ */
126
+ enableNativePlugin?: boolean;
127
+ }
284
128
  ```
285
129
 
286
- #### banner
287
-
288
- :::danger
289
- `supports.banner` 分析仅用于调试,请勿将其用于生产。
290
- :::
291
-
292
- - **类型:** `boolean`
293
- - **默认值:** `true`
294
-
295
- 如果开启 `supports.banner` 则会开启 Rsdoctor 对 BannerPlugin 的兼容逻辑。详细请看:[支持 BannerPlugin](../../guide/usage/bundle-size#%E6%94%AF%E6%8C%81-bannerplugin)
296
-
297
- #### ~~generateTileGraph [**Deprecated**]~~
298
-
299
- <Badge text="Deprecated" type="warning" />
300
-
301
- Rsdoctor 默认支持生成 Tree Map 图,所以不需要配置此选项。
302
-
303
- #### parseBundle
304
-
305
- - **类型:** `boolean`
306
- - **默认值:** `true`
307
-
308
- 在部分大型仓库中,反解 Bundle 解析执行耗时过大,这是因为 Parse Bundle 的分析利用了 AST 解析与处理。当产物文件过多时,耗时也会增加。如果不需要此功能,可以通过 `supports.parseBundle` 配置进行选择性关闭。示例如下:
309
-
310
- ```ts
311
- chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
312
- {
313
- supports: {
314
- parseBundle: false,
315
- },
316
- },
317
- ]);
318
- ```
130
+ ### RsdoctorWebpackPluginOptions
319
131
 
320
- 关闭 Parse Bundle 能力只会影响是否能查看到 Bundle 中 Module 的最终打包大小(Bundled Size)及最终打包代码(Bundled Code):
321
-
322
- <div style={{ display: 'flex' }}>
323
- <img
324
- src="https://assets.rspack.rs/others/assets/rsdoctor/bundled-size.jpeg"
325
- height="300px"
326
- width="300px"
327
- style={{ margin: 'auto' }}
328
- />
329
-
330
- <img
331
- src="https://assets.rspack.rs/others/assets/rsdoctor/bundled-code.png"
332
- height="300px"
333
- width="400px"
334
- style={{ margin: 'auto' }}
335
- />
336
- </div>
132
+ RsdoctorWebpackPlugin `Omit<RsdoctorRspackPluginOptions, 'experiments'>` 类型。
@@ -0,0 +1,162 @@
1
+ import { Badge } from '@theme';
2
+
3
+ # output
4
+
5
+ ## mode
6
+
7
+ <Badge text="V1.2.4 新增" type="tip" />
8
+
9
+ - **类型:** `"normal" | "brief"`
10
+
11
+ Rsdoctor 报告模式,默认是 `normal`。
12
+
13
+ - **normal:** 在构建产物目录中生成一个 `.rsdoctor` 文件夹,其中包含各种数据文件,并在报告页面中展示代码。输出目录可以通过 [reportDir](#reportdir) 进行配置。
14
+ - **brief:** 在构建产物目录的 `.rsdoctor` 文件夹中生成一个 HTML 报告文件,所有构建分析数据会整合注入到这个 HTML 文件中,可以通过浏览器打开该 HTML 文件查看报告。brief 模式还有更多配置项,详细信息请参阅:[brief](#brief)。
15
+
16
+ :::tip
17
+ mode 是没有 lite 配置项的,lite 模式即将废弃,参考 [lite 模式废弃说明](./options-v2.mdx#lite-模式废弃说明)。
18
+ :::
19
+
20
+ ## options
21
+
22
+ <Badge text="V1.2.4 新增" type="tip" />
23
+
24
+ - **类型:** `BriefModeOptions | NormalModeOptions`
25
+ - **可选:** `true`
26
+ - **默认值:** `undefined`
27
+ - **描述:**
28
+ 根据不同的 `mode` 配置,`options` 支持不同的配置项:
29
+
30
+ ### mode: 'brief'
31
+
32
+ Brief 模式用于生成轻量级的分析报告,支持 HTML 和 JSON 两种输出格式。
33
+
34
+ - **`type`**:输出类型,支持 `'html'` 和 `'json'` 数组,可同时选择多种格式
35
+ - **`htmlOptions`**:HTML 输出相关配置
36
+ - **`reportHtmlName`**:HTML 报告文件名,默认为 `report-rsdoctor.html`
37
+ - **`jsonOptions`**:JSON 输出相关配置
38
+ - **`sections`**:JSON 输出包含的模块配置
39
+ - **`moduleGraph`**:是否包含模块图数据,默认为 `true`
40
+ - **`chunkGraph`**:是否包含 Chunk 图数据,默认为 `true`
41
+ - **`rules`**:是否包含规则数据,默认为 `true`
42
+
43
+ **配置示例:**
44
+
45
+ ```js
46
+ new RsdoctorRspackPlugin({
47
+ output: {
48
+ mode: 'brief',
49
+ options: {
50
+ // 同时输出 HTML 和 JSON 格式
51
+ type: ['html', 'json'],
52
+ htmlOptions: {
53
+ reportHtmlName: 'my-report.html',
54
+ },
55
+ },
56
+ },
57
+ });
58
+ ```
59
+
60
+ **注意事项:**
61
+
62
+ - Brief 模式下,**`reportCodeType`** 配置项无效,因为只支持 **`'noCode'`**。
63
+ - Brief 模式下,**type 为 'html' 时**,分析数据会直接注入到 HTML 文件中,便于单文件分享。
64
+ - Brief 模式下,**type 为 'json' 时**,会生成结构化的数据文件,便于程序化处理。
65
+
66
+ ### mode: 'normal'
67
+
68
+ Normal 模式下的 `options` 为空对象,无额外配置项。
69
+
70
+ ### 类型定义
71
+
72
+ #### BriefModeOptions
73
+
74
+ ```ts
75
+ interface BriefModeOptions {
76
+ /** 输出类型,支持 HTML 和 JSON */
77
+ type?: Array<'html' | 'json'>;
78
+ /** HTML 输出相关配置 */
79
+ htmlOptions?: BriefConfig;
80
+ /** JSON 输出相关配置 */
81
+ jsonOptions?: JsonOptions;
82
+ }
83
+
84
+ interface BriefConfig {
85
+ /** HTML 报告文件名,默认为 report-rsdoctor.html */
86
+ reportHtmlName?: string;
87
+ /** 是否额外生成 JSON 数据文件,默认为 false */
88
+ writeDataJson: boolean;
89
+ }
90
+
91
+ interface JsonOptions {
92
+ /** JSON 输出包含的模块配置 */
93
+ sections?: JsonSectionOptions;
94
+ }
95
+
96
+ interface JsonSectionOptions {
97
+ /** 是否包含模块图数据,默认为 true */
98
+ moduleGraph?: boolean;
99
+ /** 是否包含 Chunk 图数据,默认为 true */
100
+ chunkGraph?: boolean;
101
+ /** 是否包含规则数据,默认为 true */
102
+ rules?: boolean;
103
+ }
104
+ ```
105
+
106
+ #### NormalModeOptions
107
+
108
+ NormalModeOptions 目前类型为空 Object。
109
+
110
+ ## reportCodeType
111
+
112
+ - **类型:** `"noModuleSource" | "noAssetsAndModuleSource" | "noCode" | { noModuleSource?: boolean; noAssetsAndModuleSource?: boolean; noCode?: boolean }`
113
+ - **V2 时,类型将只支持 String 类型。**
114
+ - **可选:** `true`
115
+ - **默认值:** `undefined`,undefined 时输出所有完整数据。
116
+ - **描述:**
117
+ 选择输出的分析数据范围:
118
+ - **默认**:输出所有完整数据
119
+ - **`noModuleSource`**:输出除模块([Module](https://rspack.rs/config/module#module))代码外的数据,模块([Module](https://rspack.rs/config/module#module))代码即产物(([Module](https://rspack.rs/config/module#module)))内各个文件的打包模块代码
120
+ - **`noAssetsAndModuleSource`**:输出除模块([Module](https://rspack.rs/config/module#module))代码和 Assets 产物代码外的数据
121
+ - **`noCode`**:输出除代码外的数据,即不输出任何代码
122
+
123
+ ### 输出数据对比表
124
+
125
+ | 配置项 | 包含的数据 | 不包含数据 | 适用场景 | 文件大小 |
126
+ | --------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------- | -------- |
127
+ | **默认** (不配置) | **完整构建信息:**<br/>• Modules 数据及其打包后代码<br/>• Assets 代码<br/>• 其他分析数据 | 无 | • 开发调试<br/>• 完整分析 | 最大 |
128
+ | **noModuleSource** | • 构建信息<br/>• Modules 数据及其打包后代码<br/>• Assets 代码<br/>• 其他分析数据 | Modules 源代码 | • 不需要查看源代码<br/>• 发生内存泄漏问题 | 中等 |
129
+ | **noAssetsAndModuleSource** | • 构建信息<br/>• Modules 数据及其打包后代码<br/>• 其他分析数据 | Module 源代码、Assets 代码 | • 大型项目<br/>• 不需要查看源代码和 Assets 代码<br/>• 发生内存泄漏问题 | 较小 |
130
+ | **noCode** | • 构建信息<br/>• Modules 数据<br/>• 其他分析数据 | 所有代码(Module 源代码 + Module 打包后代码 + Assets 代码) | • 大型项目<br/>• CI/CD<br/>• 发生内存泄漏问题 | 最小 |
131
+
132
+ **数据输出从丰富到简的排序:** `默认` > `noModuleSource` > `noAssetsAndModuleSource` > `noCode`
133
+
134
+ > Asset 和 Module 解释,见[术语](./term)
135
+
136
+ - **示例:**
137
+
138
+ ```js
139
+ new RsdoctorRspackPlugin({
140
+ reportCodeType: { noModuleSource: true } // { noAssetsAndModuleSource: true }
141
+ }),
142
+ ```
143
+
144
+ ## reportDir
145
+
146
+ - **类型:** `string`
147
+ - **可选:** `true`
148
+ - **默认值:** `undefined`
149
+
150
+ Rsdoctor 报告输出目录,默认是构建产物输出目录。
151
+
152
+ ## compressData
153
+
154
+ :::warning
155
+ V2 中即将废弃,请使用 `output.mode: 'brief'` 和 `output.options.type: 'json'` 代替。参考 [compressData 配置迁移](/config/options/options-v2#compressdata)。
156
+ :::
157
+
158
+ - **类型:** `boolean`
159
+ - **可选:** `true`
160
+ - **默认值:** `true`
161
+
162
+ compressData 用于配置是否将 `[outputDir]/.rsdoctor` 下的分析数据进行压缩处理。