@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.
- package/docs/en/{_meta.json → _nav.json} +5 -0
- package/docs/en/blog/release/release-note-1_0.mdx +2 -2
- package/docs/en/config/options/_meta.json +13 -1
- package/docs/en/config/options/brief.mdx +35 -0
- package/docs/en/config/options/disableClientServer.mdx +11 -0
- package/docs/en/config/options/experiments.mdx +21 -0
- package/docs/en/config/options/features.mdx +70 -0
- package/docs/en/config/options/mode.mdx +20 -0
- package/docs/en/config/options/options-v2.mdx +40 -0
- package/docs/en/config/options/options.mdx +61 -266
- package/docs/en/config/options/output.mdx +162 -0
- package/docs/en/config/options/port.mdx +7 -0
- package/docs/en/config/options/supports.mdx +72 -0
- package/docs/en/config/options/term.mdx +35 -2
- package/docs/en/guide/more/faq.mdx +14 -14
- package/docs/en/guide/rules/rule-custom.mdx +1 -11
- package/docs/en/guide/start/cli.mdx +5 -5
- package/docs/en/guide/start/intro.mdx +1 -1
- package/docs/en/guide/start/quick-start-shared.mdx +1 -1
- package/docs/en/guide/usage/bundle-size.mdx +1 -1
- package/docs/en/guide/usage/module-analysis.mdx +1 -2
- package/docs/en/shared/mode-intro.md +2 -1
- package/docs/public/netlify.toml +12 -0
- package/docs/zh/{_meta.json → _nav.json} +5 -0
- package/docs/zh/blog/release/release-note-1_0.mdx +1 -1
- package/docs/zh/config/options/_meta.json +13 -1
- package/docs/zh/config/options/brief.mdx +35 -0
- package/docs/zh/config/options/disableClientServer.mdx +11 -0
- package/docs/zh/config/options/experiments.mdx +21 -0
- package/docs/zh/config/options/features.mdx +70 -0
- package/docs/zh/config/options/mode.mdx +20 -0
- package/docs/zh/config/options/options-v2.mdx +40 -0
- package/docs/zh/config/options/options.mdx +61 -265
- package/docs/zh/config/options/output.mdx +162 -0
- package/docs/zh/config/options/port.mdx +7 -0
- package/docs/zh/config/options/supports.mdx +71 -0
- package/docs/zh/config/options/term.mdx +33 -0
- package/docs/zh/guide/more/faq.mdx +12 -12
- package/docs/zh/guide/rules/rule-custom.mdx +1 -11
- package/docs/zh/guide/start/cli.mdx +5 -5
- package/docs/zh/guide/start/intro.mdx +1 -1
- package/docs/zh/guide/start/quick-start-shared.mdx +1 -1
- package/docs/zh/guide/usage/module-analysis.mdx +1 -2
- package/docs/zh/shared/mode-intro.md +1 -0
- package/package.json +17 -14
|
@@ -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 | 模块 | 构建的最小单元,源文件 |
|
|
@@ -94,19 +94,19 @@ export default {
|
|
|
94
94
|
- rspeedy 项目中,在 `rspeedy.config.ts` 中配置:
|
|
95
95
|
|
|
96
96
|
```js rspeedy.config.ts
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
97
|
+
export default {
|
|
98
|
+
tools: {
|
|
99
|
+
rspack(config, { env }) {
|
|
100
|
+
if (process.env.RSDOCTOR === 'true') {
|
|
101
|
+
config.optimization = {
|
|
102
|
+
...config.optimization,
|
|
103
|
+
concatenateModules: false,
|
|
104
|
+
};
|
|
105
|
+
return config;
|
|
106
|
+
}
|
|
108
107
|
},
|
|
109
|
-
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
## CssExtractRspackPlugin 的 loader 耗时过长问题
|
|
@@ -73,7 +73,7 @@ export default {
|
|
|
73
73
|
|
|
74
74
|
import { PackageManagerTabs } from '@theme';
|
|
75
75
|
|
|
76
|
-
import { Tab, Tabs } from 'rspress/theme';
|
|
76
|
+
import { Tab, Tabs } from '@rspress/core/theme';
|
|
77
77
|
|
|
78
78
|
<PackageManagerTabs command="add @rsdoctor/core -D" />
|
|
79
79
|
|
|
@@ -200,19 +200,15 @@ const CheckRule = defineRule<typeof ruleTitle, config>(() => ({
|
|
|
200
200
|
[LinkRule Type](#linkrulestoredata)
|
|
201
201
|
|
|
202
202
|
- 组件输入
|
|
203
|
-
|
|
204
203
|
- type
|
|
205
|
-
|
|
206
204
|
- 使用组件类型。
|
|
207
205
|
- value: 'link'。
|
|
208
206
|
|
|
209
207
|
- title
|
|
210
|
-
|
|
211
208
|
- 规则标题。
|
|
212
209
|
- type: string。
|
|
213
210
|
|
|
214
211
|
- description
|
|
215
|
-
|
|
216
212
|
- 规则描述。数据来源为 report 中的 message 或 detail.description:
|
|
217
213
|
```js
|
|
218
214
|
report({
|
|
@@ -226,7 +222,6 @@ const CheckRule = defineRule<typeof ruleTitle, config>(() => ({
|
|
|
226
222
|
- type: string。
|
|
227
223
|
|
|
228
224
|
- level
|
|
229
|
-
|
|
230
225
|
- 规则级别。
|
|
231
226
|
- type:warn | error。
|
|
232
227
|
|
|
@@ -267,19 +262,15 @@ report({
|
|
|
267
262
|
[CodeViewRule Type](#codeviewrule)
|
|
268
263
|
|
|
269
264
|
- 组件输入
|
|
270
|
-
|
|
271
265
|
- type
|
|
272
|
-
|
|
273
266
|
- 使用组件类型。
|
|
274
267
|
- value: 'code-view'。
|
|
275
268
|
|
|
276
269
|
- title
|
|
277
|
-
|
|
278
270
|
- 规则标题。
|
|
279
271
|
- type: string。
|
|
280
272
|
|
|
281
273
|
- description
|
|
282
|
-
|
|
283
274
|
- 规则描述。数据来源为 report 中的 message 或 detail.description:
|
|
284
275
|
```js
|
|
285
276
|
report({
|
|
@@ -293,7 +284,6 @@ report({
|
|
|
293
284
|
- type: string。
|
|
294
285
|
|
|
295
286
|
- level
|
|
296
|
-
|
|
297
287
|
- 规则级别。
|
|
298
288
|
- type:warn | error。
|
|
299
289
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { PackageManagerTabs } from '@theme';
|
|
19
19
|
|
|
20
|
-
import { Tab, Tabs } from 'rspress/theme';
|
|
20
|
+
import { Tab, Tabs } from '@rspress/core/theme';
|
|
21
21
|
|
|
22
22
|
<PackageManagerTabs command="add @rsdoctor/cli -D" />
|
|
23
23
|
|
|
@@ -76,18 +76,18 @@ rsdoctor bundle-diff --baseline="baseline/.rsdoctor/manifest.json" --current="cu
|
|
|
76
76
|
|
|
77
77
|
<Tabs>
|
|
78
78
|
|
|
79
|
-
<Tab label="
|
|
79
|
+
<Tab label="esm">
|
|
80
80
|
|
|
81
81
|
```js
|
|
82
|
-
|
|
82
|
+
import { execute } from '@rsdoctor/cli';
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
</Tab>
|
|
86
86
|
|
|
87
|
-
<Tab label="
|
|
87
|
+
<Tab label="cjs">
|
|
88
88
|
|
|
89
89
|
```js
|
|
90
|
-
|
|
90
|
+
const { execute } = require('@rsdoctor/cli');
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
</Tab>
|
|
@@ -4,7 +4,7 @@ Rsdoctor 是一款为 [Rspack](https://rspack.rs/) 生态量身打造的构建
|
|
|
4
4
|
|
|
5
5
|
Rsdoctor 致力于成为一站式、智能化的构建分析工具,通过可视化与智能分析,使整个构建流程变得透明、可预测和可优化,从而帮助开发团队精准定位瓶颈、优化性能并提升工程质量。
|
|
6
6
|
|
|
7
|
-
Rsdoctor 支持所有基于 Rspack 或 webpack 的工具和框架,例如:[Docusaurus](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-rsdoctor)、[Rspeedy (Lynx)](https://lynxjs.org/rspeedy/)、[Storybook](https://github.com/rspack-contrib/storybook-rsbuild)、[Next.js](https://nextjs.org/)、[Nuxt](https://nuxt.com/)、[Re.Pack](https://re-pack.dev/)、[Modern.js](https://modernjs.dev/)、[Rsbuild](https://rsbuild.rs/)、[Rspress](https://rspress.rs/) 和 [Rslib](https://
|
|
7
|
+
Rsdoctor 支持所有基于 Rspack 或 webpack 的工具和框架,例如:[Docusaurus](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-rsdoctor)、[Rspeedy (Lynx)](https://lynxjs.org/rspeedy/)、[Storybook](https://github.com/rspack-contrib/storybook-rsbuild)、[Next.js](https://nextjs.org/)、[Nuxt](https://nuxt.com/)、[Re.Pack](https://re-pack.dev/)、[Modern.js](https://modernjs.dev/)、[Rsbuild](https://rsbuild.rs/)、[Rspress](https://rspress.rs/) 和 [Rslib](https://rslib.rs/) 等。
|
|
8
8
|
|
|
9
9
|
<video
|
|
10
10
|
src="https://assets.rspack.rs/others/assets/rsdoctor/rsdoctor-1.0-ui.mp4"
|
|
@@ -84,7 +84,7 @@ export default {
|
|
|
84
84
|
|
|
85
85
|
在 `next.config.ts` 的 [Rspack 配置](https://rspack.rs/guide/tech/next)([webpack 配置](https://nextjs.org/docs/pages/api-reference/config/next-config-js/webpack)) 中初始化 [RsdoctorRspackPlugin](#rspack-%E9%A1%B9%E7%9B%AE)([RsdoctorWebpackPlugin](#webpack-%E9%A1%B9%E7%9B%AE)) 插件。
|
|
86
86
|
|
|
87
|
-
import { Tab, Tabs } from 'rspress/theme';
|
|
87
|
+
import { Tab, Tabs } from '@rspress/core/theme';
|
|
88
88
|
|
|
89
89
|
<Tabs>
|
|
90
90
|
<Tab label="Rspack">
|
|
@@ -48,9 +48,8 @@
|
|
|
48
48
|
- `Usage` 标签会展示各种模块标签的作用。
|
|
49
49
|
|
|
50
50
|
- `Concatenated`标签:
|
|
51
|
-
|
|
52
51
|
- `Concatenated` 标签标识该模块是被串联的子模块,`hover` 上去就可以看到被聚合到了哪个主模块中。这种聚合模块无法继续拆解打包后的代码,因此无法得知具体的 `Bundled Size`,只能得知整个串联模块的大小。
|
|
53
|
-
- 名词解释:串联模块是将多个模块在打包时提升或串联到一个闭包中。 `Concatenated Module` 的解释可以查看[名词解释](guide/usage/bundle-size#%E5%90%8D%E8%AF%8D%E8%A7%A3%E9%87%8A)。
|
|
52
|
+
- 名词解释:串联模块是将多个模块在打包时提升或串联到一个闭包中。 `Concatenated Module` 的解释可以查看[名词解释](/guide/usage/bundle-size#%E5%90%8D%E8%AF%8D%E8%A7%A3%E9%87%8A)。
|
|
54
53
|
|
|
55
54
|
- `!` 标签,`hover` 上去可以展示模块详细路径.
|
|
56
55
|
|
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
- **brief 模式:** 在构建产物目录的 `.rsdoctor` 文件夹中生成一个 HTML 报告文件,所有构建分析数据会整合注入到这个 HTML 文件中,可以通过浏览器打开该 HTML 文件查看报告。brief 模式还有更多配置项,详细信息请参阅:[brief](/config/options/options#brief).
|
|
4
4
|
|
|
5
5
|
- **lite 模式:** 基于普通模式,不展示源码和产物代码,仅显示打包后的代码信息。
|
|
6
|
+
- lite 模式即将在 V2 废弃,参考 [lite 模式废弃说明](/config/options/options-v2#lite)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/docs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -18,29 +18,32 @@
|
|
|
18
18
|
"registry": "https://registry.npmjs.org/"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@rspress/plugin-algolia": "2.0.0-beta.
|
|
22
|
-
"@rspress/plugin-llms": "2.0.0-beta.
|
|
23
|
-
"@rspress/plugin-rss": "2.0.0-beta.
|
|
21
|
+
"@rspress/plugin-algolia": "2.0.0-beta.29",
|
|
22
|
+
"@rspress/plugin-llms": "2.0.0-beta.29",
|
|
23
|
+
"@rspress/plugin-rss": "2.0.0-beta.29",
|
|
24
24
|
"@types/node": "^22.8.1",
|
|
25
|
-
"@types/react": "^18.3.
|
|
25
|
+
"@types/react": "^18.3.24",
|
|
26
26
|
"@types/react-dom": "^18.3.7",
|
|
27
|
+
"cross-env": "^7.0.3",
|
|
27
28
|
"react": "18.3.1",
|
|
28
29
|
"react-dom": "18.3.1",
|
|
29
|
-
"rsbuild-plugin-google-analytics": "^1.0.
|
|
30
|
-
"rsbuild-plugin-open-graph": "^1.0
|
|
31
|
-
"rspress-plugin-font-open-sans": "^1.0.
|
|
30
|
+
"rsbuild-plugin-google-analytics": "^1.0.4",
|
|
31
|
+
"rsbuild-plugin-open-graph": "^1.1.0",
|
|
32
|
+
"rspress-plugin-font-open-sans": "^1.0.3",
|
|
32
33
|
"rspress-plugin-sitemap": "^1.1.4",
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"@
|
|
34
|
+
"typescript": "^5.9.2",
|
|
35
|
+
"@rsbuild/plugin-sass": "^1.4.0",
|
|
36
|
+
"@rsdoctor/types": "1.2.4-beta.1"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
|
-
"@rstack-dev/doc-ui": "1.
|
|
39
|
+
"@rstack-dev/doc-ui": "1.11.0",
|
|
40
|
+
"clsx": "^2.1.1",
|
|
38
41
|
"react-markdown": "^9.1.0",
|
|
39
|
-
"rspress": "2.0.0-beta.
|
|
42
|
+
"@rspress/core": "2.0.0-beta.29"
|
|
40
43
|
},
|
|
41
44
|
"scripts": {
|
|
42
|
-
"dev": "rspress dev",
|
|
43
|
-
"build": "rspress build",
|
|
45
|
+
"dev": "cross-env RSPRESS_PERSIST_CACHE=false rspress dev",
|
|
46
|
+
"build": "cross-env RSPRESS_PERSIST_CACHE=false rspress build && sh build.sh",
|
|
44
47
|
"preview": "rspress preview"
|
|
45
48
|
}
|
|
46
49
|
}
|