@rsdoctor/docs 0.0.0-next-20240620044732

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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/docs/404.mdx +7 -0
  3. package/docs/en/_meta.json +17 -0
  4. package/docs/en/blog/_meta.json +12 -0
  5. package/docs/en/blog/release/_meta.json +1 -0
  6. package/docs/en/blog/release/release-note-1.mdx +129 -0
  7. package/docs/en/blog/topic/_meta.json +1 -0
  8. package/docs/en/blog/topic/duplicate-pkg-problem.mdx +141 -0
  9. package/docs/en/blog/topic/loader-optimization.mdx +80 -0
  10. package/docs/en/config/_meta.json +7 -0
  11. package/docs/en/config/options/_meta.json +1 -0
  12. package/docs/en/config/options/options-shared.mdx +67 -0
  13. package/docs/en/config/options/options.mdx +195 -0
  14. package/docs/en/config/options/term.mdx +10 -0
  15. package/docs/en/guide/_meta.json +17 -0
  16. package/docs/en/guide/more/_meta.json +1 -0
  17. package/docs/en/guide/more/faq.mdx +104 -0
  18. package/docs/en/guide/more/rules.mdx +5 -0
  19. package/docs/en/guide/start/_meta.json +1 -0
  20. package/docs/en/guide/start/cli.mdx +94 -0
  21. package/docs/en/guide/start/features.mdx +36 -0
  22. package/docs/en/guide/start/intro.mdx +115 -0
  23. package/docs/en/guide/start/quick-start-shared.mdx +184 -0
  24. package/docs/en/guide/start/quick-start.mdx +29 -0
  25. package/docs/en/guide/usage/_meta.json +14 -0
  26. package/docs/en/guide/usage/bundle-alerts.mdx +47 -0
  27. package/docs/en/guide/usage/bundle-overall.mdx +55 -0
  28. package/docs/en/guide/usage/bundle-size.mdx +148 -0
  29. package/docs/en/guide/usage/compile-alerts.mdx +18 -0
  30. package/docs/en/guide/usage/compile-overall.mdx +115 -0
  31. package/docs/en/guide/usage/loaders-analysis.mdx +72 -0
  32. package/docs/en/guide/usage/loaders-timeline.mdx +68 -0
  33. package/docs/en/guide/usage/module-analysis.mdx +58 -0
  34. package/docs/en/guide/usage/plugins-analysis.mdx +43 -0
  35. package/docs/en/guide/usage/project-overall.mdx +51 -0
  36. package/docs/en/guide/usage/resolver.mdx +32 -0
  37. package/docs/en/guide/usage/rule-config.mdx +85 -0
  38. package/docs/en/index.md +38 -0
  39. package/docs/public/netlify.toml +4 -0
  40. package/docs/public/og-image.png +0 -0
  41. package/docs/zh/_meta.json +17 -0
  42. package/docs/zh/blog/_meta.json +12 -0
  43. package/docs/zh/blog/release/_meta.json +1 -0
  44. package/docs/zh/blog/release/release-note-1.mdx +128 -0
  45. package/docs/zh/blog/topic/_meta.json +1 -0
  46. package/docs/zh/blog/topic/duplicate-pkg-problem.mdx +138 -0
  47. package/docs/zh/blog/topic/loader-optimization.mdx +80 -0
  48. package/docs/zh/config/_meta.json +7 -0
  49. package/docs/zh/config/options/_meta.json +1 -0
  50. package/docs/zh/config/options/options-shared.mdx +70 -0
  51. package/docs/zh/config/options/options.mdx +170 -0
  52. package/docs/zh/config/options/term.mdx +10 -0
  53. package/docs/zh/guide/_meta.json +17 -0
  54. package/docs/zh/guide/more/_meta.json +1 -0
  55. package/docs/zh/guide/more/faq.mdx +102 -0
  56. package/docs/zh/guide/more/rules.mdx +5 -0
  57. package/docs/zh/guide/start/_meta.json +1 -0
  58. package/docs/zh/guide/start/cli.mdx +94 -0
  59. package/docs/zh/guide/start/features.mdx +36 -0
  60. package/docs/zh/guide/start/intro.mdx +116 -0
  61. package/docs/zh/guide/start/quick-start-shared.mdx +183 -0
  62. package/docs/zh/guide/start/quick-start.mdx +29 -0
  63. package/docs/zh/guide/usage/_meta.json +14 -0
  64. package/docs/zh/guide/usage/bundle-alerts.mdx +49 -0
  65. package/docs/zh/guide/usage/bundle-overall.mdx +57 -0
  66. package/docs/zh/guide/usage/bundle-size.mdx +148 -0
  67. package/docs/zh/guide/usage/compile-alerts.mdx +18 -0
  68. package/docs/zh/guide/usage/compile-overall.mdx +115 -0
  69. package/docs/zh/guide/usage/loaders-analysis.mdx +73 -0
  70. package/docs/zh/guide/usage/loaders-timeline.mdx +68 -0
  71. package/docs/zh/guide/usage/module-analysis.mdx +59 -0
  72. package/docs/zh/guide/usage/plugins-analysis.mdx +43 -0
  73. package/docs/zh/guide/usage/project-overall.mdx +51 -0
  74. package/docs/zh/guide/usage/resolver.mdx +32 -0
  75. package/docs/zh/guide/usage/rule-config.mdx +86 -0
  76. package/docs/zh/index.md +38 -0
  77. package/docs/zh/shared/features-rspack.md +24 -0
  78. package/docs/zh/shared/features.md +29 -0
  79. package/package.json +45 -0
  80. package/src/components/NextSteps.module.scss +6 -0
  81. package/src/components/NextSteps.tsx +7 -0
  82. package/src/components/Overview.module.scss +61 -0
  83. package/src/components/Overview.tsx +40 -0
  84. package/src/components/RuleIndex.module.scss +57 -0
  85. package/src/components/RuleIndex.tsx +75 -0
  86. package/src/components/Step.module.scss +32 -0
  87. package/src/components/Step.tsx +13 -0
  88. package/src/global.d.ts +4 -0
  89. package/src/utils.ts +9 -0
