@rsdoctor/docs 1.0.0-beta.3 → 1.0.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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/docs/en/blog/release/release-note-0_1.mdx +4 -4
  3. package/docs/en/blog/release/release-note-0_3.mdx +2 -1
  4. package/docs/en/blog/topic/duplicate-pkg-problem.mdx +11 -12
  5. package/docs/en/blog/topic/loader-optimization.mdx +1 -1
  6. package/docs/en/config/options/options.mdx +2 -2
  7. package/docs/en/guide/more/faq.mdx +1 -43
  8. package/docs/en/guide/rules/rules.mdx +10 -10
  9. package/docs/en/guide/start/cli.mdx +1 -1
  10. package/docs/en/guide/start/intro.mdx +6 -6
  11. package/docs/en/guide/start/quick-start-shared.mdx +49 -20
  12. package/docs/en/guide/start/quick-start.mdx +3 -3
  13. package/docs/en/guide/usage/bundle-alerts.mdx +1 -1
  14. package/docs/en/guide/usage/bundle-size.mdx +11 -11
  15. package/docs/en/guide/usage/compile-alerts.mdx +1 -1
  16. package/docs/en/guide/usage/compile-overall.mdx +7 -7
  17. package/docs/en/guide/usage/plugins-analysis.mdx +2 -2
  18. package/docs/en/guide/usage/project-overall.mdx +13 -15
  19. package/docs/en/guide/usage/resolver.mdx +1 -1
  20. package/docs/en/guide/usage/rule-config.mdx +3 -3
  21. package/docs/zh/blog/release/release-note-0_1.mdx +4 -4
  22. package/docs/zh/blog/release/release-note-0_3.mdx +1 -1
  23. package/docs/zh/blog/topic/duplicate-pkg-problem.mdx +9 -10
  24. package/docs/zh/blog/topic/loader-optimization.mdx +1 -1
  25. package/docs/zh/config/options/options.mdx +39 -39
  26. package/docs/zh/guide/more/faq.mdx +1 -43
  27. package/docs/zh/guide/rules/rules.mdx +5 -5
  28. package/docs/zh/guide/start/cli.mdx +1 -1
  29. package/docs/zh/guide/start/intro.mdx +5 -5
  30. package/docs/zh/guide/start/quick-start-shared.mdx +44 -14
  31. package/docs/zh/guide/start/quick-start.mdx +2 -2
  32. package/docs/zh/guide/usage/bundle-size.mdx +9 -9
  33. package/docs/zh/guide/usage/compile-overall.mdx +7 -7
  34. package/docs/zh/guide/usage/module-analysis.mdx +1 -1
  35. package/docs/zh/guide/usage/plugins-analysis.mdx +2 -2
  36. package/docs/zh/guide/usage/project-overall.mdx +13 -15
  37. package/docs/zh/guide/usage/resolver.mdx +1 -1
  38. package/docs/zh/guide/usage/rule-config.mdx +1 -1
  39. package/package.json +5 -5
  40. package/docs/public/og-image.png +0 -0
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rsdoctor Website
1
+ # Rsdoctor website
2
2
 
3
3
  ## Writing style guide
4
4
 
@@ -23,11 +23,11 @@ Rsdoctor is a one-stop build analysis tool for Rspack and Webpack. It allows for
23
23
  - **Compilation Visualization**: Rsdoctor visualizes the compilation behavior and time consumption, making it easy to view build issues.
24
24
  - **Multiple Analysis Capabilities**: Rsdoctor supports build artifact, build-time analysis, and anti-degradation capabilities:
25
25
  - Build artifact support for resource lists and module dependencies, etc.
26
- - Build-time analysis supports Loader, Plugin, and Resolver building process analysis, including: Rspack's builtin:swc-loader.
26
+ - Build-time analysis supports Loader, Plugin, and Resolver building process analysis, including Rspack's builtin loaders.
27
27
  - Build rules support duplicate package detection and ES Version Check, etc.
