@rsdoctor/docs 0.3.5-beta.0 → 0.3.6

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.
@@ -11,7 +11,7 @@
11
11
  },
12
12
  {
13
13
  "text": "Blog",
14
- "link": "/blog/release/release-note-1",
14
+ "link": "/blog/release/release-note-0_1",
15
15
  "activeMatch": "/blog/"
16
16
  }
17
17
  ]
@@ -1 +1 @@
1
- ["release-note-1"]
1
+ ["release-note-0_1", "release-note-0_3"]
@@ -0,0 +1,138 @@
1
+ # Rsdoctor v0.2-0.3 Release Note
2
+
3
+ Rsdoctor v0.3 has been released!
4
+
5
+ The new features of Rsdoctor v0.3 include:
6
+
7
+ - Custom Extension Rules: Users can customize their own rule checks through the interface.
8
+ - Support for Banner Plugin: Added support for the Banner Plugin, which adds template wrapping to the bundled code, allowing analysis of code changes.
9
+ - Support for ESM Loader Analysis: Added support for analyzing ESM Loaders in the compilation analysis in Rspack.
10
+
11
+ ## Custom Extension Rules
12
+
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
+ 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
+
16
+ For more details, please refer to: [Custom Extension Rules](/guide/custom/rule-custom)
17
+
18
+ Additionally, the use of custom rules can also be applied for user data collection and reporting. [Data Reporting](/guide/custom/upload-data)
19
+
20
+ - Example:
21
+
22
+ ```ts
23
+ // src/rules/assets-count-limit.ts
24
+ import { defineRule } from '@rsdoctor/core/rules';
25
+
26
+ export const AssetsCountLimit = defineRule(() => ({
27
+ meta: {
28
+ category: 'bundle',
29
+ severity: 'Warn',
30
+ title: 'assets-count-limit',
31
+ defaultConfig: {
32
+ limit: 10,
33
+ },
34
+ },
35
+ check({ chunkGraph, report, ruleConfig }) {
36
+ const assets = chunkGraph.getAssets();
37
+
38
+ if (assets.length > ruleConfig.limit) {
39
+ report({
40
+ message: 'The count of assets is bigger than limit',
41
+ detail: {
42
+ type: 'link',
43
+ link: 'https://rsdoctor.dev/zh/guide/start/quick-start', // This link just for show case.
44
+ },
45
+ });
46
+ }
47
+ },
48
+ }));
49
+ ```
50
+
51
+ ```ts
52
+ // rsbuild.config.ts
53
+ import { AssetsCountLimit } from './rules/assets-count-limit';
54
+
55
+ export default {
56
+ tools: {
57
+ bundlerChain: (chain) => {
58
+ chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
59
+ {
60
+ linter: {
61
+ level: 'Error',
62
+ extends: [AssetsCountLimit],
63
+ rules: {
64
+ 'assets-count-limit': [
65
+ 'on',
66
+ {
67
+ limit: 1, // rule custom configs
68
+ },
69
+ ],
70
+ },
71
+ },
72
+ },
73
+ ]);
74
+ },
75
+ },
76
+ };
77
+ ```
78
+
79
+ ## Support for Banner Plugin
80
+
81
+ Both Rspack and Webpack support the BannerPlugin, which is an built-in plugin that allows you to add specific content at the top or bottom of the generated chunks. The added code will affect the parsing capability of the bundle.
82
+ Therefore, Rsdoctor has added support for the Banner Plugin.
83
+
84
+ Please refer to [Support for BannerPlugin](/guide/usage/bundle-size#support-for-bannerplugin)
85
+
86
+ ## Support for ESM Loader
87
+
88
+ Starting from Rspack@0.7.3, support for ESM Loader execution with `.js` extension and `type: module` configuration in `package.json` is added ([related issue](https://github.com/web-infra-dev/rspack/issues/5735)). Therefore, Rsdoctor also supports the analysis of ESM Loader, mainly supporting the following two types:
89
+
90
+ 1. ESM Loader with `.mjs` extension.
91
+ 2. ESM Loader with `.js` extension and `type: module` configuration in `package.json`.
92
+
93
+ ### Support for defining port
94
+
95
+ Support for [defining the port of Rsdoctor service](/config/options/options#port) has been added.
96
+
97
+ - Example:
98
+
99
+ ```ts
100
+ chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
101
+ {
102
+ port: 8888, // port
103
+ },
104
+ ]);
105
+ ```
106
+
107
+ ## Support for Parse Bundle Configuration
108
+
109
+ In some large repositories, the execution time for parsing bundles is significant. This is because the Parse Bundle analysis relies on AST parsing and processing, which can be time-consuming when there are a large number of files.
110
+ If this capability is not necessary, it can be selectively disabled using the `supports.parseBundle` configuration. Here is an example:
111
+
112
+ ```ts
113
+ chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
114
+ {
115
+ supports: {
116
+ parseBundle: false,
117
+ },
118
+ },
119
+ ]);
120
+ ```
121
+
122
+ Disabling the Parse Bundle capability only affects the ability to view the final bundled size and code of modules in the bundle (Bundled Code).
123
+
124
+ <div style={{ display: 'flex' }}>
125
+ <img
126
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundled-size.jpeg"
127
+ height="300px"
128
+ width="400px"
129
+ style={{ margin: 'auto' }}
130
+ />
131
+
132
+ <img
133
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundled-code.png"
134
+ height="300px"
135
+ width="500px"
136
+ style={{ margin: 'auto' }}
137
+ />
138
+ </div>
@@ -174,7 +174,9 @@ This option is used to configure whether Rsdoctor enables support for certain de
174
174
 
175
175
  ```ts
176
176
  type ISupport = {
177
- banner: boolean;
177
+ banner?: boolean;
178
+ parseBundle?: boolean;
179
+ generateTileGraph?: boolean;
178
180
  };
179
181
  ```
180
182
 
@@ -184,8 +186,59 @@ type ISupport = {
184
186
  When enabling the analysis of BannerPlugin, Rsdoctor should not be used in production versions.
185
187
  :::
186
188
 
189
+ - default: false.
190
+ - type: boolean.
191
+
187
192
  If `supports.banner` is enabled, Rsdoctor will enable compatibility logic for BannerPlugin. For more details, please refer to: [Supports BannerPlugin](../../guide/usage/bundle-size#supports-bannerplugin)
188
193
 
194
+ #### parseBundle
195
+
196
+ - default: true.
197
+ - type: boolean.
198
+
199
+ In some large repositories, the execution time of parsing the bundle is too long. Since the Parse Bundle analysis utilizes AST parsing and processing, it can be time-consuming when there are a large number of output files.
200
+ If this capability is not necessary, it can be selectively disabled using the supports.parseBundle configuration. An example is shown below:
201
+
202
+ ```ts
203
+ chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
204
+ {
205
+ supports: {
206
+ parseBundle: false,
207
+ },
208
+ },
209
+ ]);
210
+ ```
211
+
212
+ Disabling the Parse Bundle capability will only affect the visibility of the Bundled Size and Bundled Code of the modules in the bundle:
213
+
214
+ <div style={{ display: 'flex' }}>
215
+ <img
216
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundled-size.jpeg"
217
+ height="300px"
218
+ width="400px"
219
+ style={{ margin: 'auto' }}
220
+ />
221
+
222
+ <img
223
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundled-code.png"
224
+ height="300px"
225
+ width="500px"
226
+ style={{ margin: 'auto' }}
227
+ />
228
+ </div>
229
+ #### generateTileGraph
230
+
231
+ - default: true. The default value in rspack is false.
232
+ - type: boolean.
233
+
234
+ Whether to enable the ability to generate tile graphs, which affects whether the Bundle Size page has a tile graph from `webpack-bundle-analyzer`.
235
+
236
+ <img
237
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-tile-graph.png"
238
+ width="500px"
239
+ style={{ margin: 'auto' }}
240
+ />
241
+
189
242
  ### port
190
243
 
191
244
  - **Type:** `number`
@@ -9,6 +9,11 @@
9
9
  "name": "usage",
10
10
  "label": "Usage"
11
11
  },
12
+ {
13
+ "type": "dir",
14
+ "name": "custom",
15
+ "label": "User Custom"
16
+ },
12
17
  {
13
18
  "type": "dir",
14
19
  "name": "more",
@@ -0,0 +1 @@
1
+ ["rule-custom", "upload-data"]