@rsdoctor/docs 1.2.4-beta.0 → 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 (38) hide show
  1. package/docs/en/{_meta.json → _nav.json} +5 -0
  2. package/docs/en/config/options/_meta.json +13 -1
  3. package/docs/en/config/options/brief.mdx +35 -0
  4. package/docs/en/config/options/disableClientServer.mdx +11 -0
  5. package/docs/en/config/options/experiments.mdx +21 -0
  6. package/docs/en/config/options/features.mdx +70 -0
  7. package/docs/en/config/options/mode.mdx +20 -0
  8. package/docs/en/config/options/options-v2.mdx +40 -0
  9. package/docs/en/config/options/options.mdx +61 -266
  10. package/docs/en/config/options/output.mdx +162 -0
  11. package/docs/en/config/options/port.mdx +7 -0
  12. package/docs/en/config/options/supports.mdx +72 -0
  13. package/docs/en/config/options/term.mdx +36 -3
  14. package/docs/en/guide/rules/rule-custom.mdx +1 -11
  15. package/docs/en/guide/start/cli.mdx +5 -5
  16. package/docs/en/guide/start/quick-start-shared.mdx +1 -1
  17. package/docs/en/guide/usage/module-analysis.mdx +1 -2
  18. package/docs/en/shared/mode-intro.md +2 -1
  19. package/docs/public/netlify.toml +12 -0
  20. package/docs/zh/{_meta.json → _nav.json} +5 -0
  21. package/docs/zh/config/options/_meta.json +13 -1
  22. package/docs/zh/config/options/brief.mdx +35 -0
  23. package/docs/zh/config/options/disableClientServer.mdx +11 -0
  24. package/docs/zh/config/options/experiments.mdx +21 -0
  25. package/docs/zh/config/options/features.mdx +70 -0
  26. package/docs/zh/config/options/mode.mdx +20 -0
  27. package/docs/zh/config/options/options-v2.mdx +40 -0
  28. package/docs/zh/config/options/options.mdx +61 -265
  29. package/docs/zh/config/options/output.mdx +162 -0
  30. package/docs/zh/config/options/port.mdx +7 -0
  31. package/docs/zh/config/options/supports.mdx +71 -0
  32. package/docs/zh/config/options/term.mdx +33 -0
  33. package/docs/zh/guide/rules/rule-custom.mdx +1 -11
  34. package/docs/zh/guide/start/cli.mdx +5 -5
  35. package/docs/zh/guide/start/quick-start-shared.mdx +1 -1
  36. package/docs/zh/guide/usage/module-analysis.mdx +1 -2
  37. package/docs/zh/shared/mode-intro.md +1 -0
  38. package/package.json +15 -13
