@rsdoctor/docs 1.5.11 → 2.0.0-alpha.0
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/config/options/features.mdx +2 -10
- package/docs/en/config/options/options-shared.mdx +2 -10
- package/docs/en/config/options/options.mdx +4 -40
- package/docs/en/config/options/term.mdx +1 -1
- package/docs/en/guide/rules/rule-custom.mdx +1 -1
- package/docs/en/guide/start/cli.mdx +2 -2
- package/docs/en/guide/start/intro.mdx +1 -1
- package/docs/en/guide/start/quick-start-shared.mdx +2 -70
- package/docs/en/guide/start/quick-start.mdx +0 -10
- package/docs/en/guide/usage/mcp.mdx +0 -1
- package/docs/en/guide/usage/resolver.mdx +2 -4
- package/docs/en/shared/features-rspack.md +12 -2
- package/docs/zh/blog/release/release-note-0_1.mdx +1 -1
- package/docs/zh/config/options/features.mdx +3 -11
- package/docs/zh/config/options/options-shared.mdx +4 -12
- package/docs/zh/config/options/options.mdx +4 -40
- package/docs/zh/config/options/term.mdx +1 -1
- package/docs/zh/guide/rules/rule-custom.mdx +1 -1
- package/docs/zh/guide/start/cli.mdx +2 -2
- package/docs/zh/guide/start/intro.mdx +1 -1
- package/docs/zh/guide/start/quick-start-shared.mdx +2 -69
- package/docs/zh/guide/start/quick-start.mdx +0 -10
- package/docs/zh/guide/usage/mcp.mdx +0 -1
- package/docs/zh/guide/usage/resolver.mdx +2 -4
- package/docs/zh/shared/features-rspack.md +12 -2
- package/package.json +14 -14
- package/docs/en/shared/features.md +0 -30
- package/docs/zh/shared/features.md +0 -30
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# features
|
|
2
2
|
|
|
3
|
-
- **Type:** [
|
|
3
|
+
- **Type:** [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures\>](#rsdoctorrspackpluginfeatures)
|
|
4
4
|
- **Optional:** `true`
|
|
5
5
|
- **Default:** `['loader', 'plugins', 'bundle']`
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ The `features` attribute is used for analysis feature toggles, and the specific
|
|
|
14
14
|
- **resolver**: Resolver analysis, disabled by default.
|
|
15
15
|
- **lite**: **(lite mode will be deprecated in V2, refer to [lite mode deprecation notice](/config/options/options-v2#lite))** lite mode. The difference between lite mode and normal mode is that source code information is no longer displayed, only packaged code information is displayed, so the code analyzed on the page will also be packaged. Default is normal mode.
|
|
16
16
|
|
|
17
|
-
Therefore, **the default configuration enables Bundle analysis capabilities, Loader and Plugin build-time analysis**. Resolver analysis
|
|
17
|
+
Therefore, **the default configuration enables Bundle analysis capabilities, Loader and Plugin build-time analysis**. Resolver analysis is not enabled by default. To enable it, explicitly configure `resolver` in `features`.
|
|
18
18
|
|
|
19
19
|
### Types
|
|
20
20
|
|
|
@@ -53,14 +53,6 @@ new RsdoctorRspackPlugin({
|
|
|
53
53
|
|
|
54
54
|
:::
|
|
55
55
|
|
|
56
|
-
## RsdoctorWebpackPluginFeatures
|
|
57
|
-
|
|
58
|
-
`features` type:
|
|
59
|
-
|
|
60
|
-
import Features from '@en/shared/features.md';
|
|
61
|
-
|
|
62
|
-
<Features />
|
|
63
|
-
|
|
64
56
|
## RsdoctorRspackPluginFeatures
|
|
65
57
|
|
|
66
58
|
`features` type:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Type:** `Object`
|
|
4
4
|
|
|
5
|
-
This is the options for the [
|
|
5
|
+
This is the options for the [RsdoctorRspackPlugin](#rsdoctorrspackplugin). It contains these properties:
|
|
6
6
|
|
|
7
7
|
- [disableClientServer](#disableclientserver)
|
|
8
8
|
- [features](#features)
|
|
@@ -17,7 +17,7 @@ Whether to automatically open the Rsdoctor report page. If you do not need to vi
|
|
|
17
17
|
|
|
18
18
|
### features
|
|
19
19
|
|
|
20
|
-
- **Type:** [
|
|
20
|
+
- **Type:** [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures\>](#rsdoctorrspackpluginfeatures)
|
|
21
21
|
- **Optional:** `true`
|
|
22
22
|
- **Default:** `['loader', 'plugins', 'bundle']`
|
|
23
23
|
|
|
@@ -51,14 +51,6 @@ Therefore, **the default configuration enables bundle analysis capabilities and
|
|
|
51
51
|
- if the `features` is set as an `Array`, it will **open** the features which you define in this array **only**.
|
|
52
52
|
- if the `features` is set as an `Object`, it will **close** the features which you set the value is `false`.
|
|
53
53
|
|
|
54
|
-
#### RsdoctorWebpackPluginFeatures
|
|
55
|
-
|
|
56
|
-
The types of `features` are as follows:
|
|
57
|
-
|
|
58
|
-
import Features from '@zh/shared/features.md';
|
|
59
|
-
|
|
60
|
-
<Features />
|
|
61
|
-
|
|
62
54
|
#### RsdoctorRspackPluginFeatures
|
|
63
55
|
|
|
64
56
|
The types of `features` are as follows:
|
|
@@ -34,43 +34,11 @@ new RsdoctorRspackPlugin({
|
|
|
34
34
|
|
|
35
35
|
</Tabs>
|
|
36
36
|
|
|
37
|
-
## RsdoctorWebpackPlugin
|
|
38
|
-
|
|
39
|
-
The **RsdoctorWebpackPlugin** class is exported by `@rsdoctor/webpack-plugin`, and the configuration options are [RsdoctorWebpackPluginOptions](#rsdoctorwebpackpluginoptions).
|
|
40
|
-
|
|
41
|
-
<Tabs>
|
|
42
|
-
|
|
43
|
-
<Tab label="esm">
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
47
|
-
|
|
48
|
-
new RsdoctorWebpackPlugin({
|
|
49
|
-
/** RsdoctorWebpackPluginOptions */
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
</Tab>
|
|
54
|
-
|
|
55
|
-
<Tab label="cjs">
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
59
|
-
|
|
60
|
-
new RsdoctorWebpackPlugin({
|
|
61
|
-
/** RsdoctorWebpackPluginOptions */
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
</Tab>
|
|
66
|
-
|
|
67
|
-
</Tabs>
|
|
68
|
-
|
|
69
37
|
## Options
|
|
70
38
|
|
|
71
39
|
**Type:** `Object`
|
|
72
40
|
|
|
73
|
-
This `Options` object is the configuration for [RsdoctorRspackPlugin](#rsdoctorrspackplugin)
|
|
41
|
+
This `Options` object is the configuration for [RsdoctorRspackPlugin](#rsdoctorrspackplugin). It contains the following properties:
|
|
74
42
|
|
|
75
43
|
- [disableClientServer](./disableClientServer.mdx) - **Client Service Control**: Whether to not automatically open the Rsdoctor report service after analysis is complete.
|
|
76
44
|
- [experiments](./experiments.mdx) - **Experimental Features Configuration**: Enable experimental features for Rspack plugins, such as native plugin performance optimization.
|
|
@@ -84,7 +52,7 @@ This `Options` object is the configuration for [RsdoctorRspackPlugin](#rsdoctorr
|
|
|
84
52
|
### RsdoctorRspackPluginOptions
|
|
85
53
|
|
|
86
54
|
```ts
|
|
87
|
-
interface
|
|
55
|
+
interface RsdoctorRspackPluginOptions<
|
|
88
56
|
Rules extends LinterType.ExtendRuleData[],
|
|
89
57
|
> {
|
|
90
58
|
/** Linter configuration */
|
|
@@ -92,8 +60,8 @@ interface RsdoctorWebpackPluginOptions<
|
|
|
92
60
|
|
|
93
61
|
/** Rsdoctor feature toggles */
|
|
94
62
|
features?:
|
|
95
|
-
|
|
|
96
|
-
| Array<keyof
|
|
63
|
+
| RsdoctorRspackPluginFeatures
|
|
64
|
+
| Array<keyof RsdoctorRspackPluginFeatures>;
|
|
97
65
|
|
|
98
66
|
/**
|
|
99
67
|
* @deprecated Use `output.mode` instead. If using `lite` mode, please use `output.reportCodeType: 'noCode' or 'noAssetsAndModuleSource'` instead
|
|
@@ -127,7 +95,3 @@ interface RsdoctorRspackPluginExperiments {
|
|
|
127
95
|
enableNativePlugin?: boolean;
|
|
128
96
|
}
|
|
129
97
|
```
|
|
130
|
-
|
|
131
|
-
### RsdoctorWebpackPluginOptions
|
|
132
|
-
|
|
133
|
-
RsdoctorWebpackPlugin is equivalent to `Omit<RsdoctorRspackPluginOptions, 'experiments'>` type.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### manifest.json
|
|
6
6
|
|
|
7
|
-
When your project integrates with plugins provided by **Rsdoctor
|
|
7
|
+
When your project integrates with plugins provided by **Rsdoctor**, Rsdoctor will write **build-related data information** into a local JSON file:
|
|
8
8
|
|
|
9
9
|
- The **filename is `manifest.json`**
|
|
10
10
|
- The output **path is `project output directory/.rsdoctor/manifest.json`**
|
|
@@ -68,7 +68,7 @@ You can follow the detailed steps below to define and write custom rules.
|
|
|
68
68
|
|
|
69
69
|
### 1. Installation
|
|
70
70
|
|
|
71
|
-
When writing custom rules, in addition to installing the basic `@rsdoctor/rspack-plugin
|
|
71
|
+
When writing custom rules, in addition to installing the basic `@rsdoctor/rspack-plugin` dependencies, you also need to install `@rsdoctor/core` and use the defineRule function from `@rsdoctor/core/rules` to define unified Rsdoctor rules.
|
|
72
72
|
|
|
73
73
|
import { PackageManagerTabs } from '@theme';
|
|
74
74
|
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
We provide `@rsdoctor/cli` for you to use Rsdoctor's features locally through the CLI program.
|
|
4
4
|
|
|
5
5
|
:::tip
|
|
6
|
-
`@rsdoctor/
|
|
6
|
+
`@rsdoctor/rspack-plugin` and `@rsdoctor/cli` should have the same major and minor versions.
|
|
7
7
|
:::
|
|
8
8
|
|
|
9
9
|
## Install @rsdoctor/cli
|
|
10
10
|
|
|
11
11
|
:::tip
|
|
12
12
|
|
|
13
|
-
- @rsdoctor/cli & @rsdoctor/
|
|
13
|
+
- @rsdoctor/cli & @rsdoctor/rspack-plugin >= 0.1.3.
|
|
14
14
|
- You can also use the non-installation method by using the `npx @rsdoctor/cli <command> [options]` command.
|
|
15
15
|
|
|
16
16
|
:::
|
|
@@ -76,7 +76,7 @@ Provides corresponding data and analysis functions for **Loaders, Plugins, and M
|
|
|
76
76
|
|
|
77
77
|
#### Resolve analysis
|
|
78
78
|
|
|
79
|
-
- This module mainly provides path data and estimated time consumption for module resolution in a single file within the project. Rspack
|
|
79
|
+
- This module mainly provides path data and estimated time consumption for module resolution in a single file within the project. Rspack supports enabling this module through `features`.
|
|
80
80
|
|
|
81
81
|
<p>
|
|
82
82
|
<img
|
|
@@ -27,27 +27,6 @@ module.exports = {
|
|
|
27
27
|
|
|
28
28
|
Rsbuild has built-in support for Rsdoctor, so you don't need to manually register plugins. See [Rsbuild - Use Rsdoctor](https://rsbuild.rs/guide/debug/rsdoctor) for more details.
|
|
29
29
|
|
|
30
|
-
### Webpack
|
|
31
|
-
|
|
32
|
-
Initialize the RsdoctorWebpackPlugin in the [plugins](https://webpack.js.org/configuration/plugins/#plugins) of `webpack.config.js`:
|
|
33
|
-
|
|
34
|
-
```js title="webpack.config.js"
|
|
35
|
-
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
// ...
|
|
39
|
-
plugins: [
|
|
40
|
-
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
|
|
41
|
-
process.env.RSDOCTOR &&
|
|
42
|
-
new RsdoctorWebpackPlugin({
|
|
43
|
-
// plugin options
|
|
44
|
-
}),
|
|
45
|
-
].filter(Boolean),
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
50
|
-
|
|
51
30
|
### Modern.js
|
|
52
31
|
|
|
53
32
|
Initialize the plugin in the [tools.rspack](https://modernjs.dev/configure/app/tools/rspack) of `modern.config.ts`:
|
|
@@ -74,21 +53,11 @@ export default {
|
|
|
74
53
|
|
|
75
54
|
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
76
55
|
|
|
77
|
-
:::tip
|
|
78
|
-
For projects using Modern.js's webpack mode, please register the `RsdoctorWebpackPlugin` plugin through [tools.webpack](https://modernjs.dev/configure/app/tools/webpack).
|
|
79
|
-
:::
|
|
80
|
-
|
|
81
56
|
### Next.js
|
|
82
57
|
|
|
83
58
|
#### Step 1: Register the Rsdoctor plugin
|
|
84
59
|
|
|
85
|
-
Initialize the [RsdoctorRspackPlugin](#rspack-projects)
|
|
86
|
-
|
|
87
|
-
import { Tab, Tabs } from '@rspress/core/theme';
|
|
88
|
-
|
|
89
|
-
<Tabs>
|
|
90
|
-
|
|
91
|
-
<Tab label="Rspack">
|
|
60
|
+
Initialize the [RsdoctorRspackPlugin](#rspack-projects) plugin in the [Rspack Config](https://rspack.rs/guide/tech/next) of `next.config.ts`.
|
|
92
61
|
|
|
93
62
|
```ts title="next.config.ts"
|
|
94
63
|
import type { NextConfig } from 'next';
|
|
@@ -120,43 +89,6 @@ const nextConfig: NextConfig = {
|
|
|
120
89
|
export default nextConfig;
|
|
121
90
|
```
|
|
122
91
|
|
|
123
|
-
</Tab>
|
|
124
|
-
|
|
125
|
-
<Tab label="webpack">
|
|
126
|
-
|
|
127
|
-
```ts title="next.config.ts"
|
|
128
|
-
import type { NextConfig } from 'next';
|
|
129
|
-
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
130
|
-
|
|
131
|
-
const nextConfig: NextConfig = {
|
|
132
|
-
/* config options here */
|
|
133
|
-
webpack: (config) => {
|
|
134
|
-
if (config.name === 'client') {
|
|
135
|
-
config.plugins.push(
|
|
136
|
-
new RsdoctorWebpackPlugin({
|
|
137
|
-
disableClientServer: true,
|
|
138
|
-
}),
|
|
139
|
-
);
|
|
140
|
-
} else if (config.name === 'server') {
|
|
141
|
-
config.plugins.push(
|
|
142
|
-
new RsdoctorWebpackPlugin({
|
|
143
|
-
disableClientServer: true,
|
|
144
|
-
output: {
|
|
145
|
-
reportDir: './.next/server',
|
|
146
|
-
},
|
|
147
|
-
}),
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
return config;
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export default nextConfig;
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
</Tab>
|
|
158
|
-
</Tabs>
|
|
159
|
-
|
|
160
92
|
- **Options:** The plugin provides some configuration options, please refer to [Options](../../config/options/options).
|
|
161
93
|
|
|
162
94
|
#### Step 2: Execute build
|
|
@@ -193,7 +125,7 @@ rsdoctor analyze --profile .next/server/chunks/.rsdoctor/manifest.json
|
|
|
193
125
|
|
|
194
126
|
### Vue project
|
|
195
127
|
|
|
196
|
-
Initialize the `@rsdoctor/
|
|
128
|
+
Initialize the `@rsdoctor/rspack-plugin` plugin in the configuration file. Here is an example using `rsbuild`:
|
|
197
129
|
|
|
198
130
|
```ts title="rsbuild.config.ts"
|
|
199
131
|
import { defineConfig } from '@rsbuild/core';
|
|
@@ -12,16 +12,6 @@ For projects based on Rspack, such as Rsbuild or Rslib, install the following de
|
|
|
12
12
|
|
|
13
13
|
<PackageManagerTabs command="add @rsdoctor/rspack-plugin -D" />
|
|
14
14
|
|
|
15
|
-
### Webpack projects
|
|
16
|
-
|
|
17
|
-
:::tip
|
|
18
|
-
Rsdoctor only supports webpack >= 5.
|
|
19
|
-
:::
|
|
20
|
-
|
|
21
|
-
For projects based on webpack, install the following dependencies:
|
|
22
|
-
|
|
23
|
-
<PackageManagerTabs command="add @rsdoctor/webpack-plugin -D" />
|
|
24
|
-
|
|
25
15
|
---
|
|
26
16
|
|
|
27
17
|
import QuickStartShared from './quick-start-shared.mdx';
|
|
@@ -100,7 +100,6 @@ By asking "Please help me to check why react-dom/client.js can not be tree-shake
|
|
|
100
100
|
The following Rsdoctor plugin versions are required:
|
|
101
101
|
|
|
102
102
|
- @rsdoctor/rspack-plugin >= 1.1.2
|
|
103
|
-
- @rsdoctor/webpack-plugin >= 1.1.2
|
|
104
103
|
|
|
105
104
|
Note: Please ensure you are using the latest version for the best experience.
|
|
106
105
|
:::
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
:::tip
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- The Resolver analysis capability is disabled by default. To enable it, you can add `resolver` to the `features` array as shown in the example below. [features configuration](../../config/options/options).
|
|
5
|
+
Resolver analysis is supported for Rspack, but it is disabled by default. To enable it, add `resolver` to the `features` array as shown in the example below. See [features configuration](../../config/options/options).
|
|
8
6
|
|
|
9
7
|
```js
|
|
10
|
-
new
|
|
8
|
+
new RsdoctorRspackPlugin({
|
|
11
9
|
features: [
|
|
12
10
|
'resolver',
|
|
13
11
|
// ...other features
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
```ts
|
|
2
2
|
interface RsdoctorRspackPluginFeatures {
|
|
3
3
|
/**
|
|
4
|
-
* turn off it if you need not to analyze the executions of
|
|
4
|
+
* turn off it if you need not to analyze the executions of Rspack loaders.
|
|
5
5
|
* @default true
|
|
6
6
|
*/
|
|
7
7
|
loader?: boolean;
|
|
8
8
|
/**
|
|
9
|
-
* turn off it if you need not to analyze the executions of
|
|
9
|
+
* turn off it if you need not to analyze the executions of Rspack plugins.
|
|
10
10
|
* @default true
|
|
11
11
|
*/
|
|
12
12
|
plugins?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* turn on it if you need to analyze resolver executions.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
resolver?: boolean;
|
|
13
18
|
/**
|
|
14
19
|
* turn off it if you need not to analyze the output bundle.
|
|
15
20
|
* @default true
|
|
16
21
|
*/
|
|
17
22
|
bundle?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* turn on it if you need to analyze the tree shaking result.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
treeShaking?: boolean;
|
|
18
28
|
/**
|
|
19
29
|
* turn on it if you just use lite mode. This mode do not have source codes.
|
|
20
30
|
* @default false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# features
|
|
2
2
|
|
|
3
|
-
- **类型:** [
|
|
3
|
+
- **类型:** [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures\>](#rsdoctorrspackpluginfeatures)
|
|
4
4
|
- **可选:** `true`
|
|
5
5
|
- **默认值:** `["loader", "plugins", "bundle"]`
|
|
6
6
|
|
|
@@ -11,10 +11,10 @@ features 属性是用于分析功能开关的,具体的功能项如下:
|
|
|
11
11
|
- **loader**:Loaders 耗时及代码编译变化分析,默认开启。
|
|
12
12
|
- **plugins**:Plugins 调用以及耗时分析,默认开启。
|
|
13
13
|
- **bundle**:构建产物分析,默认开启。
|
|
14
|
-
- **resolver**:
|
|
14
|
+
- **resolver**:Resolver 分析,默认关闭。
|
|
15
15
|
- **lite**: **(lite 模式即将在 V2 废弃,参考[lite 模式废弃说明](/config/options/options-v2#lite))** lite 模式。lite 模式和普通模式的区别就是不再展示源码信息,只展示打包后的代码信息,这样分析页面上的代码也将是打包后的。默认普通模式。
|
|
16
16
|
|
|
17
|
-
所以,**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin
|
|
17
|
+
所以,**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin 构建时分析**,没有开启 Resolver 分析能力。如需启用 Resolver 分析,可以在 `features` 中显式配置 `resolver`。
|
|
18
18
|
|
|
19
19
|
### 类型
|
|
20
20
|
|
|
@@ -53,14 +53,6 @@ new RsdoctorRspackPlugin({
|
|
|
53
53
|
|
|
54
54
|
:::
|
|
55
55
|
|
|
56
|
-
## RsdoctorWebpackPluginFeatures
|
|
57
|
-
|
|
58
|
-
`features` 类型如下:
|
|
59
|
-
|
|
60
|
-
import Features from '@zh/shared/features.md';
|
|
61
|
-
|
|
62
|
-
<Features />
|
|
63
|
-
|
|
64
56
|
## RsdoctorRspackPluginFeatures
|
|
65
57
|
|
|
66
58
|
`features` 类型如下:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**类型:** `Object`
|
|
4
4
|
|
|
5
|
-
这个 `Options` 是 [
|
|
5
|
+
这个 `Options` 是 [RsdoctorRspackPlugin](#rsdoctorrspackplugin-%E6%8F%92%E4%BB%B6) 的配置项。它包含以下属性值:
|
|
6
6
|
|
|
7
7
|
- [disableClientServer](#disableclientserver)
|
|
8
8
|
- [features](#features)
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
### features
|
|
23
23
|
|
|
24
|
-
- **Type:** [
|
|
24
|
+
- **Type:** [RsdoctorRspackPluginFeatures](#rsdoctorrspackpluginfeatures) | [Array\<keyof RsdoctorRspackPluginFeatures\>](#rsdoctorrspackpluginfeatures)
|
|
25
25
|
- **Optional:** `true`
|
|
26
26
|
- **Default:** `['loader', 'plugins', 'bundle']`
|
|
27
27
|
|
|
@@ -32,10 +32,10 @@ features 属性是用于分析功能开关的,具体的功能项如下:
|
|
|
32
32
|
- **loader**:Loaders 耗时及代码编译变化分析,默认开启。
|
|
33
33
|
- **plugins**:Plugins 调用以及耗时分析,默认开启。
|
|
34
34
|
- **bundle**:构建产物分析,默认开启。
|
|
35
|
-
- **resolver**:
|
|
35
|
+
- **resolver**:Resolver 分析,默认关闭。
|
|
36
36
|
- **lite**: **(废弃,参考:[mode.lite]())** lite 模式。lite 模式和普通模式的区别就是不再缓存源码信息,只缓存打包后的代码信息,这样分析页面上的代码也将是打包后的。默认普通模式。
|
|
37
37
|
|
|
38
|
-
所以,**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin
|
|
38
|
+
所以,**默认配置是开启了 Bundle 分析能力、 Loader 和 Plugin 构建时分析**,没有开启 Resolver 分析能力。如需启用 Resolver 分析,可以在 `features` 中显式配置 `resolver`。
|
|
39
39
|
|
|
40
40
|
:::tip
|
|
41
41
|
**如果出现了 out of memory 的报错,可以尝试:**
|
|
@@ -53,14 +53,6 @@ features 属性是用于分析功能开关的,具体的功能项如下:
|
|
|
53
53
|
- 如果你将 `features` 设置为**数组**类型,该插件**只会开启**你在 `features` 数组中定义的功能。
|
|
54
54
|
- 如果你将 `features` 设置为**简单对象**类型,该插件**只会关闭**你在 `features` 对象中值为 `false` 的功能。
|
|
55
55
|
|
|
56
|
-
#### RsdoctorWebpackPluginFeatures
|
|
57
|
-
|
|
58
|
-
`features` 类型如下:
|
|
59
|
-
|
|
60
|
-
import Features from '@zh/shared/features.md';
|
|
61
|
-
|
|
62
|
-
<Features />
|
|
63
|
-
|
|
64
56
|
#### RsdoctorRspackPluginFeatures
|
|
65
57
|
|
|
66
58
|
`features` 类型如下:
|
|
@@ -34,43 +34,11 @@ new RsdoctorRspackPlugin({
|
|
|
34
34
|
|
|
35
35
|
</Tabs>
|
|
36
36
|
|
|
37
|
-
## RsdoctorWebpackPlugin 插件
|
|
38
|
-
|
|
39
|
-
**RsdoctorWebpackPlugin** 类由 `@rsdoctor/webpack-plugin` 导出,配置项是 [RsdoctorWebpackPluginOptions](#rsdoctorwebpackpluginoptions)。
|
|
40
|
-
|
|
41
|
-
<Tabs>
|
|
42
|
-
|
|
43
|
-
<Tab label="esm">
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
47
|
-
|
|
48
|
-
new RsdoctorWebpackPlugin({
|
|
49
|
-
/** RsdoctorWebpackPluginOptions */
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
</Tab>
|
|
54
|
-
|
|
55
|
-
<Tab label="cjs">
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
59
|
-
|
|
60
|
-
new RsdoctorWebpackPlugin({
|
|
61
|
-
/** RsdoctorWebpackPluginOptions */
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
</Tab>
|
|
66
|
-
|
|
67
|
-
</Tabs>
|
|
68
|
-
|
|
69
37
|
## 配置项
|
|
70
38
|
|
|
71
39
|
**类型:** `Object`
|
|
72
40
|
|
|
73
|
-
这个 `Options` 是 [RsdoctorRspackPlugin](#rsdoctorrspackplugin-%E6%8F%92%E4%BB%B6)
|
|
41
|
+
这个 `Options` 是 [RsdoctorRspackPlugin](#rsdoctorrspackplugin-%E6%8F%92%E4%BB%B6) 的配置项。它包含以下属性值:
|
|
74
42
|
|
|
75
43
|
- [disableClientServer](./disableClientServer.mdx) - **客户端服务控制**:是否在分析完成后不自动打开 Rsdoctor 报告服务。
|
|
76
44
|
- [experiments](./experiments.mdx) - **实验性功能配置**:启用 Rspack 插件的实验性功能,如原生插件性能优化。
|
|
@@ -84,15 +52,15 @@ new RsdoctorWebpackPlugin({
|
|
|
84
52
|
### RsdoctorRspackPluginOptions
|
|
85
53
|
|
|
86
54
|
```ts
|
|
87
|
-
interface
|
|
55
|
+
interface RsdoctorRspackPluginOptions<
|
|
88
56
|
Rules extends LinterType.ExtendRuleData[],
|
|
89
57
|
> {
|
|
90
58
|
linter?: LinterType.Options<Rules, InternalRules>;
|
|
91
59
|
|
|
92
60
|
/** Rsdoctor 功能开关 */
|
|
93
61
|
features?:
|
|
94
|
-
|
|
|
95
|
-
| Array<keyof
|
|
62
|
+
| RsdoctorRspackPluginFeatures
|
|
63
|
+
| Array<keyof RsdoctorRspackPluginFeatures>;
|
|
96
64
|
|
|
97
65
|
/**
|
|
98
66
|
* @deprecated 使用 `output.mode` 代替,如果使用 `lite` 模式,请使用 `output.reportCodeType: 'noCode' or 'noAssetsAndModuleSource'` 代替
|
|
@@ -126,7 +94,3 @@ interface RsdoctorRspackPluginExperiments {
|
|
|
126
94
|
enableNativePlugin?: boolean;
|
|
127
95
|
}
|
|
128
96
|
```
|
|
129
|
-
|
|
130
|
-
### RsdoctorWebpackPluginOptions
|
|
131
|
-
|
|
132
|
-
RsdoctorWebpackPlugin 同 `Omit<RsdoctorRspackPluginOptions, 'experiments'>` 类型。
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### manifest.json
|
|
6
6
|
|
|
7
|
-
当你的项目集成 **Rsdoctor**
|
|
7
|
+
当你的项目集成 **Rsdoctor** 提供的插件之后,Rsdoctor 会将项目**构建相关的数据信息**写入到一个本地的 JSON 文件中:
|
|
8
8
|
|
|
9
9
|
- 其**文件名为 `manifest.json`**
|
|
10
10
|
- 该文件的输出**路径为 `项目产物目录/.rsdoctor/manifest.json`**
|
|
@@ -69,7 +69,7 @@ export default {
|
|
|
69
69
|
|
|
70
70
|
### 1. 安装
|
|
71
71
|
|
|
72
|
-
编写自定义规则时,除了安装基本的 @rsdoctor/rspack-plugin
|
|
72
|
+
编写自定义规则时,除了安装基本的 @rsdoctor/rspack-plugin 依赖,还需要安装 @rsdoctor/core 并使用 @rsdoctor/core/rules 中的 defineRule 函数来定义统一的 Rsdoctor 规则。
|
|
73
73
|
|
|
74
74
|
import { PackageManagerTabs } from '@theme';
|
|
75
75
|
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
我们提供了 `@rsdoctor/cli` 让你可以在本地通过 CLI 程序来使用 Rsdoctor 提供的功能
|
|
4
4
|
|
|
5
5
|
:::tip
|
|
6
|
-
`@rsdoctor/
|
|
6
|
+
`@rsdoctor/rspack-plugin` 与 `@rsdoctor/cli` 要保持同一个 major 和 minor 版本。
|
|
7
7
|
:::
|
|
8
8
|
|
|
9
9
|
## 安装 @rsdoctor/cli
|
|
10
10
|
|
|
11
11
|
:::tip
|
|
12
12
|
|
|
13
|
-
- @rsdoctor/cli & @rsdoctor/
|
|
13
|
+
- @rsdoctor/cli & @rsdoctor/rspack-plugin >= 0.1.2。
|
|
14
14
|
- 可以使用非安装方式,使用 `npx @rsdoctor/cli <command> [options]`。
|
|
15
15
|
|
|
16
16
|
:::
|
|
@@ -27,27 +27,6 @@ module.exports = {
|
|
|
27
27
|
|
|
28
28
|
Rsbuild 内置了对 Rsdoctor 的支持,不需要手动注册插件。详见 [Rsbuild - 使用 Rsdoctor](https://rsbuild.rs/zh/guide/debug/rsdoctor)。
|
|
29
29
|
|
|
30
|
-
### Webpack 项目
|
|
31
|
-
|
|
32
|
-
在 `webpack.config.js` 的 [plugins](https://webpack.js.org/configuration/plugins/#plugins) 中初始化 RsdoctorWebpackPlugin 插件,参考:
|
|
33
|
-
|
|
34
|
-
```js title="webpack.config.js"
|
|
35
|
-
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
// ...
|
|
39
|
-
plugins: [
|
|
40
|
-
// 仅在 RSDOCTOR 为 true 时注册插件,因为插件会增加构建耗时
|
|
41
|
-
process.env.RSDOCTOR &&
|
|
42
|
-
new RsdoctorWebpackPlugin({
|
|
43
|
-
// 插件选项
|
|
44
|
-
}),
|
|
45
|
-
].filter(Boolean),
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
- **Options:** 插件提供了一些配置项,请参考 [Options](../../config/options/options)。
|
|
50
|
-
|
|
51
30
|
### Modern.js 项目
|
|
52
31
|
|
|
53
32
|
在 `modern.config.ts` 的 [tools.bundlerChain](https://modernjs.dev/configure/app/tools/rspack) 中初始化插件,参考:
|
|
@@ -74,20 +53,11 @@ export default {
|
|
|
74
53
|
|
|
75
54
|
- **Options:** 插件提供了一些配置项,请参考 [Options](../../config/options/options)。
|
|
76
55
|
|
|
77
|
-
:::tip
|
|
78
|
-
对于使用 Modern.js webpack 模式的项目,请使用 [tools.webpack](https://modernjs.dev/configure/app/tools/webpack) 注册 `RsdoctorWebpackPlugin` 插件。
|
|
79
|
-
:::
|
|
80
|
-
|
|
81
56
|
### Next.js 项目
|
|
82
57
|
|
|
83
58
|
#### 第一步:注册 Rsdoctor 插件
|
|
84
59
|
|
|
85
|
-
在 `next.config.ts` 的 [Rspack 配置](https://rspack.rs/guide/tech/next)
|
|
86
|
-
|
|
87
|
-
import { Tab, Tabs } from '@rspress/core/theme';
|
|
88
|
-
|
|
89
|
-
<Tabs>
|
|
90
|
-
<Tab label="Rspack">
|
|
60
|
+
在 `next.config.ts` 的 [Rspack 配置](https://rspack.rs/guide/tech/next) 中初始化 [RsdoctorRspackPlugin](#rspack-%E9%A1%B9%E7%9B%AE) 插件。
|
|
91
61
|
|
|
92
62
|
```ts title="next.config.ts"
|
|
93
63
|
import type { NextConfig } from 'next';
|
|
@@ -119,43 +89,6 @@ const nextConfig: NextConfig = {
|
|
|
119
89
|
export default nextConfig;
|
|
120
90
|
```
|
|
121
91
|
|
|
122
|
-
</Tab>
|
|
123
|
-
|
|
124
|
-
<Tab label="webpack">
|
|
125
|
-
|
|
126
|
-
```ts title="next.config.ts"
|
|
127
|
-
import type { NextConfig } from 'next';
|
|
128
|
-
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
129
|
-
|
|
130
|
-
const nextConfig: NextConfig = {
|
|
131
|
-
/* config options here */
|
|
132
|
-
webpack: (config) => {
|
|
133
|
-
if (config.name === 'client') {
|
|
134
|
-
config.plugins.push(
|
|
135
|
-
new RsdoctorWebpackPlugin({
|
|
136
|
-
disableClientServer: true,
|
|
137
|
-
}),
|
|
138
|
-
);
|
|
139
|
-
} else if (config.name === 'server') {
|
|
140
|
-
config.plugins.push(
|
|
141
|
-
new RsdoctorWebpackPlugin({
|
|
142
|
-
disableClientServer: true,
|
|
143
|
-
output: {
|
|
144
|
-
reportDir: './.next/server',
|
|
145
|
-
},
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
return config;
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default nextConfig;
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
</Tab>
|
|
157
|
-
</Tabs>
|
|
158
|
-
|
|
159
92
|
- **Options:** 插件提供了一些配置项,请参考 [Options](../../config/options/options)。
|
|
160
93
|
|
|
161
94
|
#### 第二步:执行构建
|
|
@@ -192,7 +125,7 @@ rsdoctor analyze --profile .next/server/chunks/.rsdoctor/manifest.json
|
|
|
192
125
|
|
|
193
126
|
### Vue 项目
|
|
194
127
|
|
|
195
|
-
在配置文件中初始化 `@rsdoctor/
|
|
128
|
+
在配置文件中初始化 `@rsdoctor/rspack-plugin` 插件,以下是使用 rsbuild 项目作为示例:
|
|
196
129
|
|
|
197
130
|
```ts title="rsbuild.config.ts"
|
|
198
131
|
import { defineConfig } from '@rsbuild/core';
|
|
@@ -12,16 +12,6 @@ import { PackageManagerTabs } from '@theme';
|
|
|
12
12
|
|
|
13
13
|
<PackageManagerTabs command="add @rsdoctor/rspack-plugin -D" />
|
|
14
14
|
|
|
15
|
-
### Webpack 项目
|
|
16
|
-
|
|
17
|
-
:::tip
|
|
18
|
-
Rsdoctor 仅支持 webpack >= 5。
|
|
19
|
-
:::
|
|
20
|
-
|
|
21
|
-
基于 webpack 的项目,安装以下依赖:
|
|
22
|
-
|
|
23
|
-
<PackageManagerTabs command="add @rsdoctor/webpack-plugin -D" />
|
|
24
|
-
|
|
25
15
|
---
|
|
26
16
|
|
|
27
17
|
import QuickStartShared from './quick-start-shared.mdx';
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
:::tip
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- Resolver 分析能力默认关闭,如需开启,可以在 `features` 数组中添加 `resolver`,如下示例。[features 配置](../../config/options/options)。
|
|
5
|
+
Rspack 支持通过 `features` 开启 Resolver 分析能力;该能力默认关闭,如需启用,可以在 `features` 数组中添加 `resolver`,如下示例。[features 配置](../../config/options/options)。
|
|
8
6
|
|
|
9
7
|
```js
|
|
10
|
-
new
|
|
8
|
+
new RsdoctorRspackPlugin({
|
|
11
9
|
features: [
|
|
12
10
|
'resolver',
|
|
13
11
|
// ...other features
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
```ts
|
|
2
2
|
interface RsdoctorRspackPluginFeatures {
|
|
3
3
|
/**
|
|
4
|
-
* turn off it if you need not to analyze the executions of
|
|
4
|
+
* turn off it if you need not to analyze the executions of Rspack loaders.
|
|
5
5
|
* @default true
|
|
6
6
|
*/
|
|
7
7
|
loader?: boolean;
|
|
8
8
|
/**
|
|
9
|
-
* turn off it if you need not to analyze the executions of
|
|
9
|
+
* turn off it if you need not to analyze the executions of Rspack plugins.
|
|
10
10
|
* @default true
|
|
11
11
|
*/
|
|
12
12
|
plugins?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* turn on it if you need to analyze resolver executions.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
resolver?: boolean;
|
|
13
18
|
/**
|
|
14
19
|
* turn off it if you need not to analyze the output bundle.
|
|
15
20
|
* @default true
|
|
16
21
|
*/
|
|
17
22
|
bundle?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* turn on it if you need to analyze the tree shaking result.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
treeShaking?: boolean;
|
|
18
28
|
/**
|
|
19
29
|
* turn on it if you just use lite mode. This mode do not have source codes.
|
|
20
30
|
* @default false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/docs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -19,29 +19,29 @@
|
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@rspress/plugin-algolia": "2.0.
|
|
23
|
-
"@rspress/plugin-client-redirects": "2.0.
|
|
22
|
+
"@rspress/plugin-algolia": "2.0.12",
|
|
23
|
+
"@rspress/plugin-client-redirects": "2.0.12",
|
|
24
24
|
"@rspress/plugin-rss": "2.0.5",
|
|
25
|
-
"@types/node": "^
|
|
26
|
-
"@types/react": "^
|
|
27
|
-
"@types/react-dom": "^
|
|
28
|
-
"cross-env": "^
|
|
29
|
-
"react": "
|
|
30
|
-
"react-dom": "
|
|
31
|
-
"react-render-to-markdown": "^
|
|
25
|
+
"@types/node": "^24.12.3",
|
|
26
|
+
"@types/react": "^19.2.15",
|
|
27
|
+
"@types/react-dom": "^19.2.3",
|
|
28
|
+
"cross-env": "^10.1.0",
|
|
29
|
+
"react": "19.2.6",
|
|
30
|
+
"react-dom": "19.2.6",
|
|
31
|
+
"react-render-to-markdown": "^19.0.1",
|
|
32
32
|
"rsbuild-plugin-google-analytics": "^1.0.5",
|
|
33
33
|
"rsbuild-plugin-open-graph": "^1.1.2",
|
|
34
34
|
"rspress-plugin-font-open-sans": "^1.0.3",
|
|
35
35
|
"rspress-plugin-sitemap": "^1.2.1",
|
|
36
|
-
"typescript": "^
|
|
36
|
+
"typescript": "^6.0.3",
|
|
37
37
|
"@rsbuild/plugin-sass": "^1.5.2",
|
|
38
|
-
"@rsdoctor/types": "
|
|
38
|
+
"@rsdoctor/types": "2.0.0-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@rstack-dev/doc-ui": "1.
|
|
41
|
+
"@rstack-dev/doc-ui": "1.13.3",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"react-markdown": "^9.1.0",
|
|
44
|
-
"@rspress/core": "2.0.
|
|
44
|
+
"@rspress/core": "2.0.12"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"dev": "cross-env RSPRESS_PERSIST_CACHE=false rspress dev",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
```ts
|
|
2
|
-
interface RsdoctorWebpackPluginFeatures {
|
|
3
|
-
/**
|
|
4
|
-
* turn off it if you need not to analyze the executions of webpack loaders.
|
|
5
|
-
* @default true
|
|
6
|
-
*/
|
|
7
|
-
loader?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* turn off it if you need not to analyze the executions of webpack plugins.
|
|
10
|
-
* @default true
|
|
11
|
-
*/
|
|
12
|
-
plugins?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* turn off it if you need not to analyze the executions of resolver.
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
resolver?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* turn off it if you need not to analyze the output bundle.
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
bundle?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* turn on it if you just use lite mode. This mode do not have source codes.
|
|
25
|
-
* @default false
|
|
26
|
-
* @deprecated
|
|
27
|
-
*/
|
|
28
|
-
lite?: boolean;
|
|
29
|
-
}
|
|
30
|
-
```
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
```ts
|
|
2
|
-
interface RsdoctorWebpackPluginFeatures {
|
|
3
|
-
/**
|
|
4
|
-
* turn off it if you need not to analyze the executions of webpack loaders.
|
|
5
|
-
* @default true
|
|
6
|
-
*/
|
|
7
|
-
loader?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* turn off it if you need not to analyze the executions of webpack plugins.
|
|
10
|
-
* @default true
|
|
11
|
-
*/
|
|
12
|
-
plugins?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* turn off it if you need not to analyze the executions of resolver.
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
resolver?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* turn off it if you need not to analyze the output bundle.
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
bundle?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* turn on it if you just use lite mode. This mode do not have source codes.
|
|
25
|
-
* @default false
|
|
26
|
-
* @deprecated
|
|
27
|
-
*/
|
|
28
|
-
lite?: boolean;
|
|
29
|
-
}
|
|
30
|
-
```
|