@@ -0,0 +1,184 @@
1
+ ## Step 2: Register Plugin
2
+
3
+ After the dependency installation, you need to integrate the Rsdoctor plugin into your project. Below are some examples of common tools and frameworks:
4
+
5
+ ### Rspack
6
+
7
+ Initialize the RsdoctorRspackPlugin in the [plugins](https://www.rspack.dev/config/plugins.html#plugins) of `rspack.config.js`:
8
+
9
+ ```js title="rspack.config.js"
10
+ const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
11
+
12
+ module.exports = {
13
+ // ...
14
+ plugins: [
15
+ // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
16
+ process.env.RSDOCTOR &&
17
+ new RsdoctorRspackPlugin({
18
+ // plugin options
19
+ }),
20
+ ].filter(Boolean),
21
+ };
22
+ ```
23
+
24
+ - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
25
+
26
+ ### Rsbuild
27
+
28
+ Initialize the RsdoctorRspackPlugin in the [tools.rspack](https://rsbuild.dev/config/tools/rspack) of `rsbuild.config.ts`:
29
+
30
+ ```js title="rsbuild.config.ts"
31
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
32
+
33
+ export default {
34
+ // ...
35
+ tools: {
36
+ rspack(config, { appendPlugins }) {
37
+ // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
38
+ if (process.env.RSDOCTOR) {
39
+ appendPlugins(
40
+ new RsdoctorRspackPlugin({
41
+ // plugin options
42
+ }),
43
+ );
44
+ }
45
+ },
46
+ },
47
+ };
48
+ ```
49
+
50
+ - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
51
+
52
+ ### Webpack
53
+
54
+ Initialize the RsdoctorWebpackPlugin in the [plugins](https://webpack.js.org/configuration/plugins/#plugins) of `webpack.config.js`:
55
+
56
+ ```js title="webpack.config.js"
57
+ const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
58
+
59
+ module.exports = {
60
+ // ...
61
+ plugins: [
62
+ // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
63
+ process.env.RSDOCTOR &&
64
+ new RsdoctorWebpackPlugin({
65
+ // plugin options
66
+ }),
67
+ ].filter(Boolean),
68
+ };
69
+ ```
70
+
71
+ - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
72
+
73
+ ### Modern.js Framework
74
+
75
+ Initialize the plugin in the [tools.rspack](https://modernjs.dev/configure/app/tools/rspack) of `modern.config.ts`:
76
+
77
+ ```ts title="modern.config.ts"
78
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
79
+
80
+ export default {
81
+ // ...
82
+ tools: {
83
+ rspack(config, { appendPlugins }) {
84
+ // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
85
+ if (process.env.RSDOCTOR) {
86
+ appendPlugins(
87
+ new RsdoctorRspackPlugin({
88
+ // plugin options
89
+ }),
90
+ );
91
+ }
92
+ },
93
+ },
94
+ };
95
+ ```
96
+
97
+ - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
98
+
99
+ :::tip
100
+ For projects using Modern.js Webpack mode, please register the `RsdoctorWebpackPlugin` plugin through [tools.webpack](https://modernjs.dev/configure/app/tools/webpack).
101
+ :::
102
+
103
+ ### Next.js Framework
104
+
105
+ Initialize the RsdoctorWebpackPlugin plugin in the [Webpack Config](https://nextjs.org/docs/app/api-reference/next-config-js/webpack) of `next.config.mjs`.
106
+
107
+ ```ts title="next.config.mjs"
108
+ import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
109
+
110
+ export default {
111
+ // ...
112
+ webpack: (config, { isServer }) => {
113
+ config.plugins.push(
114
+ new RsdoctorWebpackPlugin({
115
+ // plugin options
116
+ }),
117
+ );
118
+
119
+ return config;
120
+ },
121
+ };
122
+ ```
123
+
124
+ - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
125
+
126
+ #### 📢 Next.js Project Notice
127
+
128
+ 1. Next.js Project Reporting Page Issues
129
+
130
+ For more details, see: [FAQ](../more/faq#nextjs)
131
+
132
+ 2. Loader Analysis with Rules Overriding Not Supported in Next.js
133
+
134
+ For more details, see: [FAQ](../more/faq#nextjs)
135
+
136
+ ### Vue Framework
137
+
138
+ Initialize the `@rsdoctor/webpack-plugin` or `@rsdoctor/rspack-plugin` plugin in the configuration file. Here is an example using `rsbuild`:
139
+
140
+ ```ts title="rsbuild.config.ts"
141
+ import { defineConfig } from '@rsbuild/core';
142
+ import { pluginVue } from '@rsbuild/plugin-vue';
143
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
144
+
145
+ export default defineConfig({
146
+ plugins: [pluginVue()],
147
+ performance: {
148
+ buildCache: false,
149
+ },
150
+ tools: {
151
+ bundlerChain: (chain, { CHAIN_ID }) => {
152
+ chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
153
+ {
154
+ // plugin options
155
+ },
156
+ ]);
157
+ },
158
+ },
159
+ });
160
+ ```
161
+
162
+ - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
163
+
164
+ #### 📢 Vue Project Notice
165
+
166
+ Because `vue-loader` analysis is not supported at the moment, loader analysis is disabled by default for Vue projects. However, plugin and build artifact analysis can still be performed.
167
+
168
+ ---
169
+
170
+ ## Step 3: Run Build
171
+
172
+ Now, you can run the **build** command in the project. After the build is complete, Rsdoctor will automatically open the analysis page of this build.
173
+
174
+ ```bash
175
+ # Enable Rsdoctor
176
+ RSDOCTOR=true npm run build
177
+
178
+ # Disable Rsdoctor
179
+ npm run build
180
+ ```
181
+
182
+ :::tip
183
+ The Rsdoctor plugin provides some configurations, please refer to [Options](../../config/options/options).
184
+ :::
@@ -0,0 +1,29 @@
1
+ # Quick Start
2
+
3
+ This document will explain how to access the Rsdoctor ability.
4
+
5
+ ## Step 1: Install dependencies
6
+
7
+ import { PackageManagerTabs } from '@theme';
8
+
9
+ ### Rspack Projects
10
+
11
+ For projects based on Rspack or Rsbuild, install the following dependencies:
12
+
13
+ <PackageManagerTabs command="add @rsdoctor/rspack-plugin -D" />
14
+
15
+ ### Webpack Projects
16
+
17
+ :::tip
18
+ Not supported in Webpack 4.
19
+ :::
20
+
21
+ For projects based on Webpack, install the following dependencies:
22
+
23
+ <PackageManagerTabs command="add @rsdoctor/webpack-plugin -D" />
24
+
25
+ ---
26
+
27
+ import QuickStartShared from './quick-start-shared.mdx';
28
+
29
+ <QuickStartShared />
@@ -0,0 +1,14 @@
1
+ [
2
+ "project-overall",
3
+ "bundle-overall",
4
+ "compile-overall",
5
+ "compile-alerts",
6
+ "bundle-alerts",
7
+ "loaders-timeline",
8
+ "loaders-analysis",
9
+ "plugins-analysis",
10
+ "bundle-size",
11
+ "module-analysis",
12
+ "resolver",
13
+ "rule-config"
14
+ ]
@@ -0,0 +1,47 @@
1
+ # Bundle Alerts
2
+
3
+ ## Introduction
4
+
5
+ ### Duplicate Third-party Packages
6
+
7
+ - The `Duplicate Packages` card displays the number of duplicate third-party packages in the project. Click on the image to view the specific details of the duplicate packages. Note: The third-party packages mentioned here are the ones that have been bundled.
8
+
9
+ <div style={{ display: 'flex' }}>
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>
21
+
22
+ - Duplicate Package Alerts Card
23
+
24
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alerts.png" />
25
+
26
+ - Click on the icon to expand the details of the duplicate packages, where you can see the package name, version, size, and reference files.
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
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alerts-ecma.png" />
46
+
47
+ Click on "**More**" to view the corresponding rule explanation.
@@ -0,0 +1,55 @@
1
+ # Bundle Overall
2
+
3
+ ## Overview
4
+
5
+ On the homepage of **Rsdoctor**, we can see a card called `Bundle Overall`, which provides information about the **build artifacts** of the current project. The content is shown in the following image:
6
+
7
+ <img
8
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/bundle-overall-1.jpg"
9
+ width="400px"
10
+ height="500px"
11
+ style={{ margin: 'auto' }}
12
+ />
13
+
14
+ ## Glossary
15
+
16
+ | Term | Description |
17
+ | -------------------------------- | -------------------------------------------------------------------------------------------- |
18
+ | <b><i>total files</i></b> | Represents the total number of files in the artifacts |
19
+ | <b><i>total size</i></b> | Represents the total size of all files in the artifacts |
20
+ | <b><i>js files</i></b> | Represents the number of `.js` files in the artifacts |
21
+ | <b><i>css files</i></b> | Represents the number of `.css` files in the artifacts |
22
+ | <b><i>image files</i></b> | Represents the number of `.png`/`.jpg`/`.svg`/`.webp`/`.jpeg`/`.gif`/`.bmp` files |
23
+ | <b><i>font files</i></b> | Represents the number of `.ttf`/`.fnt`/`.fon`/`.otf`/`.woff`/`.woff2` files in the artifacts |
24
+ | <b><i>media files</i></b> | Represents the number of `.mp3`/`.mp4`/`.avi`/`.wav`/`.flv`/`.mov`/`.mpg`/`.mpeg` files |
25
+ | <b><i>html files</i></b> | Represents the number of `.html` files in the artifacts |
26
+ | <b><i>modules</i></b> | Represents the total number of modules in the artifacts |
27
+ | <b><i>duplicate packages</i></b> | Represents the total number of duplicate packages in the artifacts |
28
+
29
+ ## Usage Instructions
30
+
31
+ ### View Bundle Artifacts
32
+
33
+ - The **"TOTAL Size"** data on the card represents the total size of the project. Clicking on this number will navigate to the [Bundle Size](./bundle-size.mdx)
34
+
35
+ - The card also displays the number and total size of different file types. Clicking on the corresponding blue icon will display the list of files, as shown in the following image:
36
+ - **Initial:** Refers to the Chunk being the main chunk of the entry.
37
+
38
+ <img
39
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/bundle-overall-files.png"
40
+ width="400px"
41
+ height="600px"
42
+ style={{ margin: 'auto' }}
43
+ />
44
+
45
+ ### [Duplicate Packages](../../blog/topic/duplicate-pkg-problem.mdx)
46
+
47
+ If the `Duplicate Packages` number on the card is greater than 0, you can **click to view the details of the duplicate packages**. The content is shown in the following image:
48
+
49
+ <img
50
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/bundle-overall-dup-pkg.jpg"
51
+ width="600px"
52
+ style={{ margin: 'auto' }}
53
+ />
54
+
55
+ Here, you can see the list of all duplicate packages detected by Rsdoctor in the current build artifacts.
@@ -0,0 +1,148 @@
1
+ # Bundle Analysis
2
+
3
+ ## Introduction
4
+
5
+ **Rsdoctor** provides the `Bundle Size` module, which is mainly used to analyze the information of the build artifacts of **Webpack** or **Rspack**, including the **size of resources**, **duplicate packages**, and **module reference relationships**:
6
+
7
+ - **Bundle Overview**: Displays the total number and size of artifacts, as well as the number and size of each file type. It also shows the duplicate packages and their reference chains.
8
+ - **Bundle Analysis Module**: Analyzes the size and code information of the build artifacts' resources (**Assets**) and the included **Modules**. In this module, you can view the **actual code size of modules after packaging** in the Assets, as well as the original code or **packaged code segments** and **module reference relationships**.
9
+
10
+ <img
11
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-overall.png"
12
+ width={'700px'}
13
+ style={{ margin: 'auto' }}
14
+ />
15
+
16
+ Click on the **"Bundle Size"** option in the navigation bar to view the Bundle analysis report. Please note that to display this page, you need to enable the build artifact analysis capability [features](/config/options/options).
17
+
18
+ ### Glossary
19
+
20
+ - **`Assets`**: Resources refer to images, fonts, media, and other file types. They are the files that ultimately exist in the output folder. Each Chunk has corresponding [Assets resources](https://webpack.js.org/concepts/under-the-hood/#chunks).
21
+ - **`Module`**: One or more Modules combine to form a Chunk. For more information about Module types, please refer to [Rspack Modules](https://www.rspack.dev/api/modules.html) and [Webpack Modules](https://webpack.js.org/concepts/modules/#what-is-a-webpack-module).
22
+ - **`Bundle Size`**: The final packaged size of the resource artifact, which is the final size after being processed by the builder.
23
+ - **`Module Bundled Source & Size`**: **Module Parsed Source** refers to the final code fragment of the **Module** in the packaged artifact, and **Module Parsed Size** refers to the size of the final code fragment of the **Module** in the packaged artifact.
24
+ - **`Package Count`**: The number of third-party packages.
25
+ - **`Initial Chunk`**: The **initial** chunk is the main chunk of the entry point. This chunk contains all the modules specified by the entry point and their dependencies, unlike the **chunks** for "on-demand loading".
26
+ - For more information about Initial Chunk, please refer to [Initial Chunk Introduction](https://webpack.js.org/concepts/under-the-hood/#chunks).
27
+ - **`Duplicate Packages`**: Duplicate third-party packages bundled into the project. Excludes third-party packages that are not bundled into the artifact. Please refer to [Duplicate Packages](/guide/usage/bundle-alerts).
28
+ - **`Concatenated Module`**: A concatenated module is a technique that combines multiple modules into one closure during packaging. In the past, Webpack would package each module into a separate closure, and this encapsulation function would cause slower execution of JavaScript in the browser. Optimization can be achieved by enabling the [`optimization.concatenateModules`](https://webpack.js.org/plugins/module-concatenation-plugin/#root) parameter.
29
+
30
+ ## Bundle Overview
31
+
32
+ ### Bundle Information Card
33
+
34
+ The bundle overview displays information about the number and size of files, such as `Total Files`. Clicking on the card chart expands the resource details, as shown in the following image:
35
+
36
+ <img
37
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-overall-1.png"
38
+ width={'700px'}
39
+ style={{ margin: 'auto' }}
40
+ />
41
+
42
+ - Clicking on the details icon displays the corresponding resource tree on the right, indicating the resource sizes:
43
+
44
+ <img
45
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-tree.png"
46
+ width={'300px'}
47
+ height={'400px'}
48
+ style={{ margin: 'auto' }}
49
+ />
50
+
51
+ - Clicking on the tabs allows you to switch between different resource information views, such as **[Total JS | Initial JS]**. The card also displays the percentage, size, and number of resources. Similarly, clicking on the icon in the lower right corner expands the resource list.
52
+
53
+ ### Duplicate Packages
54
+
55
+ The **Duplicate Packages** card displays the number of duplicate third-party packages in the project. Clicking on the image allows you to view the specific details of the duplicate packages. Please note that these are duplicate packages that have been bundled.
56
+
57
+ For more information, please refer to [Duplicate Packages](/guide/usage/bundle-alerts).
58
+
59
+ ## Bundle Analysis
60
+
61
+ ::: tip
62
+ If your project is based on Rspack and the version is lower than 0.5.1, you cannot view code information.
63
+ :::
64
+
65
+ ### Resource and Module Relationship Display
66
+
67
+ The **Bundle Analysis** module is used to analyze the size and code information of the build artifacts' resources (**Assets**) and the included **Modules**. The example image is shown below:
68
+
69
+ - On the left side is the list of **Assets** resources, sorted in descending order by resource size. You can click the **"expand all"** button to expand all nodes.
70
+ - On the right side is the list of **Modules** corresponding to the **Assets**, also sorted in descending order by module size after packaging.
71
+
72
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-analysis-tree.png" />
73
+
74
+ ### Search and Filter Box
75
+
76
+ The top toolbar from left to right includes: the search tool for **Assets**, the filter tool for **Assets** size, and the filter tool for **Module** size.
77
+
78
+ - **Search Entry Input Box**: Enter the keyword of an **Entry** in the input box to search for the corresponding **Entry** and display only the related **Assets**.
79
+ - **Search Assets Input Box**: Enter the keyword of an **Assets** in the input box to search for the corresponding **Assets**.
80
+ - **Assets Size Filter Tool**: Enter a number with units of KB or MB to filter out **Assets** resources smaller than the specified size.
81
+ - **Module Size Filter Tool**: Enter a number with units of KB or MB to filter out **Module** resources smaller than the specified size.
82
+
83
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-analysis-selects.png" />
84
+
85
+ ### Module Tag Explanation
86
+
87
+ The **Assets** tag is shown in the left image, from left to right representing: **Resource Size**, **[Initial Chunk](https://webpack.js.org/concepts/under-the-hood/#chunks)**, and **Code View**.
88
+
89
+ <div style={{ display: 'flex' }}>
90
+ <img
91
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-assets-tags.png"
92
+ height="200px"
93
+ width="360px"
94
+ style={{ margin: 'auto' }}
95
+ />
96
+ <img
97
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-modules-tags.png"
98
+ height="300px"
99
+ width="440px"
100
+ style={{ margin: 'auto' }}
101
+ />
102
+ </div>
103
+
104
+ The **Modules** tag is shown in the right image, from left to right representing:
105
+
106
+ - **Bundled Size**
107
+ - The final size of the module bundled into the artifact. Some modules labeled as `concatenated` are concatenated modules, which have a certain impact on this value. Please refer to the explanation of `concatenated module` below.
108
+ - **[Concatenated Module](https://webpack.js.org/plugins/module-concatenation-plugin/#root)**: Concatenated modules are modules that are optimized or concatenated into one closure during bundling. There are two types:
109
+ - One is the concatenated main module, indicating how many `Modules` are concatenated.
110
+ - The other is the concatenated sub-module, indicating which `Module` it is aggregated into. This sub-module cannot be further unpacked after bundling, so the specific `Bundled Size` cannot be determined. Only the size of the entire concatenated module is known, which is marked at the end of the main module.
111
+ - **Module Explorer** tag: Click to open the dependency analysis page between `Modules`.
112
+ - **Code View** tag: Click to expand code segments, including `Source` (source code), `Transformed` (compiled code), and `Bundled` (bundled code).
113
+
114
+ ## Bundle Overview Tile Graph
115
+
116
+ Click the **"Bundle Analyzer Graph"** button on the **"Bundle Size"** page to view the classic tile graph.
117
+
118
+ <img
119
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-size-tile-graph.png"
120
+ width="500px"
121
+ style={{ margin: 'auto' }}
122
+ />
123
+
124
+ ## Supports BannerPlugin
125
+
126
+ :::danger
127
+ When enabling the BannerPlugin analysis, do not use Rsdoctor in the production version.
128
+ :::
129
+
130
+ Both Rspack and Webpack support the [BannerPlugin](https://www.rspack.dev/plugins/webpack/banner-plugin#bannerplugin), which is a built-in plugin that allows you to add specific content at the top or bottom of the generated chunks.
131
+ The added code segment will affect the analysis capability of the bundle.
132
+
133
+ Rsdoctor is compatible with the logic of adding code using the BannerPlugin, but it is not enabled by default because Rsdoctor needs to add tag code. The Rsdoctor BannerPlugin capability is enabled in the following two cases:
134
+
135
+ 1. The project uses the BannerPlugin in `rspack.config.j|ts` or `webpack.config.j|ts`.
136
+
137
+ 2. Enable Rsdoctor BannerPlugin capability through Rsdoctor options by setting `supports.banner`:
138
+
139
+ ```ts
140
+ new RsdoctorRspackPlugin (
141
+ supports: {
142
+ banner: true
143
+ }
144
+ )
145
+
146
+ ```
147
+
148
+ - Note: Enabling `drop_console` will affect Rsdoctor's analysis of the BannerPlugin. Therefore, you can disable `drop_console` when `RSDOCTOR = true`.
@@ -0,0 +1,18 @@
1
+ # Compilation Alerts
2
+
3
+ We have also integrated the ability to detect warnings based on compilation data. If the current compilation results contain data that matches the rules defined by us, the `Compile Alerts` module will appear below the **Rsdoctor** main interface, as shown in the following figure:
4
+
5
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/compile/compile-alerts.png" />
6
+
7
+ Through this module, we can intuitively see some warning information about the compilation performance of our project, which helps us further optimize the compilation performance of the project.
8
+
9
+ ## Rules
10
+
11
+ Currently, the compilation rules include:
12
+
13
+ :::tip
14
+ [Rule List](../more/rules)
15
+ :::
16
+
17
+ - `E1002` Default Import Check.
18
+ - `E1003` Loader Performance Optimization.
@@ -0,0 +1,115 @@
1
+ # Compile Overall
2
+
3
+ ## Overview
4
+
5
+ On the homepage of **Rsdoctor**, there is a card called `Compile Overall` that provides information about the **compilation process** of the current project. The content is shown in the following image:
6
+
7
+ <img
8
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/compile-overall-1.jpg"
9
+ width="400px"
10
+ height="600px"
11
+ style={{ margin: 'auto' }}
12
+ />
13
+
14
+ :::tip
15
+ For each compilation phase, if the time data is displayed in <u>blue</u>, it means that you can <u>click to view the detailed time breakdown</u>.
16
+ :::
17
+
18
+ ## Glossary
19
+
20
+ The following table explains the meaning and code implementation of each phase in the card:
21
+
22
+ | Phase Name | Description | Code Implementation |
23
+ | ---------------------------------------- | ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24
+ | <b><i>Bootstrap -> BeforeCompile</i></b> | Represents the time taken from project startup to before compilation starts | <ul><li>In `Webpack` or `Rspack` projects: Reports [process.uptime()](https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processuptime) as the <b>duration</b> when **compiler.hooks.beforeCompile** is called</li></ul> |
25
+ | <b><i>Compile</i></b> | Represents the total time taken for the project compilation | <ul><li>In `Webpack` or `Rspack` projects: The <b>start time</b> is the time when **compiler.hooks.beforeCompile** is called, and the <b>end time</b> is the time when **compiler.hooks.afterCompile** is called</li></ul> |
26
+ | <b><i>AfterCompile -> Done</i></b> | Represents the time taken from compilation completion to the end of the entire process | <ul><li>In `Webpack` or `Rspack` projects: The <b>start time</b> is the time when **compiler.hooks.afterCompile** is called, and the <b>end time</b> is the time when **compiler.hooks.done** is called</li></ul> |
27
+ | <b><i>Minify</i></b> | Represents the time taken for file compression during the compilation process in most cases | <ul><li>In `Webpack` or `Rspack` projects: Calculates the sum of the time taken for each call of **compilation.hooks.optimizeChunkAssets** and **compilation.hooks.processAssets**</li></ul> |
28
+
29
+ ## Usage Instructions
30
+
31
+ ### Bootstrap -> BeforeCompile Details
32
+
33
+ By **clicking on the data of the `Bootstrap -> BeforeCompile` phase**, a popup will appear on the page, as shown in the following image:
34
+
35
+ <img
36
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/compile-overall-boostrap.jpg"
37
+ width="600px"
38
+ style={{ margin: 'auto' }}
39
+ />
40
+
41
+ The popup mainly contains a chart:
42
+
43
+ - The **x-axis** represents **time**
44
+ - The **y-axis** represents all the **hooks** that have been **tapped by plugins** before the **compiler.hooks.beforeCompile** is called
45
+ - The data in the chart represents the **start and end time** of each **hook**.
46
+
47
+ Hovering over a data point in the chart will display the following information in a tooltip:
48
+
49
+ - **hook**: the name of the hook
50
+ - **tap name**: the name value when [.tap](https://github.com/webpack/tapable#hookhookmap-interface) is called
51
+ - **start**: the start time
52
+ - **end**: the end time
53
+ - **duration**: the duration, calculated as `end - start`
54
+
55
+ ### Compile Phase
56
+
57
+ In this section, you can navigate to "Compile Analysis" -> "Loader Analysis" -> [**"Loader Timeline"**](./loaders-timeline.mdx) in the navigation bar to view the timeline of loader compilation time.
58
+
59
+ ### AfterCompile -> Done Details
60
+
61
+ By **clicking on the data of the `AfterCompile -> Done` phase**, a popup will appear on the page, as shown in the following image:
62
+
63
+ <img
64
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/compile-overall-aftercompile-1.jpg"
65
+ width="600px"
66
+ height="400px"
67
+ style={{ margin: 'auto' }}
68
+ />
69
+
70
+ The popup mainly contains a data table that shows the relevant data of the calls. The field meanings are as follows:
71
+
72
+ - **Plugin Tap Name**: the name value when [.tap](https://github.com/webpack/tapable#hookhookmap-interface) is called
73
+ - **Hook**: the name of the hook
74
+ - **calls**: the number of times the hook is called
75
+ - **duration(total)**: the total time of all the calls
76
+
77
+ Scrolling down the page will show the corresponding chart:
78
+
79
+ <img
80
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/compile-overall-aftercompile-2.jpg"
81
+ width="600px"
82
+ style={{ margin: 'auto' }}
83
+ />
84
+
85
+ The chart shows:
86
+
87
+ - The **x-axis** represents **time**
88
+ - The **y-axis** represents all the **hooks** that have been **tapped by plugins** between **compiler.hooks.afterCompile** and **compiler.hooks.done**
89
+ - The data in the chart represents the **start and end time** of each **hook**.
90
+
91
+ Hovering over a data point in the chart will display the following information in a tooltip:
92
+
93
+ - **hook**: the name of the hook
94
+ - **tap name**: the name value when [.tap](https://github.com/webpack/tapable#hookhookmap-interface) is called
95
+ - **start**: the start time
96
+ - **end**: the end time
97
+ - **duration**: the duration, calculated as `end - start`
98
+
99
+ ### Minify Details
100
+
101
+ :::tip
102
+ Minify details are currently not available for Rspack projects.
103
+ :::
104
+
105
+ By **clicking on the data of the `Minify` phase**, a popup will appear on the page, as shown in the following images:
106
+
107
+ | <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/compile-overall-minify-1.jpg" /> | <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/overall/compile-overall-minify-2.jpg" /> |
108
+ | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
109
+
110
+ The content in the popup has similar meanings to the previous paragraphs, so it will not be repeated here.
111
+
112
+ ## Reference Documentation
113
+
114
+ - [**Rspack Hooks**](https://www.rspack.dev/api/plugin-api.html#beforecompile)
115
+ - [**Webpack Hooks**](https://webpack.js.org/api/compilation-hooks/)