@@ -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` 下的分析数据进行压缩处理。
@@ -0,0 +1,7 @@
1
+ # port
2
+
3
+ - **类型:** `number`
4
+ - **可选:** `true`
5
+ - **默认值:** `random(3000, 8999)`
6
+
7
+ 配置 Rsdoctor 服务的端口。
@@ -0,0 +1,71 @@
1
+ import { Badge } from '@theme';
2
+
3
+ # supports
4
+
5
+ - **类型:** [Supports Types](#supports-types)
6
+ - **可选:** `true`
7
+ - **默认值:** `undefined`
8
+
9
+ 该选项是配置 Rsdoctor 是否开启某些细节特性分析能力支持的,例如:是否开启对 BannerPlugin 的兼容能力。
10
+
11
+ ## supportsTypes
12
+
13
+ ```ts
14
+ type ISupport = {
15
+ banner?: boolean;
16
+ parseBundle?: boolean;
17
+ generateTileGraph?: boolean;
18
+ };
19
+ ```
20
+
21
+ ## banner
22
+
23
+ :::danger
24
+ `supports.banner` 分析仅用于调试,请勿将其用于生产。
25
+ :::
26
+
27
+ - **类型:** `boolean`
28
+ - **默认值:** `true`
29
+
30
+ 如果开启 `supports.banner` 则会开启 Rsdoctor 对 BannerPlugin 的兼容逻辑。详细请看:[支持 BannerPlugin](../../guide/usage/bundle-size#%E6%94%AF%E6%8C%81-bannerplugin)
31
+
32
+ ## ~~generateTileGraph [**Deprecated**]~~
33
+
34
+ <Badge text="Deprecated" type="warning" />
35
+
36
+ Rsdoctor 默认支持生成 Tree Map 图,所以不需要配置此选项。
37
+
38
+ ## parseBundle
39
+
40
+ - **类型:** `boolean`
41
+ - **默认值:** `true`
42
+
43
+ 在部分大型仓库中,反解 Bundle 解析执行耗时过大,这是因为 Parse Bundle 的分析利用了 AST 解析与处理。当产物文件过多时,耗时也会增加。如果不需要此功能,可以通过 `supports.parseBundle` 配置进行选择性关闭。示例如下:
44
+
45
+ ```ts
46
+ chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
47
+ {
48
+ supports: {
49
+ parseBundle: false,
50
+ },
51
+ },
52
+ ]);
53
+ ```
54
+
55
+ 关闭 Parse Bundle 能力只会影响是否能查看到 Bundle 中 Module 的最终打包大小(Bundled Size)及最终打包代码(Bundled Code):
56
+
57
+ <div style={{ display: 'flex' }}>
58
+ <img
59
+ src="https://assets.rspack.rs/others/assets/rsdoctor/bundled-size.jpeg"
60
+ height="300px"
61
+ width="300px"
62
+ style={{ margin: 'auto' }}
63
+ />
64
+
65
+ <img
66
+ src="https://assets.rspack.rs/others/assets/rsdoctor/bundled-code.png"
67
+ height="300px"
68
+ width="400px"
69
+ style={{ margin: 'auto' }}
70
+ />
71
+ </div>
@@ -8,3 +8,36 @@
8
8
 
9
9
  - 其**文件名为 `manifest.json`**
10
10
  - 该文件的输出**路径为 `项目产物目录/.rsdoctor/manifest.json`**
11
+
12
+ ### 产物中的名词释义
13
+
14
+ ### assets(资源|产物文件)
15
+
16
+ **定义:**
17
+ 指的是项目中所有静态文件,例如图片、字体、CSS、JS、SVG 等。它们是构建后被输出到目标目录的文件,最终会被浏览器加载和使用。
18
+
19
+ **举例:**
20
+
21
+ - `logo.png`、`main.css`、`app.js` 都属于资源。
22
+
23
+ ### chunk
24
+
25
+ **定义:**
26
+ Rspack 会把多个模块(JS、CSS 等)打包成一个或多个文件,这些文件就是 bundle。一个 chunk 可能包含多个 Assets,例如:name 为 index 的 chunk 可能包含 index.js 和 index.css 两个产物。
27
+
28
+ ### module(模块)
29
+
30
+ **定义:**
31
+ 在 Rspack 中,任何文件都可以被视为模块。最常见的是 JS 模块(通过 `import` 或 `require`),但也可以是 CSS、图片等。模块是构建中的最小单元,Rspack 通过依赖图将它们组织起来。Assets 是由 Modules 集合组成的。
32
+
33
+ **举例:**
34
+
35
+ - 第三方文件或源码文件,例如 `index.js`、`button.js`、`style.css`,都是模块,这些文件不是产物文件,但是会参与到产物文件的打包过程中,并且可能会最终被打包到产物文件中。
36
+
37
+ ### 总结对比
38
+
39
+ | 英文名 | 中文定义 | Rspack 中的作用 |
40
+ | ------ | -------- | ---------------------------------------------- |
41
+ | assets | 资源 | 最终产物,静态文件 |
42
+ | chunk | | 输出的打包文件,一个 chunk 可能包含多个 assets |
43
+ | module | 模块 | 构建的最小单元,源文件 |