28
- - Currently, bundle Diff capabilities are also available.
28
+ - Currently, bundle diff capabilities are also available.
29
29
  - **Support Custom Rules**: In addition to built-in build scan rules, Rsdoctor also supports users adding custom component scan rules based on the build data of Rsdoctor.
30
- - **Framework-Independent**: Rsdoctor support all projects built on Webpack or Rspack.
30
+ - **Framework-Independent**: Rsdoctor support all projects built on Rspack or webpack.
31
31
 
32
32
  ## 🛠️ Introduction
33
33
 
@@ -48,7 +48,7 @@ Provides corresponding data and analysis functions for **Loaders, Plugins, and M
48
48
 
49
49
  #### Loader analysis
50
50
 
51
- - This module mainly provides the function of data analysis such as input and output, estimated time consumption, and parameters within **Rspack or Webpack Loaders**.
51
+ - This module mainly provides the function of data analysis such as input and output, estimated time consumption, and parameters within **Rspack or webpack Loaders**.
52
52
 
53
53
  <div style={{ display: 'flex' }}>
54
54
  <img
@@ -78,7 +78,8 @@ export default {
78
78
 
79
79
  ## Support for banner plugin
80
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.
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
+
82
83
  Therefore, Rsdoctor has added support for the Banner Plugin.
83
84
 
84
85
  Please refer to [Support for BannerPlugin](/guide/usage/bundle-size#support-for-bannerplugin)
@@ -1,6 +1,6 @@
1
1
  # Duplicate dependency problem
2
2
 
3
- Rsdoctor will report cases where multiple duplicate dependencies exist in the same builder's artifact.
3
+ Rsdoctor will report cases where multiple duplicate dependencies exist in the same bundler's artifact.
4
4
 
5
5
  <img src="https://assets.rspack.dev/others/assets/rsdoctor/bundle-alerts.png" />
6
6
 
@@ -8,7 +8,7 @@ Rsdoctor will report cases where multiple duplicate dependencies exist in the sa
8
8
 
9
9
  - **Security**
10
10
  - Many packages adopt singleton mode and are only loaded once by default. Examples include core-js, react, and some component libraries. Having multiple versions coexist can cause runtime errors.
11
- - **Runtime Perßformance**
11
+ - **Runtime Performance**
12
12
  - Increases artifact size, slowing down network transmission
13
13
  - Same code for the same functionality runs multiple times
14
14
 
@@ -38,10 +38,9 @@ However, before using them, it is important to consider the compatibility betwee
38
38
 
39
39
  #### Use [resolve.alias](https://www.rspack.dev/config/resolve.html#resolvealias)
40
40
 
41
- Almost all builders support modifying the paths for resolving npm packages. Therefore, we can eliminate duplicate dependencies by manually specifying the resolve paths for packages during compilation. For example, using **Rspack** or **Webpack**, if `lodash` is duplicated in the build, we can configure it as follows to specify the resolve paths for all `lodash` packages to the `node_modules` directory in the current directory.
41
+ Almost all bundlers support customizing the resolution paths for npm packages. Therefore, we can eliminate duplicate dependencies by manually specifying the resolve paths for packages during compilation. For example, using **Rspack** or **Webpack**, if `lodash` is duplicated in the build, we can configure it as follows to specify the resolve paths for all `lodash` packages to the `node_modules` directory in the current directory.
42
42
 
43
- ```js
44
- // webpack.config.js/rspack.config.js
43
+ ```js title="rspack.config.js"
45
44
  const path = require('path');
46
45
 
47
46
  module.exports = {
@@ -71,7 +70,7 @@ In this project, the `web` app depends on `react@18.2.0` and imports `component`
71
70
  │ │ └── react -> ../../../node_modules/.pnpm/react@18.2.0
72
71
  │ ├── src
73
72
  │ │ └── index.js
74
- │ ├── webpack.config.js
73
+ │ ├── rspack.config.js
75
74
  │ └── package.json
76
75
  └── packages
77
76
  └── component
@@ -82,14 +81,14 @@ In this project, the `web` app depends on `react@18.2.0` and imports `component`
82
81
  └── package.json
83
82
  ```
84
83
 
85
- When executing `webpack build` under `apps/web`, the code in the `web` directory will be resolved to `react@18.2.0`, and then the code in the `component` directory will be resolved to `react@18.1.0`. This results in the output of the web project containing two versions of `React`.
84
+ When executing `rspack build` under `apps/web`, the code in the `web` directory will be resolved to `react@18.2.0`, and then the code in the `component` directory will be resolved to `react@18.1.0`. This results in the output of the web project containing two versions of `React`.
86
85
 
87
86
  #### Solution
88
87
 
89
- This issue can be resolved using the `resolve.alias` configuration in the builder, such as `Rspack` or `Webpack`. By specifying the resolve path for `React` to only resolve to `apps/web/node_modules/react`, you can ensure that only one version of `React` is included in the output. Here is an example code:
88
+ This issue can be resolved using the `resolve.alias` configuration of the bundler, such as Rspack or webpack. By specifying the resolve path for `React` to only resolve to `apps/web/node_modules/react`, you can ensure that only one version of `React` is included in the output. Here is an example code:
90
89
 
91
90
  ```javascript
92
- // apps/web/webpack.config.js
91
+ // apps/web/rspack.config.js
93
92
  const path = require('path');
94
93
 
95
94
  module.exports = {
@@ -116,7 +115,7 @@ This handling method also applies to projects with duplicate packages caused by
116
115
  │ │ └── debug -> ../../../node_modules/.pnpm/debug@4.3.4
117
116
  │ ├── src
118
117
  │ │ └── index.js
119
- │ ├── webpack.config.js
118
+ │ ├── rspack.config.js
120
119
  │ └── package.json
121
120
  └── packages
122
121
  └── component
@@ -127,14 +126,14 @@ This handling method also applies to projects with duplicate packages caused by
127
126
  └── package.json
128
127
  ```
129
128
 
130
- In this project, when executing `webpack build` under `apps/web`, the code in the `web` directory will be resolved to `axios@0.27.2_debug@4.3.4`, and then the code in the `packages/component` directory will be resolved to `axios@0.27.2`.
129
+ In this project, when executing `rspack build` under `apps/web`, the code in the `web` directory will be resolved to `axios@0.27.2_debug@4.3.4`, and then the code in the `packages/component` directory will be resolved to `axios@0.27.2`.
131
130
 
132
131
  Although they are the same version, they have different paths, resulting in two copies of `axios` in the output.
133
132
 
134
133
  The solution is to configure the `web` project to only resolve the `axios` package under the `web` directory's `node_modules`.
135
134
 
136
135
  ```javascript
137
- // apps/web/webpack.config.js
136
+ // apps/web/rspack.config.js
138
137
  alias: {
139
138
  'axios': path.resolve(__dirname, 'node_modules/axios')
140
139
  }
@@ -3,7 +3,7 @@
3
3
  import NextSteps from '@components/NextSteps';
4
4
  import Step from '@components/Step';
5
5
 
6
- Optimizing loaders is a common way to improve the performance of Rspack or Webpack compilation. In most cases, besides replacing the loader with a faster one, we can also reduce execution by setting [module.rule.exclude](https://webpack.js.org/configuration/module/#ruleexclude) for the loader.
6
+ Optimizing loaders is a common way to improve the performance of Rspack or webpack compilation. In most cases, besides replacing the loader with a faster one, we can also reduce execution by setting [module.rule.exclude](https://webpack.js.org/configuration/module/#ruleexclude) for the loader.
7
7
 
8
8
  Rsdoctor provides two core modules, [Loader Overall](/guide/usage/loaders-timeline) and [Loader Analysis](/guide/usage/loaders-analysis), to help you optimize based on the loader's invocation information.
9
9
 
@@ -175,7 +175,7 @@ Therefore, **the default configuration enables bundle analysis capabilities and
175
175
 
176
176
  #### RsdoctorWebpackPluginFeatures
177
177
 
178
- `features` type
178
+ `features` type:
179
179
 
180
180
  import Features from '@en/shared/features.md';
181
181
 
@@ -183,7 +183,7 @@ import Features from '@en/shared/features.md';
183
183
 
184
184
  #### RsdoctorRspackPluginFeatures
185
185
 
186
- `features` type
186
+ `features` type:
187
187
 
188
188
  import FeaturesRspack from '@en/shared/features-rspack.md';
189
189
 
@@ -15,7 +15,7 @@ new RsdoctorRspackPlugin({
15
15
  ## Loader time-consuming data is inaccurate?
16
16
 
17
17
  The time-consuming data provided by Rsdoctor for loaders is an **estimated time**. Why can't it accurately measure the timing? It's because we know that loader execution can be both **asynchronous** and **synchronous**.
18
- Additionally, the builder will **parallelize the execution** of multiple non-conflicting loader functions. Since JavaScript is single-threaded, multiple loader functions can **compete for the current task queue**.
18
+ Additionally, the bundler will **parallelize the execution** of multiple non-conflicting loader functions. Since JavaScript is single-threaded, multiple loader functions can **compete for the current task queue**.
19
19
  Furthermore, the asynchronous logic within loader functions cannot be recognized, causing a single loader function to potentially span across the execution of multiple other loaders. As a result, there are three possible cases, as shown in the following diagram:
20
20
 
21
21
  <img
@@ -68,45 +68,3 @@ When using Rsdoctor to analyze the compilation time of Rspack projects, you may
68
68
  - Reason: The loader in [CssExtractRspackPlugin](https://rspack.dev/plugins/rspack/css-extract-rspack-plugin) asynchronously calls other loaders during the pitch phase and waits for the callback results after these loaders execute. Therefore, the time taken by CssExtractRspackPlugin actually includes the execution time of other loaders and idle time.
69
69
 
70
70
  <img src="https://assets.rspack.dev/rsdoctor/css-extract-loader.png" />
71
-
72
- ## Next.js
73
-
74
- ### Issue with Next.js project report page
75
-
76
- Initialize the RsdoctorWebpackPlugin plugin in the [Webpack Config](https://nextjs.org/docs/app/api-reference/next-config-js/webpack) of `next.config.js`.
77
-
78
- However, in Next.js, when Rsdoctor is enabled and the **build command** is executed, the report server started by Rsdoctor will be disconnected. Therefore, if you need to reopen the report, you can use **[@rsdoctor/cli](../start/cli.mdx)** without performing the build operation.
79
-
80
- For example, if the build artifact of Rsdoctor is located at the path `.next/.rsdoctor/manifest.json`, you can open the report page by executing the following command:
81
-
82
- ```bash
83
- npx @rsdoctor/cli analyze --profile .next/.rsdoctor/manifest.json
84
-
85
- ```
86
-
87
- ### Loader analysis with rule override is not supported in Next.js
88
-
89
- - Rsdoctor Loader logic: Since Rsdoctor modifies the Loader Rules, Rsdoctor wraps the Module in a Proxy to support Loader logic with rule override.
90
-
91
- - Next.js specific logic: In Next.js, the LoaderContext adds the currentTraceSpan property, which is obtained from the value retrieved using the Module as the key. However, since Rsdoctor wraps the Module in a Proxy (referred to as ProxyModule), retrieving the value using ProxyModule as the key will result in no value being obtained.
92
-
93
- Based on the above reason, Rsdoctor does not wrap the Module in a Proxy in Next.js projects, which means it does not support Loader analysis with rule override. If you encounter Loader errors, you need to configure the **[features](../../config/options/options#features)** parameter to disable **Loader** analysis. You can use the following configuration:
94
-
95
- ```js title="next.config.js"
96
- const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
97
-
98
- module.exports = {
99
- // ...
100
- webpack: (config, { isServer }) => {
101
- config.plugins.push(
102
- new RsdoctorWebpackPlugin({
103
- // 插件选项
104
- features: ['bundle', 'plugins'],
105
- }),
106
- );
107
- return config;
108
- },
109
- };
110
- ```
111
-
112
- - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
@@ -8,9 +8,9 @@ Please refer to the [Linter Type](#linter-type) in this document for the type de
8
8
 
9
9
  :::
10
10
 
11
- ### [E1001] Duplicate Packages
11
+ ### [E1001] Duplicate packages
12
12
 
13
- #### Rule Details
13
+ #### Rule details
14
14
 
15
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
16
 
@@ -91,13 +91,13 @@ enum CheckVersion {
91
91
  }
92
92
  ```
93
93
 
94
- #### Duplicate Package Optimization Problem
94
+ #### Duplicate package optimization problem
95
95
 
96
96
  Please refer to the [Duplicate Package Optimization Solution](../../blog/topic/duplicate-pkg-problem).
97
97
 
98
98
  Clicking 「**More**」 can view the corresponding rule explanation.
99
99
 
100
- ### [E1002] Cross Chunks Package
100
+ ### [E1002] Cross chunks package
101
101
 
102
102
  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.
103
103
 
@@ -111,7 +111,7 @@ The cross chunks duplicate package rule can scan **duplicate packages in differe
111
111
 
112
112
  Please refer to [[E1002] Cross Chunks Packages](../more/rules)
113
113
 
114
- ### [E1003] Loader Performance Optimization
114
+ ### [E1003] Loader performance optimization
115
115
 
116
116
  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.
117
117
 
@@ -119,7 +119,7 @@ This module allows you to visually see some warning information about our projec
119
119
 
120
120
  Please refer to [[E1003] Loader Performance Optimization](../more/rules)
121
121
 
122
- #### Configuration Type
122
+ #### Configuration type
123
123
 
124
124
  - **ignore**: Can include strings or regular expressions, used to specify the loaders to be ignored.
125
125
  - **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.
@@ -145,7 +145,7 @@ interface Config {
145
145
  }
146
146
  ```
147
147
 
148
- ### [E1004] ECMA Version Check
148
+ ### [E1004] ECMA version check
149
149
 
150
150
  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:
151
151
 
@@ -171,7 +171,7 @@ export default {
171
171
  };
172
172
  ```
173
173
 
174
- #### Type Definitions
174
+ #### Type definitions
175
175
 
176
176
  ```ts
177
177
  type CheckSyntaxOptions = {
@@ -205,7 +205,7 @@ type CheckSyntaxOptions = {
205
205
 
206
206
  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)
207
207
 
208
- ### [E1005] Default Import Check
208
+ ### [E1005] Default import check
209
209
 
210
210
  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.
211
211
 
@@ -224,7 +224,7 @@ interface Config {
224
224
  }
225
225
  ```
226
226
 
227
- ## Linter Type
227
+ ## Linter type
228
228
 
229
229
  - The type definition for the `linter` field is as follows:
230
230
 
@@ -96,7 +96,7 @@ import { execute } from '@rsdoctor/cli';
96
96
 
97
97
  **execute()**
98
98
 
99
- The `execute` asynchronous function is the execution function of Rsdoctor CLI. By calling the `execute` function, it will automatically parse [process.argv](https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processargv) and invoke different commands.
99
+ The `execute` asynchronous function is the execution function of Rsdoctor CLI. By calling the `execute` function, it will automatically parse [process.argv](https://nodejs.org/dist/latest-v22.x/docs/api/process.html#processargv) and invoke different commands.
100
100
 
101
101
  **execute('analyze', \{...\})**
102
102
 
@@ -3,20 +3,20 @@
3
3
  ## 💡 What is Rsdoctor?
4
4
 
5
5
  - Rsdoctor is a one-stop tool for diagnosing and analyzing the build process and build artifacts.
6
- - Rsdoctor is a tool that supports Webpack and Rspack build analysis.
6
+ - Rsdoctor is a tool that supports Rspack and webpack build analysis.
7
7
  - Rsdoctor is an analysis tool that can display the time-consuming and behavioral details of the compilation.
8
- - Rsdoctor is a tool that provides bundle Diff and other anti-degradation capabilities simultaneously.
8
+ - Rsdoctor is a tool that provides bundle diff and other anti-degradation capabilities simultaneously.
9
9
 
10
10
  ## 🔥 Features
11
11
 
12
12
  - **Compilation Visualization**: Rsdoctor visualizes the compilation behavior and time consumption, making it easy to view build issues.
13
13
  - **Multiple Analysis Capabilities**: Rsdoctor supports build artifact, build-time analysis, and anti-degradation capabilities:
14
14
  - Build artifact support for resource lists and module dependencies, etc.
15
- - Build-time analysis supports Loader, Plugin, and Resolver building process analysis, including: Rspack's builtin:swc-loader.
15
+ - Build-time analysis supports Loader, Plugin, and Resolver building process analysis, including Rspack's builtin loaders.
16
16
  - Build rules support duplicate package detection and ES Version Check, etc.
17
- - Currently, bundle Diff capabilities are also available.
17
+ - Currently, bundle diff capabilities are also available.
18
18
  - **Support Custom Rules**: In addition to built-in build scan rules, Rsdoctor also supports users adding custom component scan rules based on the build data of Rsdoctor.
19
- - **Framework-Independent**: Rsdoctor support all projects built on Webpack or Rspack.
19
+ - **Framework-Independent**: Rsdoctor support all projects built on Rspack or webpack.
20
20
 
21
21
  ## 🛠️ Introduction
22
22
 
@@ -36,7 +36,7 @@ Provides corresponding data and analysis functions for **Loaders, Plugins, and M
36
36
 
37
37
  #### Loader analysis
38
38
 
39
- - This module mainly provides the function of data analysis such as input and output, estimated time consumption, and parameters within Rspack / Webpack Loaders.
39
+ - This module mainly provides the function of data analysis such as input and output, estimated time consumption, and parameters within Rspack or webpack loaders.
40
40
 
41
41
  <img
42
42
  src="https://assets.rspack.dev/others/assets/rsdoctor/loader-timeline-overall.png"
@@ -1,4 +1,4 @@
1
- ## Step 2: Register plugin
1
+ ## Step 2: register plugin
2
2
 
3
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
4
 
@@ -75,41 +75,70 @@ export default {
75
75
  - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
76
76
 
77
77
  :::tip
78
- For projects using Modern.js Webpack mode, please register the `RsdoctorWebpackPlugin` plugin through [tools.webpack](https://modernjs.dev/configure/app/tools/webpack).
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
79
  :::
80
80
 
81
81
  ### Next.js Framework
82
82
 
83
- Initialize the RsdoctorWebpackPlugin plugin in the [Webpack Config](https://nextjs.org/docs/app/api-reference/next-config-js/webpack) of `next.config.mjs`.
83
+ Initialize the RsdoctorWebpackPlugin plugin in the [Webpack Config](https://nextjs.org/docs/app/api-reference/next-config-js/webpack) of `next.config.ts`.
84
84
 
85
- ```ts title="next.config.mjs"
85
+ ```ts title="next.config.ts"
86
+ import type { NextConfig } from 'next';
86
87
  import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
87
88
 
88
- export default {
89
- // ...
90
- webpack: (config, { isServer }) => {
91
- config.plugins.push(
92
- new RsdoctorWebpackPlugin({
93
- // plugin options
94
- }),
95
- );
96
-
89
+ const nextConfig: NextConfig = {
90
+ /* config options here */
91
+ webpack: (config) => {
92
+ if (config.name === 'client') {
93
+ config.plugins.push(
94
+ new RsdoctorWebpackPlugin({
95
+ disableClientServer: true,
96
+ }),
97
+ );
98
+ } else if (config.name === 'server') {
99
+ config.plugins.push(
100
+ new RsdoctorWebpackPlugin({
101
+ disableClientServer: true,
102
+ output: {
103
+ reportDir: './.next/server',
104
+ },
105
+ }),
106
+ );
107
+ }
97
108
  return config;
98
109
  },
99
110
  };
111
+
112
+ export default nextConfig;
100
113
  ```
101
114
 
102
- - **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
115
+ - **Options:** The plugin provides some configuration options, please refer to [Options](../../config/options/options).
103
116
 
104
- #### 📢 Next.js project notice
117
+ #### 📢 Note for Next.js Projects
105
118
 
106
- 1. Next.js Project Reporting Page Issues
119
+ Since Next.js closes the terminal service after the `build` execution is completed, the report page server run by Rsdoctor during the build process will also be shut down. At this point, you can reopen the report page using [@rsdoctor/cli](/guide/start/cli) without having to execute the build operation again.
107
120
 
108
- For more details, see: [FAQ](../more/faq#nextjs)
121
+ - First, install [@rsdoctor/cli](/guide/start/cli):
109
122
 
110
- 2. Loader Analysis with Rules Overriding Not Supported in Next.js
123
+ import { PackageManagerTabs } from '@theme';
111
124
 
112
- For more details, see: [FAQ](../more/faq#nextjs)
125
+ <PackageManagerTabs command="add @rsdoctor/cli -D" />
126
+
127
+ - Second, add the following scripts commands to **package.json**, executing **client:rsdoctor** or **server:rsdoctor** can open the report for the corresponding builder:
128
+
129
+ ```ts
130
+ "scripts": {
131
+ "client:rsdoctor": "rsdoctor analyze --profile .next/.rsdoctor/manifest.json",
132
+ "server:rsdoctor": "rsdoctor analyze --profile .next/server/chunks/.rsdoctor/manifest.json"
133
+ }
134
+ ```
135
+
136
+ For example, if Rsdoctor's build artifacts are located at the `.next/server/chunks/.rsdoctor/manifest.json` path, you can open the report page by executing the following command:
137
+
138
+ ```bash
139
+ rsdoctor analyze --profile .next/server/chunks/.rsdoctor/manifest.json
140
+
141
+ ```
113
142
 
114
143
  ### Vue project
115
144
 
@@ -141,7 +170,7 @@ export default defineConfig({
141
170
 
142
171
  ---
143
172
 
144
- ## Step 3: Run build
173
+ ## Step 3: run build
145
174
 
146
175
  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.
147
176
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  This document will explain how to access the Rsdoctor ability.
4
4
 
5
- ## Step 1: Install dependencies
5
+ ## Step 1: install dependencies
6
6
 
7
7
  import { PackageManagerTabs } from '@theme';
8
8
 
@@ -15,10 +15,10 @@ For projects based on Rspack or Rsbuild, install the following dependencies:
15
15
  ### Webpack projects
16
16
 
17
17
  :::tip
18
- Not supported in Webpack 4.
18
+ Rsdoctor only supports webpack >= 5.
19
19
  :::
20
20
 
21
- For projects based on Webpack, install the following dependencies:
21
+ For projects based on webpack, install the following dependencies:
22
22
 
23
23
  <PackageManagerTabs command="add @rsdoctor/webpack-plugin -D" />
24
24
 
@@ -1,4 +1,4 @@
1
- # Bundle Alerts
1
+ # Bundle alerts
2
2
 
3
3
  ## Introduction
4
4
 
@@ -19,13 +19,13 @@ Click on the **"Bundle Size"** option in the navigation bar to view the Bundle a
19
19
 
20
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
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.
22
+ - **`Bundle Size`**: The final packaged size of the resource artifact, which is the final size after being processed by the bundler.
23
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
24
  - **`Package Count`**: The number of third-party packages.
25
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
26
  - For more information about Initial Chunk, please refer to [Initial Chunk Introduction](https://webpack.js.org/concepts/under-the-hood/#chunks).
27
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.
28
+ - **`Concatenated Module`**: A concatenated module is a technique that combines multiple modules into one closure during packaging. In the past, Rspack 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
29
 
30
30
  ## Bundle overview
31
31
 
@@ -82,7 +82,7 @@ The top toolbar from left to right includes: the search tool for **Assets**, the
82
82
 
83
83
  <img src="https://assets.rspack.dev/others/assets/rsdoctor/bundle-size-analysis-selects.png" />
84
84
 
85
- #### Search Module
85
+ #### Search module
86
86
 
87
87
  Search for which Assets the Module is located in. As shown in the figure, you can see the results of matching the search Module keyword.
88
88
 
@@ -91,7 +91,7 @@ Search for which Assets the Module is located in. As shown in the figure, you ca
91
91
  src="https://assets.rspack.dev/others/assets/rsdoctor/search-modules.png"
92
92
  />
93
93
 
94
- #### Search Module
94
+ #### Search module
95
95
 
96
96
  The module search functionality is supported, allowing users to click the "**Search Module**" button to open the module search dialog. By entering the module name, users can quickly locate and view the module's position in the Assets, making it easier to analyze the module's reference relationships and size. The search determines which Assets the Module is located in.
97
97
 
@@ -144,22 +144,22 @@ Click the **"Bundle Analyzer Graph"** button on the **"Bundle Size"** page to vi
144
144
  When enabling the BannerPlugin analysis, do not use Rsdoctor in the production version.
145
145
  :::
146
146
 
147
- 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.
147
+ 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.
148
+
148
149
  The added code segment will affect the analysis capability of the bundle.
149
150
 
150
151
  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:
151
152
 
152
- 1. The project uses the BannerPlugin in `rspack.config.j|ts` or `webpack.config.j|ts`.
153
+ 1. The project uses the BannerPlugin in `rspack.config.(js|ts)` or `webpack.config.(js|ts)`.
153
154
 
154
155
  2. Enable Rsdoctor BannerPlugin capability through Rsdoctor options by setting `supports.banner`:
155
156
 
156
157
  ```ts
157
- new RsdoctorRspackPlugin (
158
+ new RsdoctorRspackPlugin({
158
159
  supports: {
159
- banner: true
160
- }
161
- )
162
-
160
+ banner: true,
161
+ },
162
+ });
163
163
  ```
164
164
 
165
165
  - Note: Enabling `drop_console` will affect Rsdoctor's analysis of the BannerPlugin. Therefore, you can disable `drop_console` when `RSDOCTOR = true`.
@@ -1,4 +1,4 @@
1
- # Compile Alerts
1
+ # Compile alerts
2
2
 
3
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
 
@@ -19,12 +19,12 @@ For each compilation phase, if the time data is displayed in <u>blue</u>, it mea
19
19
 
20
20
  The following table explains the meaning and code implementation of each phase in the card:
21
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> |
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>Reports [process.uptime()](https://nodejs.org/dist/latest-v22.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>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>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>Calculates the sum of the time taken for each call of **compilation.hooks.optimizeChunkAssets** and **compilation.hooks.processAssets**</li></ul> |
28
28
 
29
29
  ## Usage instructions
30
30
 
@@ -56,7 +56,7 @@ Hovering over a data point in the chart will display the following information i
56
56
 
57
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
58
 
59
- ### AfterCompile -> Done details
59
+ ### AfterCompile -> done details
60
60
 
61
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
62
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- In the **Rsdoctor** `Compile Analysis` secondary page `Plugins Analysis`, we can see the invocation data of all **Compiler Hooks** and **Compilation Hooks** used by the current Rspack or Webpack project. The content is shown in the following figure:
5
+ In the **Rsdoctor** `Compile Analysis` secondary page `Plugins Analysis`, we can see the invocation data of all **Compiler Hooks** and **Compilation Hooks** used by the current Rspack or webpack project. The content is shown in the following figure:
6
6
 
7
7
  <img
8
8
  src="https://assets.rspack.dev/others/assets/rsdoctor/plugins-analysis-overall.png"
@@ -29,7 +29,7 @@ The meanings of the fields in the data statistics table on the page are as follo
29
29
 
30
30
  ### View bundler config
31
31
 
32
- If we need to view the Rspack or Webpack configuration of the project, we can click on `View Bundler Config` in the upper right corner of the card. A floating layer will pop up, which contains the serialized **Bundler Config**, as shown in the following figure:
32
+ If we need to view the Rspack or webpack configuration of the project, we can click on `View Bundler Config` in the upper right corner of the card. A floating layer will pop up, which contains the serialized **Bundler Config**, as shown in the following figure:
33
33
 
34
34
  <img
35
35
  src="https://assets.rspack.dev/others/assets/rsdoctor/plugins-analysis-config.png"