@rsdoctor/docs 1.0.0-beta.0 → 1.0.0-beta.2
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/blog/release/release-note-0_3.mdx +2 -2
- package/docs/en/config/options/options.mdx +55 -33
- package/docs/en/guide/_meta.json +2 -2
- package/docs/en/guide/more/faq.mdx +4 -4
- package/docs/en/guide/rules/_meta.json +1 -0
- package/docs/en/guide/rules/rules.mdx +281 -0
- package/docs/en/guide/usage/bundle-alerts.mdx +9 -40
- package/docs/en/guide/usage/compile-alerts.mdx +6 -6
- package/docs/en/guide/usage/rule-config.mdx +15 -91
- package/docs/en/index.md +1 -35
- package/docs/public/bundle-alerts.png +0 -0
- package/docs/public/cross-chunks-package.png +0 -0
- package/docs/zh/blog/release/release-note-0_3.mdx +2 -2
- package/docs/zh/config/options/options.mdx +48 -26
- package/docs/zh/guide/_meta.json +2 -2
- package/docs/zh/guide/more/faq.mdx +4 -4
- package/docs/zh/guide/rules/_meta.json +1 -0
- package/docs/zh/guide/rules/rules.mdx +281 -0
- package/docs/zh/guide/usage/bundle-alerts.mdx +8 -40
- package/docs/zh/guide/usage/compile-alerts.mdx +2 -2
- package/docs/zh/guide/usage/resolver.mdx +1 -1
- package/docs/zh/guide/usage/rule-config.mdx +11 -88
- package/docs/zh/index.md +1 -35
- package/package.json +5 -5
- package/docs/en/guide/custom/_meta.json +0 -1
- package/docs/zh/guide/custom/_meta.json +0 -1
- /package/docs/en/guide/{custom → rules}/rule-custom.mdx +0 -0
- /package/docs/en/guide/{custom → rules}/upload-data.mdx +0 -0
- /package/docs/zh/guide/{custom → rules}/rule-custom.mdx +0 -0
- /package/docs/zh/guide/{custom → rules}/upload-data.mdx +0 -0
|
@@ -13,9 +13,9 @@ The new features of Rsdoctor v0.3 include:
|
|
|
13
13
|
Considering that users may have their own specific rule definition requirements, Rsdoctor provides an external interface for users to customize their own rule checks in addition to the internal rules already available.
|
|
14
14
|
External extension interfaces need to be configured on the Rsdoctor plugin through the `extends` field, and their configurations are also placed in the `rules` field.
|
|
15
15
|
|
|
16
|
-
For more details, please refer to: [Custom Extension Rules](/guide/
|
|
16
|
+
For more details, please refer to: [Custom Extension Rules](/guide/rules/rule-custom)
|
|
17
17
|
|
|
18
|
-
Additionally, the use of custom rules can also be applied for user data collection and reporting. [Data Reporting](/guide/
|
|
18
|
+
Additionally, the use of custom rules can also be applied for user data collection and reporting. [Data Reporting](/guide/rules/upload-data)
|
|
19
19
|
|
|
20
20
|
- Example:
|
|
21
21
|
|
|
@@ -77,6 +77,28 @@ This is the options for the [RsdoctorWebpackPlugin](#rsdoctorwebpackplugin) and
|
|
|
77
77
|
- [disableClientServer](#disableclientserver)
|
|
78
78
|
- [features](#features)
|
|
79
79
|
|
|
80
|
+
### brief
|
|
81
|
+
|
|
82
|
+
<Badge text="Version: 0.4.0" type="warning" />
|
|
83
|
+
|
|
84
|
+
- **Type:** [BriefType](#brieftype)
|
|
85
|
+
- **Optional:** `true`
|
|
86
|
+
- **Default:** undefined
|
|
87
|
+
|
|
88
|
+
More configurations for Brief mode are as follows:
|
|
89
|
+
|
|
90
|
+
- **reportHtmlName:** Configures the name of the HTML report for Brief mode. The default value is `report-rsdoctor.html`.
|
|
91
|
+
- **writeDataJson:** By default, in Brief mode, the analysis data is injected into the HTML file, so no additional build analysis data is generated. If you want to generate additional local data, you need to configure `writeDataJson: true`.
|
|
92
|
+
|
|
93
|
+
#### briefType
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
interface BriefConfig {
|
|
97
|
+
reportHtmlName?: string | undefined;
|
|
98
|
+
writeDataJson: boolean;
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
80
102
|
### disableClientServer
|
|
81
103
|
|
|
82
104
|
- **Type:** `boolean`
|
|
@@ -151,9 +173,11 @@ import ModeIntro from '@en/shared/mode-intro.md';
|
|
|
151
173
|
|
|
152
174
|
<ModeIntro />
|
|
153
175
|
|
|
154
|
-
###
|
|
176
|
+
### output
|
|
155
177
|
|
|
156
|
-
<Badge text="Version
|
|
178
|
+
<Badge text="Version 1.0.0" type="warning" />
|
|
179
|
+
|
|
180
|
+
#### reportDir
|
|
157
181
|
|
|
158
182
|
- **Type:** string
|
|
159
183
|
- **Optional:** `true`
|
|
@@ -161,29 +185,7 @@ import ModeIntro from '@en/shared/mode-intro.md';
|
|
|
161
185
|
|
|
162
186
|
The output directory for Rsdoctor reports. By default, it is the build output directory.
|
|
163
187
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<Badge text="Version: 0.4.0" type="warning" />
|
|
167
|
-
|
|
168
|
-
- **Type:** [BriefType](#brieftype)
|
|
169
|
-
- **Optional:** `true`
|
|
170
|
-
- **Default:** undefined
|
|
171
|
-
|
|
172
|
-
More configurations for Brief mode are as follows:
|
|
173
|
-
|
|
174
|
-
- **reportHtmlName:** Configures the name of the HTML report for Brief mode. The default value is `report-rsdoctor.html`.
|
|
175
|
-
- **writeDataJson:** By default, in Brief mode, the analysis data is injected into the HTML file, so no additional build analysis data is generated. If you want to generate additional local data, you need to configure `writeDataJson: true`.
|
|
176
|
-
|
|
177
|
-
#### briefType
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
interface BriefConfig {
|
|
181
|
-
reportHtmlName?: string | undefined;
|
|
182
|
-
writeDataJson: boolean;
|
|
183
|
-
}
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### reportCodeType
|
|
188
|
+
#### reportCodeType
|
|
187
189
|
|
|
188
190
|
- Type: `{ noModuleSource?: boolean; noAssetsAndModuleSource?: boolean }`
|
|
189
191
|
- Optional: true
|
|
@@ -206,6 +208,34 @@ new RsdoctorRspackPlugin({
|
|
|
206
208
|
}),
|
|
207
209
|
```
|
|
208
210
|
|
|
211
|
+
#### compressData
|
|
212
|
+
|
|
213
|
+
- **Type:** boolean
|
|
214
|
+
- **Optional:** `true`
|
|
215
|
+
- **Default:** true
|
|
216
|
+
|
|
217
|
+
compressData is used to configure whether to compress the analysis data under [outputDir]/.rsdoctor.
|
|
218
|
+
|
|
219
|
+
### port
|
|
220
|
+
|
|
221
|
+
- **Type:** `number`
|
|
222
|
+
- **Optional:** `true`
|
|
223
|
+
- **Default:** `random(3000, 8999)`
|
|
224
|
+
|
|
225
|
+
Configure the port for the Rsdoctor server.
|
|
226
|
+
|
|
227
|
+
### ~~reportCodeType [**Deprecated**]~~
|
|
228
|
+
|
|
229
|
+
<Badge text="Deprecated" type="warning" />
|
|
230
|
+
|
|
231
|
+
Please use [output.reportCodeType](#reportcodetype)
|
|
232
|
+
|
|
233
|
+
### ~~reportDir [**Deprecated**]~~
|
|
234
|
+
|
|
235
|
+
<Badge text="Deprecated" type="warning" />
|
|
236
|
+
|
|
237
|
+
Please use [output.reportDir](#reportDir)
|
|
238
|
+
|
|
209
239
|
### supports
|
|
210
240
|
|
|
211
241
|
- **Type:** [Supports Types](#supports-types)
|
|
@@ -282,11 +312,3 @@ Whether to enable the ability to generate tile graphs, which affects whether the
|
|
|
282
312
|
width="500px"
|
|
283
313
|
style={{ margin: 'auto' }}
|
|
284
314
|
/>
|
|
285
|
-
|
|
286
|
-
### port
|
|
287
|
-
|
|
288
|
-
- **Type:** `number`
|
|
289
|
-
- **Optional:** `true`
|
|
290
|
-
- **Default:** `random(3000, 8999)`
|
|
291
|
-
|
|
292
|
-
Configure the port for the Rsdoctor server.
|
package/docs/en/guide/_meta.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
When we **only need** the [bundle size analysis](../usage/bundle-size) feature of Rsdoctor, we can configure the corresponding [Features](/config/options/options) option when integrating the Rsdoctor plugin. Refer to the code snippet below:
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import {
|
|
8
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
9
9
|
|
|
10
|
-
new
|
|
10
|
+
new RsdoctorRspackPlugin({
|
|
11
11
|
features: ['bundle'], // Represents enabling only the bundle size analysis feature
|
|
12
12
|
});
|
|
13
13
|
```
|
|
@@ -44,13 +44,13 @@ You can add the `lite` field to the `features` array to use the lite mode. Addit
|
|
|
44
44
|
The following example enables the lite mode, build-time analysis, and bundle analysis:
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
|
-
const {
|
|
47
|
+
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
|
|
48
48
|
|
|
49
49
|
// adding the plugin to your configuration
|
|
50
50
|
module.exports = {
|
|
51
51
|
// ...
|
|
52
52
|
plugins: [
|
|
53
|
-
new
|
|
53
|
+
new RsdoctorRspackPlugin({
|
|
54
54
|
disableClientServer: false,
|
|
55
55
|
features: ['lite', 'loader', 'plugins', 'bundle'],
|
|
56
56
|
}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["rules", "rule-custom", "upload-data"]
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# Built-in rules
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
:::tip
|
|
6
|
+
|
|
7
|
+
Please refer to the [Linter Type](#linter-type) in this document for the type definition of `linter`.
|
|
8
|
+
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
### [E1001] Duplicate Packages
|
|
12
|
+
|
|
13
|
+
#### Rule Details
|
|
14
|
+
|
|
15
|
+
- The `Duplicate Packages` card displays the number of duplicate third-party packages in the project. Clicking the image allows you to view the specific details of the duplicate third-party packages. Note: The third-party packages referred to here are all bundled third-party packages.
|
|
16
|
+
|
|
17
|
+
<div style={{ display: 'flex' }}>
|
|
18
|
+
<img
|
|
19
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-1.png"
|
|
20
|
+
height="200px"
|
|
21
|
+
width="260px"
|
|
22
|
+
style={{ margin: 'auto' }}
|
|
23
|
+
/>
|
|
24
|
+
<img
|
|
25
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-2.png"
|
|
26
|
+
height="300px"
|
|
27
|
+
width="340px"
|
|
28
|
+
style={{ margin: 'auto' }}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
- Duplicate Package Warning Card
|
|
33
|
+
|
|
34
|
+
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alerts.png" />
|
|
35
|
+
|
|
36
|
+
- Clicking the icon to expand the duplicate package details allows you to see: the name, version, size, and reference files of the duplicate package.
|
|
37
|
+
|
|
38
|
+
- Clicking the **「Show Relations」** on the far right can view the specific reference chain and the corresponding reference file code position of this third-party package.
|
|
39
|
+
|
|
40
|
+
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-relations.png" />
|
|
41
|
+
|
|
42
|
+
- Clicking the **「!(exclamation mark)」** icon on the far right can view the specific explanation of the rule for the duplicate third-party package.
|
|
43
|
+
|
|
44
|
+
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-rule.png" />
|
|
45
|
+
|
|
46
|
+
#### Configuration
|
|
47
|
+
|
|
48
|
+
- Configuration Example:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
plugin: [
|
|
55
|
+
new RsdoctorRspackPlugin({
|
|
56
|
+
linter: {
|
|
57
|
+
level: 'Error',
|
|
58
|
+
extends: [],
|
|
59
|
+
rules: {
|
|
60
|
+
'duplicate-package': [
|
|
61
|
+
'Error',
|
|
62
|
+
{
|
|
63
|
+
checkVersion: 'minor',
|
|
64
|
+
ignore: ['chalk', '@babel/runtime'],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
##### Type
|
|
75
|
+
|
|
76
|
+
- **ignore**: Configures the packages to be ignored.
|
|
77
|
+
- **checkVersion**: Refers to the maximum version level to be checked, for example: if set to `minor`, then the duplicate package will no longer check the `major` level differences. **Default is `major`**.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
interface Config {
|
|
81
|
+
checkVersion: keyof typeof CheckVersion;
|
|
82
|
+
ignore: string[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
enum CheckVersion {
|
|
86
|
+
null = 0,
|
|
87
|
+
prerelease = 0x1,
|
|
88
|
+
prepatch = 0x10,
|
|
89
|
+
patch = 0x100,
|
|
90
|
+
preminor = 0x1000,
|
|
91
|
+
minor = 0x10000,
|
|
92
|
+
premajor = 0x100000,
|
|
93
|
+
major = 0x1000000,
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Duplicate Package Optimization Problem
|
|
98
|
+
|
|
99
|
+
Please refer to the [Duplicate Package Optimization Solution](../../blog/topic/duplicate-pkg-problem).
|
|
100
|
+
|
|
101
|
+
Clicking 「**More**」 can view the corresponding rule explanation.
|
|
102
|
+
|
|
103
|
+
### [E1002] Cross Chunks Package
|
|
104
|
+
|
|
105
|
+
The cross chunks duplicate package rule can scan **duplicate packages in different `chunks`**. These duplicate packages may also lead to redundant code in the build artifacts, depending on the business logic and the size of the redundant code.
|
|
106
|
+
|
|
107
|
+
- Display
|
|
108
|
+
- Module refers to the module that is repeatedly packaged in multiple chunks.
|
|
109
|
+
- Chunks are the build artifacts that are repeatedly packaged.
|
|
110
|
+
|
|
111
|
+
<img src="/cross-chunks-package.png" />
|
|
112
|
+
|
|
113
|
+
#### Solution
|
|
114
|
+
|
|
115
|
+
Please refer to [[E1002] Cross Chunks Packages](../more/rules)
|
|
116
|
+
|
|
117
|
+
### [E1003] Loader Performance Optimization
|
|
118
|
+
|
|
119
|
+
This module allows you to visually see some warning information about our project's compilation, which can help us further optimize the project's compilation performance.
|
|
120
|
+
|
|
121
|
+
#### Solution
|
|
122
|
+
|
|
123
|
+
Please refer to [[E1003] Loader Performance Optimization](../more/rules)
|
|
124
|
+
|
|
125
|
+
#### Configuration Type
|
|
126
|
+
|
|
127
|
+
- **ignore**: Can include strings or regular expressions, used to specify the loaders to be ignored.
|
|
128
|
+
- **threshold**: Represents the total time threshold for the loader, in milliseconds. If the loader's execution time exceeds this threshold, it may trigger warnings or errors. The default value is 5000 milliseconds.
|
|
129
|
+
- **extensions**: Strings or regular expressions, used to specify the file extensions that need to be matched in rule checks. By default, it includes common file types such as js, css, jpg, jpeg, png, gif, webp, and svg.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
interface Config {
|
|
133
|
+
/**
|
|
134
|
+
* loaders which should be ignore.
|
|
135
|
+
*/
|
|
136
|
+
ignore: (string | RegExp)[];
|
|
137
|
+
/**
|
|
138
|
+
* threshold which the loader total costs.
|
|
139
|
+
* @unit millisecond
|
|
140
|
+
* @default 5000
|
|
141
|
+
*/
|
|
142
|
+
threshold: number;
|
|
143
|
+
/**
|
|
144
|
+
* the file extensions which will be match in rule check.
|
|
145
|
+
* @default ["js", "css", "jpg", "jpeg", "png", "gif", "webp", "svg"]
|
|
146
|
+
*/
|
|
147
|
+
extensions: (string | RegExp)[];
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### [E1004] ECMA Version Check
|
|
152
|
+
|
|
153
|
+
This rule is used to detect incompatible advanced syntax. When scanning the rule, the configuration of `browserslist` is prioritized; if `browserslist` is not configured, manual detection is required, as shown below:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
157
|
+
|
|
158
|
+
export default {
|
|
159
|
+
plugin: [
|
|
160
|
+
new RsdoctorRspackPlugin({
|
|
161
|
+
linter: {
|
|
162
|
+
rules: {
|
|
163
|
+
'ecma-version-check': [
|
|
164
|
+
'Warn',
|
|
165
|
+
{
|
|
166
|
+
ecmaVersion: 2015,
|
|
167
|
+
// targets: ["chrome >= 53"],
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### Type Definitions
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
type CheckSyntaxOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* The target browser range of the project.
|
|
183
|
+
* Its value is a standard browserslist array.
|
|
184
|
+
*/
|
|
185
|
+
targets?: string[];
|
|
186
|
+
/**
|
|
187
|
+
* Used to exclude a portion of source files during detection.
|
|
188
|
+
* You can pass in one or more regular expressions to match the paths of source files.
|
|
189
|
+
*/
|
|
190
|
+
exclude?: CheckSyntaxExclude;
|
|
191
|
+
/**
|
|
192
|
+
* Used to exclude files by output path before detection.
|
|
193
|
+
* You can pass in one or more regular expressions to match the paths of source files.
|
|
194
|
+
*/
|
|
195
|
+
excludeOutput?: CheckSyntaxExclude;
|
|
196
|
+
/**
|
|
197
|
+
* The minimum ECMAScript syntax version that can be used in the build artifact.
|
|
198
|
+
* The priority of `ecmaVersion` is higher than `targets`.
|
|
199
|
+
*/
|
|
200
|
+
ecmaVersion?: EcmaVersion;
|
|
201
|
+
/**
|
|
202
|
+
* Used to ignore specified syntax error messages after detection.
|
|
203
|
+
* You can pass in one or more error message types to ignore.
|
|
204
|
+
*/
|
|
205
|
+
excludeErrorLogs?: SyntaxErrorKey[];
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
For more `ECMA Version Check` configuration options, please refer to [ECMA Version Check Options](https://github.com/rspack-contrib/rsbuild-plugin-check-syntax?tab=readme-ov-file#options)
|
|
210
|
+
|
|
211
|
+
### [E1005] Default Import Check
|
|
212
|
+
|
|
213
|
+
Typically, Rspack automatically supports different types of modules, but in some cases, compatibility operations may fail. For example, when using `Default Import` to import a `cjs` module, if the module does not have a compatible statement (such as `exports.default`), issues may arise.
|
|
214
|
+
|
|
215
|
+
#### Solution
|
|
216
|
+
|
|
217
|
+
Please refer to [[E1005] Default Import Check](../more/rules)
|
|
218
|
+
|
|
219
|
+
#### Configuration
|
|
220
|
+
|
|
221
|
+
- **ignore**:Configure to ignore some imported files.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
interface Config {
|
|
225
|
+
/** Packages that need to be ignored */
|
|
226
|
+
ignore: string[];
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Linter Type
|
|
231
|
+
|
|
232
|
+
- The type definition for the `linter` field is as follows:
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
/** Linter options */
|
|
236
|
+
interface Options {
|
|
237
|
+
rules?: RulesMap;
|
|
238
|
+
level?: SeverityString;
|
|
239
|
+
extends?: ExtendRuleData[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Linting level
|
|
244
|
+
* - `'Warn'` runs only rules categorized as `'Warn'`
|
|
245
|
+
* - `'Error'` runs all rules
|
|
246
|
+
*/
|
|
247
|
+
type SeverityString = 'Warn' | 'Error';
|
|
248
|
+
|
|
249
|
+
/** Rule level */
|
|
250
|
+
type SeverityInput = SeverityString | 'off' | 'on';
|
|
251
|
+
|
|
252
|
+
/** Rule configuration */
|
|
253
|
+
type RulesMap = Record<string, RuleConfigItem>;
|
|
254
|
+
|
|
255
|
+
/** Single rule configuration */
|
|
256
|
+
type RuleConfigItem =
|
|
257
|
+
// Only error level, this level has higher priority than the rule's own configuration
|
|
258
|
+
| SeverityInput
|
|
259
|
+
// In the case of an array, the first item is the error level, and the second item is the rule configuration
|
|
260
|
+
| [SeverityInput, unknown];
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
If you want to **disable a rule**, you can set `SeverityInput` to `off`, as shown in the following example:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
267
|
+
|
|
268
|
+
export default {
|
|
269
|
+
plugin: [
|
|
270
|
+
new RsdoctorRspackPlugin({
|
|
271
|
+
linter: {
|
|
272
|
+
level: 'Error',
|
|
273
|
+
extends: [],
|
|
274
|
+
rules: {
|
|
275
|
+
'duplicate-package': 'off',
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
}),
|
|
279
|
+
],
|
|
280
|
+
};
|
|
281
|
+
```
|
|
@@ -1,48 +1,17 @@
|
|
|
1
|
-
# Bundle
|
|
1
|
+
# Bundle Alerts
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The `Alerts` section in the `Overall` page is used to display the results of "Build Rules" and "Compilation Rules", as shown in the image below. In addition to being displayed on the page, the rules will also be displayed in the terminal log.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<img src="/bundle-alerts.png" />
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<img
|
|
11
|
-
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-1.png"
|
|
12
|
-
width="360px"
|
|
13
|
-
style={{ margin: 'auto' }}
|
|
14
|
-
/>
|
|
15
|
-
<img
|
|
16
|
-
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-2.png"
|
|
17
|
-
width="360px"
|
|
18
|
-
style={{ margin: 'auto' }}
|
|
19
|
-
/>
|
|
20
|
-
</div>
|
|
9
|
+
You can check the built-in rules for bundle alerts below to understand the details of each rule.
|
|
21
10
|
|
|
22
|
-
-
|
|
11
|
+
### Built-in Rules
|
|
23
12
|
|
|
24
|
-
|
|
13
|
+
1. [[E1001] Duplicate Packages](../../guide/rules/rules#e1001-duplicate-packages)
|
|
14
|
+
2. [[E1002] Cross Chunks Package](../../guide/rules/rules#e1002-cross-chunks-package)
|
|
15
|
+
3. [[E1004] ECMA Version Check](../../guide/rules/rules#e1004-ecma-version-check)
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- Click on the rightmost **"Show Relations"** to view the specific reference chain and corresponding reference file code location for this third-party package.
|
|
29
|
-
|
|
30
|
-
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-relations.png" />
|
|
31
|
-
|
|
32
|
-
- Click on the rightmost **"!"** icon to view the specific explanation of the rule for the duplicate third-party package.
|
|
33
|
-
|
|
34
|
-
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alters-rule.png" />
|
|
35
|
-
|
|
36
|
-
### Duplicate package optimization
|
|
37
|
-
|
|
38
|
-
Please check [Duplicate Package Optimization](../../blog/topic/duplicate-pkg-problem).
|
|
39
|
-
|
|
40
|
-
### ECMA version check
|
|
41
|
-
|
|
42
|
-
In the bundle alerts, the ECMA version of the bundle is checked, as shown in the following image:
|
|
43
|
-
|
|
44
|
-
{' '}
|
|
45
|
-
|
|
46
|
-
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alerts-ecma.png" />
|
|
47
|
-
|
|
48
|
-
Click on "**More**" to view the corresponding rule explanation.
|
|
17
|
+
For more details, please refer to the [Built-in Rules](../../guide/rules/rules).
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Compile Alerts
|
|
2
2
|
|
|
3
|
-
We have
|
|
3
|
+
We have integrated some capabilities based on compilation data detection. If the current compilation result contains data that hits the rules we define, the `Compile Alerts` module will appear at the bottom of the **Rsdoctor** main interface, as shown in the image below:
|
|
4
4
|
|
|
5
5
|
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/compile/compile-alerts.png" />
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This module allows us to visually see some warning information about our project's compilation, which can help us further optimize the project's compilation performance.
|
|
8
8
|
|
|
9
9
|
## Rules
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The current compilation rules include:
|
|
12
12
|
|
|
13
13
|
:::tip
|
|
14
14
|
[Rule List](../more/rules)
|
|
15
15
|
:::
|
|
16
16
|
|
|
17
|
-
- `
|
|
18
|
-
- `
|
|
17
|
+
- `E1003` Loader Performance Check. [[E1003] Loader Performance Optimization](/guide/rules/rules#e1003-loader-performance-optimization)
|
|
18
|
+
- `E1005` Default Import Check. [[E1005] Default Import Check](/guide/rules/rules#e1005-default-import-check)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Compilation
|
|
1
|
+
# Compilation Diagnostic Rules
|
|
2
2
|
|
|
3
|
-
Building diagnostic rules is similar to lint tools
|
|
3
|
+
Building diagnostic rules is similar to `ESLint` like lint tools, but different from it in that `ESLint` performs code scanning and is unrelated to the build process. In contrast, the code diagnostics here are closely related to the build process of `Rspack or Webpack`, incorporating many internal parameters generated during the build process to aid judgment, such as ModuleGraph, Webpack's internal markings for each module, and runtime added after code transformation, among others.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
During the build process, if issues are discovered, they will be visible in the CLI and the final diagnostic summary webpage, as shown below:
|
|
6
6
|
|
|
7
7
|
<img
|
|
8
8
|
width="700"
|
|
@@ -16,98 +16,22 @@ If any issues are detected during the build process, they will be displayed in t
|
|
|
16
16
|
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/rule-config-1.png"
|
|
17
17
|
/>
|
|
18
18
|
|
|
19
|
-
## How to
|
|
19
|
+
## How to Use
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Currently, Rsdoctor provides **built-in rules** and **custom rules**.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
23
|
+
### Built-in Rules
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
plugin: [
|
|
28
|
-
new RsdoctorWebpackPlugin({
|
|
29
|
-
linter: {
|
|
30
|
-
level: 'Error',
|
|
31
|
-
extends: [],
|
|
32
|
-
rules: {
|
|
33
|
-
'default-import-check': 'off',
|
|
34
|
-
'duplicate-package': [
|
|
35
|
-
'Error',
|
|
36
|
-
{
|
|
37
|
-
checkVersion: 'minor',
|
|
38
|
-
ignore: ['chalk', '@babel/runtime'],
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
};
|
|
46
|
-
```
|
|
25
|
+
The existing diagnostic tool includes multiple rules, all of which are enabled by default. They are:
|
|
47
26
|
|
|
48
|
-
|
|
27
|
+
1. [[E1001] Duplicate Packages](/guide/rules/rules#e1001-duplicate-packages)
|
|
28
|
+
2. [[E1002] Cross Chunks Package](/guide/rules/rules#e1002-cross-chunks-package)
|
|
29
|
+
3. [[E1003] Loader Performance Optimization](/guide/rules/rules#e1003-loader-performance-optimization)
|
|
30
|
+
4. [[E1004] ECMA Version Check](/guide/rules/rules#e1004-ecma-version-check)
|
|
31
|
+
5. [[E1005] Default Import Check](/guide/rules/rules#e1005-default-import-check)
|
|
49
32
|
|
|
50
|
-
|
|
33
|
+
For specific details, refer to [Built-in Rules](/guide/rules/rules).
|
|
51
34
|
|
|
52
|
-
|
|
53
|
-
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
35
|
+
### Custom Rules
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
plugin: [
|
|
57
|
-
new RsdoctorWebpackPlugin({
|
|
58
|
-
linter: {
|
|
59
|
-
rules: {
|
|
60
|
-
'ecma-version-check': [
|
|
61
|
-
'Warn',
|
|
62
|
-
{
|
|
63
|
-
ecmaVersion: 2015,
|
|
64
|
-
// targets: ["chrome >= 53"],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
}),
|
|
70
|
-
],
|
|
71
|
-
};
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
For more `ECMA Version Check` configuration, please refer to [ECMA Version Check Options](https://github.com/rspack-contrib/rsbuild-plugin-check-syntax?tab=readme-ov-file#options)
|
|
75
|
-
|
|
76
|
-
The type of `linter`:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
interface Options {
|
|
80
|
-
rules?: RulesMap;
|
|
81
|
-
level?: SeverityString;
|
|
82
|
-
extends?: ExtendRuleData[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Validation Level
|
|
87
|
-
* - When set to `'Warn'`, only rules with the category `'Warn'` will be executed
|
|
88
|
-
* - When set to `'Error'`, all rules will be executed
|
|
89
|
-
*/
|
|
90
|
-
type SeverityString = 'Warn' | 'Error';
|
|
91
|
-
|
|
92
|
-
/** Rule Level */
|
|
93
|
-
type SeverityInput = SeverityString | 'off' | 'on';
|
|
94
|
-
|
|
95
|
-
/** Rule Configuration */
|
|
96
|
-
type RulesMap = Record<string, RuleConfigItem>;
|
|
97
|
-
|
|
98
|
-
/** Individual Rule Configuration */
|
|
99
|
-
type RuleConfigItem =
|
|
100
|
-
// Only severity level, which takes precedence over the rule's own configuration
|
|
101
|
-
| SeverityInput
|
|
102
|
-
// In the case of an array, the first item is the severity level, and the second item is the rule configuration
|
|
103
|
-
| [SeverityInput, unknown];
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Existing internal rules
|
|
107
|
-
|
|
108
|
-
There are already three rules included in the existing diagnostic tool, which are:
|
|
109
|
-
|
|
110
|
-
1. [[E1001] Duplicate Packages](./bundle-alerts#%E9%87%8D%E5%A4%8D%E7%AC%AC%E4%B8%89%E6%96%B9%E5%8C%85)
|
|
111
|
-
2. [[E1002] Default Import Check](../more/rules)
|
|
112
|
-
3. [[E1003] Loader Performance Optimization](../more/rules)
|
|
113
|
-
4. [[E1004] ECMA Version Check](../more/rules)
|
|
37
|
+
Rsdoctor also collects analyzed data and allows users to integrate custom rules through the Linter API. For details on custom rules, refer to [Custom Rules](/guide/rules/rule-custom).
|