@rsdoctor/docs 0.0.1
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/_meta.json +17 -0
- package/docs/en/blog/_meta.json +12 -0
- package/docs/en/blog/release/_meta.json +1 -0
- package/docs/en/blog/release/release-note-1.mdx +129 -0
- package/docs/en/blog/topic/_meta.json +1 -0
- package/docs/en/blog/topic/duplicate-pkg-problem.mdx +141 -0
- package/docs/en/blog/topic/loader-optimization.mdx +80 -0
- package/docs/en/config/_meta.json +7 -0
- package/docs/en/config/options/_meta.json +1 -0
- package/docs/en/config/options/options.mdx +135 -0
- package/docs/en/config/options/term.mdx +10 -0
- package/docs/en/guide/_meta.json +17 -0
- package/docs/en/guide/more/_meta.json +1 -0
- package/docs/en/guide/more/faq.mdx +104 -0
- package/docs/en/guide/more/rules.mdx +5 -0
- package/docs/en/guide/start/_meta.json +1 -0
- package/docs/en/guide/start/cli.mdx +94 -0
- package/docs/en/guide/start/features.mdx +36 -0
- package/docs/en/guide/start/intro.mdx +115 -0
- package/docs/en/guide/start/quick-start.mdx +210 -0
- package/docs/en/guide/usage/_meta.json +13 -0
- package/docs/en/guide/usage/bundle-alerts.mdx +47 -0
- package/docs/en/guide/usage/bundle-overall.mdx +55 -0
- package/docs/en/guide/usage/bundle-size.mdx +122 -0
- package/docs/en/guide/usage/compile-alerts.mdx +18 -0
- package/docs/en/guide/usage/compile-overall.mdx +115 -0
- package/docs/en/guide/usage/loaders-analysis.mdx +72 -0
- package/docs/en/guide/usage/loaders-timeline.mdx +68 -0
- package/docs/en/guide/usage/module-analysis.mdx +58 -0
- package/docs/en/guide/usage/plugins-analysis.mdx +43 -0
- package/docs/en/guide/usage/project-overall.mdx +51 -0
- package/docs/en/guide/usage/resolver.mdx +29 -0
- package/docs/en/index.md +38 -0
- package/docs/zh/_meta.json +17 -0
- package/docs/zh/blog/_meta.json +12 -0
- package/docs/zh/blog/release/_meta.json +1 -0
- package/docs/zh/blog/release/release-note-1.mdx +128 -0
- package/docs/zh/blog/topic/_meta.json +1 -0
- package/docs/zh/blog/topic/duplicate-pkg-problem.mdx +138 -0
- package/docs/zh/blog/topic/loader-optimization.mdx +80 -0
- package/docs/zh/config/_meta.json +7 -0
- package/docs/zh/config/options/_meta.json +1 -0
- package/docs/zh/config/options/options.mdx +138 -0
- package/docs/zh/config/options/term.mdx +10 -0
- package/docs/zh/guide/_meta.json +17 -0
- package/docs/zh/guide/more/_meta.json +1 -0
- package/docs/zh/guide/more/faq.mdx +102 -0
- package/docs/zh/guide/more/rules.mdx +5 -0
- package/docs/zh/guide/start/_meta.json +1 -0
- package/docs/zh/guide/start/cli.mdx +94 -0
- package/docs/zh/guide/start/features.mdx +36 -0
- package/docs/zh/guide/start/intro.mdx +116 -0
- package/docs/zh/guide/start/quick-start.mdx +209 -0
- package/docs/zh/guide/usage/_meta.json +13 -0
- package/docs/zh/guide/usage/bundle-alerts.mdx +49 -0
- package/docs/zh/guide/usage/bundle-overall.mdx +57 -0
- package/docs/zh/guide/usage/bundle-size.mdx +122 -0
- package/docs/zh/guide/usage/compile-alerts.mdx +18 -0
- package/docs/zh/guide/usage/compile-overall.mdx +115 -0
- package/docs/zh/guide/usage/loaders-analysis.mdx +73 -0
- package/docs/zh/guide/usage/loaders-timeline.mdx +68 -0
- package/docs/zh/guide/usage/module-analysis.mdx +59 -0
- package/docs/zh/guide/usage/plugins-analysis.mdx +43 -0
- package/docs/zh/guide/usage/project-overall.mdx +51 -0
- package/docs/zh/guide/usage/resolver.mdx +29 -0
- package/docs/zh/index.md +38 -0
- package/docs/zh/shared/features-rspack.md +24 -0
- package/docs/zh/shared/features.md +29 -0
- package/package.json +44 -0
- package/src/components/NextSteps.module.scss +6 -0
- package/src/components/NextSteps.tsx +7 -0
- package/src/components/Overview.module.scss +61 -0
- package/src/components/Overview.tsx +40 -0
- package/src/components/RuleIndex.module.scss +57 -0
- package/src/components/RuleIndex.tsx +75 -0
- package/src/components/Step.module.scss +32 -0
- package/src/components/Step.tsx +13 -0
- package/src/global.d.ts +4 -0
- package/src/utils.ts +9 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# FAQ
|
|
2
|
+
|
|
3
|
+
## How to use only a specific feature of Rsdoctor?
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
9
|
+
|
|
10
|
+
new RsdoctorWebpackPlugin({
|
|
11
|
+
features: ['bundle'], // Represents enabling only the bundle size analysis feature
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Loader time-consuming data is inaccurate?
|
|
16
|
+
|
|
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**.
|
|
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
|
+
|
|
21
|
+
<img
|
|
22
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/compile/loader-cases.jpeg"
|
|
23
|
+
style={{ width: '250px' }}
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
Therefore, the loader timing provided by Rsdoctor is an **estimate**. The timing data we provide is adapted to handle Case 1 and Case 2 from the diagram. As for Case 3, we are still exploring solutions.
|
|
27
|
+
|
|
28
|
+
## `out of memory` error when using `Rsdoctor` for building
|
|
29
|
+
|
|
30
|
+
If you encounter an `out of memory` error, you can try the following two methods, with the first one being recommended:
|
|
31
|
+
|
|
32
|
+
### Method 1
|
|
33
|
+
|
|
34
|
+
Increase the memory limit of Node, for example: NODE_OPTIONS=--max-old-space-size=8096.
|
|
35
|
+
|
|
36
|
+
### Method 2
|
|
37
|
+
|
|
38
|
+
You can add the `lite` field to the `features` array to use the lite mode. Additionally, since the `features` array overrides the default configuration when it is an array, you should:
|
|
39
|
+
|
|
40
|
+
- Add `loader` and `plugins` to the `features` array if you need build-time analysis to enable the analysis of loader and plugin timings.
|
|
41
|
+
|
|
42
|
+
- Add `bundle` to the `features` array if you need bundle analysis to enable the analysis of build artifacts.
|
|
43
|
+
|
|
44
|
+
The following example enables the lite mode, build-time analysis, and bundle analysis:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
48
|
+
|
|
49
|
+
// adding the plugin to your configuration
|
|
50
|
+
module.exports = {
|
|
51
|
+
// ...
|
|
52
|
+
plugins: [
|
|
53
|
+
new RsdoctorWebpackPlugin({
|
|
54
|
+
disableClientServer: false,
|
|
55
|
+
features: ['lite', 'loader', 'plugins', 'bundle'],
|
|
56
|
+
}),
|
|
57
|
+
].filter(Boolean),
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- Cause: During the build process, the source code information is stored, which exceeds the memory limit. Enabling the `lite` mode can alleviate this issue.
|
|
62
|
+
- Difference: The difference between the **lite mode** and the **normal mode** is that the **lite mode** no longer stores the **source code information**, only the **bundled code** is stored. Additionally, the code displayed in the analysis report will only consist of the **bundled code**.
|
|
63
|
+
|
|
64
|
+
## Next.js
|
|
65
|
+
|
|
66
|
+
### Issue with Next.js project report page
|
|
67
|
+
|
|
68
|
+
Initialize the RsdoctorWebpackPlugin plugin in the [Webpack Config](https://nextjs.org/docs/app/api-reference/next-config-js/webpack) of `next.config.js`.
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
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:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx @rsdoctor/cli analyze --profile .next/.rsdoctor/manifest.json
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Loader analysis with rule override is not supported in Next.js
|
|
80
|
+
|
|
81
|
+
- Rsdoctor Loader logic: Since Rsdoctor modifies the Loader Rules, Rsdoctor wraps the Module in a Proxy to support Loader logic with rule override.
|
|
82
|
+
|
|
83
|
+
- 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.
|
|
84
|
+
|
|
85
|
+
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:
|
|
86
|
+
|
|
87
|
+
```js title="next.config.js"
|
|
88
|
+
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
// ...
|
|
92
|
+
webpack: (config, { isServer }) => {
|
|
93
|
+
config.plugins.push(
|
|
94
|
+
new RsdoctorWebpackPlugin({
|
|
95
|
+
// 插件选项
|
|
96
|
+
features: ['bundle', 'plugins'],
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
return config;
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["intro", "quick-start", "features", "cli"]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# CLI Tutorial
|
|
2
|
+
|
|
3
|
+
We provide `@rsdoctor/cli` for you to use Rsdoctor's features locally through the CLI program.
|
|
4
|
+
|
|
5
|
+
:::tip
|
|
6
|
+
`@rsdoctor/webpack-plugin`, `@rsdoctor/rspack-plugin`, and `@rsdoctor/cli` should have the same major and minor versions.
|
|
7
|
+
:::
|
|
8
|
+
|
|
9
|
+
## Install @rsdoctor/cli
|
|
10
|
+
|
|
11
|
+
:::tip
|
|
12
|
+
|
|
13
|
+
- @rsdoctor/cli & @rsdoctor/webpack-plugin & @rsdoctor/rspack-plugin >= 0.1.3.
|
|
14
|
+
- You can also use the non-installation method by using the `npx @rsdoctor/cli <command> [options]` command.
|
|
15
|
+
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
import { PackageManagerTabs } from '@theme';
|
|
19
|
+
|
|
20
|
+
import { Tab, Tabs } from 'rspress/theme';
|
|
21
|
+
|
|
22
|
+
<PackageManagerTabs command="add @rsdoctor/cli -D" />
|
|
23
|
+
|
|
24
|
+
## Command Usage
|
|
25
|
+
|
|
26
|
+
```linux
|
|
27
|
+
|
|
28
|
+
rsdoctor <command> [options]
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`@rsdoctor/cli` currently provides the following commands for different functionalities:
|
|
33
|
+
|
|
34
|
+
### analyze Command
|
|
35
|
+
|
|
36
|
+
The `analyze` command is mainly used to load the [manifest.json](../../config/options/term.mdx) file locally and start Rsdoctor's analysis report page without the need to rebuild.
|
|
37
|
+
|
|
38
|
+
```linux
|
|
39
|
+
rsdoctor analyze --profile <manifestFile>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Parameter Definition**
|
|
43
|
+
|
|
44
|
+
- `manifestFile` is the path to the [manifest.json](../../config/options/term.mdx) file (supports local path)
|
|
45
|
+
|
|
46
|
+
**Usage Example**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
rsdoctor analyze --profile "./dist/.rsdoctor/manifest.json"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Node API
|
|
53
|
+
|
|
54
|
+
We provide a Node.js API in `@rsdoctor/cli` that allows you to make calls during runtime in Node.js.
|
|
55
|
+
|
|
56
|
+
**Importing the Module**
|
|
57
|
+
|
|
58
|
+
<Tabs>
|
|
59
|
+
|
|
60
|
+
<Tab label="cjs">
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const { execute } = require('@rsdoctor/cli');
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
</Tab>
|
|
67
|
+
|
|
68
|
+
<Tab label="esm">
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import { execute } from '@rsdoctor/cli';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
</Tab>
|
|
75
|
+
|
|
76
|
+
</Tabs>
|
|
77
|
+
|
|
78
|
+
**execute()**
|
|
79
|
+
|
|
80
|
+
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.
|
|
81
|
+
|
|
82
|
+
**execute('analyze', \{...\})**
|
|
83
|
+
|
|
84
|
+
If you need to directly execute the [analyze command](#analyze-command) through the Node.js API, you can call it as follows:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
execute('analyze', {
|
|
88
|
+
profile: 'input the manifest.json path or url',
|
|
89
|
+
}).then((sdk) => {
|
|
90
|
+
console.log('execute "anaylze" command success');
|
|
91
|
+
// you can stop the Rsdoctor's dev-server by calling the sdk'api below:
|
|
92
|
+
// sdk.dispose();
|
|
93
|
+
});
|
|
94
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Features
|
|
2
|
+
|
|
3
|
+
Here you can learn about the main features supported by Rsdoctor.
|
|
4
|
+
|
|
5
|
+
## Build Overview
|
|
6
|
+
|
|
7
|
+
| Feature | Description | Related Links |
|
|
8
|
+
| -------------------- | ---------------------------------------------------------------------- | -------------------------------------------- |
|
|
9
|
+
| Project Overview | View information such as the current project configuration and version | [Project Overall](../usage/project-overall) |
|
|
10
|
+
| Bundle Overview | View information about the artifacts built for the current project | [Bundle Overall](../usage/bundle-overall) |
|
|
11
|
+
| Compilation Overview | View data information about the current project's compilation process | [Compile Overall](../usage/compile-overall) |
|
|
12
|
+
| Bundle Alert | The ability to perform detection based on build artifact data | [Bundle Alert](../usage/bundle-alerts) |
|
|
13
|
+
| Compilation Alert | The ability to perform detection based on compilation data | [Compilation Alert](../usage/compile-alerts) |
|
|
14
|
+
|
|
15
|
+
## Compilation Analysis
|
|
16
|
+
|
|
17
|
+
| Feature | Description | Related Links |
|
|
18
|
+
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
19
|
+
| Compilation Overview | View data information about the current project's compilation process | [Compile Overall](../usage/compile-overall) |
|
|
20
|
+
| Compilation Alert | The ability to perform detection based on compilation data | [Compilation Alert](../usage/compile-alerts) |
|
|
21
|
+
| Loader Compilation Behavior Analysis | Loader analysis data in directory and file dimensions, displaying the compilation behavior of a single file at the same time | [Loaders Analysis](../usage/loaders-analysis) |
|
|
22
|
+
| Loader Time Consumption Analysis | Execution sequence diagram of all Loaders in the current project | [Loaders Timeline](../usage/loaders-timeline) |
|
|
23
|
+
| Plugins Analysis | Data analysis of the plugins used in the project | [Plugins Analysis](../usage/plugins-analysis) |
|
|
24
|
+
| Resolver Analysis | Analysis data on Resolver parsing capabilities | [Resolver Analysis](../usage/resolver) |
|
|
25
|
+
| Loader Time Consumption Analysis and Optimization | This document describes how to use Rsdoctor to analyze and optimize build time consumption | [Loader Analysis and Optimization](../../blog/topic/loader-optimization) |
|
|
26
|
+
|
|
27
|
+
## Bundle Analysis
|
|
28
|
+
|
|
29
|
+
| Feature | Description | Related Links |
|
|
30
|
+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
|
|
31
|
+
| Bundle Overview | View information about the artifacts built for the current project | [Bundle Overall](../usage/bundle-overall) |
|
|
32
|
+
| Bundle Alert | The ability to perform detection based on build artifact data | [Bundle Alert](../usage/bundle-alerts) |
|
|
33
|
+
| Bundle Analysis | Analysis of the relationships between assets, chunks, and modules in the artifact, as well as the packaged code and size analysis of each module, etc. | [Bundle Analysis](../usage/bundle-size) |
|
|
34
|
+
| Module Analysis | Analysis of module dependencies | [Modules Dependency Analysis](../usage/module-analysis) |
|
|
35
|
+
| Duplicate Packages Optimization | Inspection of duplicate dependencies used in the project | [Duplicate Packages Optimization](../../blog/topic/duplicate-pkg-problem) |
|
|
36
|
+
| Bundle Diff | Comparative analysis of two artifacts | Planned support |
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
## 💡 What is Rsdoctor?
|
|
4
|
+
|
|
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.
|
|
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.
|
|
9
|
+
|
|
10
|
+
## 🔥 Features
|
|
11
|
+
|
|
12
|
+
- **Compilation Visualization**: Rsdoctor visualizes the compilation behavior and time consumption, making it easy to view build issues.
|
|
13
|
+
- **Multiple Analysis Capabilities**: Rsdoctor supports build artifact, build-time analysis, and anti-degradation capabilities:
|
|
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.
|
|
16
|
+
- Build rules support duplicate package detection and ES Version Check, etc.
|
|
17
|
+
- Currently, bundle Diff capabilities are also available.
|
|
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.
|
|
20
|
+
|
|
21
|
+
## 🛠️ Introduction
|
|
22
|
+
|
|
23
|
+
### ⭐️ Overview
|
|
24
|
+
|
|
25
|
+
- The overview page (i.e. the home page) can know **project configuration, diagnostic information, compilation information, and product status**.
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
- In addition to the project overview, we also provide diagnostic functions, including compilation diagnostics and duplicate packages diagnostics. If your compilation and products hit the diagnostic rules we defined,
|
|
30
|
+
the corresponding warning alerts will appear on the tool's home page. **where you can see the detailed reference path of duplicate packages**:
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
### ⭐️ Compilation Analysis
|
|
35
|
+
|
|
36
|
+
Provides corresponding data and analysis functions for **Loaders, Plugins, and Module Resolve** to help you analyze problems in the compilation process.
|
|
37
|
+
|
|
38
|
+
#### Loader Analysis
|
|
39
|
+
|
|
40
|
+
- This module mainly provides the function of data analysis such as input and output, estimated time consumption, and parameters within Rspack / Webpack Loaders.
|
|
41
|
+
|
|
42
|
+
<div style={{ display: 'flex' }}>
|
|
43
|
+
<img
|
|
44
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/compile/loader-timeline-overall.png"
|
|
45
|
+
width="55%"
|
|
46
|
+
style={{ margin: 'auto' }}
|
|
47
|
+
/>
|
|
48
|
+
<img
|
|
49
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/compile/loader-anlaysis-all.png"
|
|
50
|
+
width="45%"
|
|
51
|
+
style={{ margin: 'auto' }}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
#### Plugin Analysis
|
|
56
|
+
|
|
57
|
+
- This module mainly intercepts and collects data information such as the number of calls and estimated time consumption of Plugins.
|
|
58
|
+
|
|
59
|
+
<p>
|
|
60
|
+
<img
|
|
61
|
+
alt="bundle"
|
|
62
|
+
src={
|
|
63
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/start/compile-plugin.jpg'
|
|
64
|
+
}
|
|
65
|
+
width="600px"
|
|
66
|
+
style={{ margin: 'auto' }}
|
|
67
|
+
/>
|
|
68
|
+
</p>
|
|
69
|
+
|
|
70
|
+
#### Resolve Analysis
|
|
71
|
+
|
|
72
|
+
- This module mainly provides path data and estimated time consumption for module resolution in a single file within the project. Rspack does not currently support this module.
|
|
73
|
+
|
|
74
|
+
<p>
|
|
75
|
+
<img
|
|
76
|
+
alt="bundle"
|
|
77
|
+
src={
|
|
78
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/start/resolver.jpeg'
|
|
79
|
+
}
|
|
80
|
+
width="700px"
|
|
81
|
+
style={{ margin: 'auto' }}
|
|
82
|
+
/>
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
### ⭐️ Product Analysis
|
|
86
|
+
|
|
87
|
+
- In the **Bundle Size** page, we can see an overview of the product data information of the current project, as well as analyze the size and reasons for duplicate package imports.
|
|
88
|
+
|
|
89
|
+
- In addition, we can also use the **Bundle Analysis** page to further analyze the relationship between the product and module in the current product, size data and other information, as well as the reasons for module introduction.
|
|
90
|
+
|
|
91
|
+
<p>
|
|
92
|
+
<img
|
|
93
|
+
alt="bundle"
|
|
94
|
+
src={
|
|
95
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/start/bundle-size.jpg'
|
|
96
|
+
}
|
|
97
|
+
width="700px"
|
|
98
|
+
style={{ margin: 'auto' }}
|
|
99
|
+
/>
|
|
100
|
+
</p>
|
|
101
|
+
|
|
102
|
+
### ⭐️ Bundle Diff
|
|
103
|
+
|
|
104
|
+
::: tip
|
|
105
|
+
Support in progress...
|
|
106
|
+
:::
|
|
107
|
+
|
|
108
|
+
Using the bundle diff function provided by Rsdoctor, you can see the changes in **the size of resources, duplicate packages, Packages and other data in the product**, as well as **the size of module files and code changes in each resource**.
|
|
109
|
+
|
|
110
|
+
|  |  |
|
|
111
|
+
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
112
|
+
|
|
113
|
+
## 🧑💻 Community
|
|
114
|
+
|
|
115
|
+
Come and chat with us on [Discord](https://discord.gg/wrBPBT6rkM)! The Rsdoctor team and users are active there, and we're always looking for contributions.
|
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
## Step 2: Register Plugin
|
|
28
|
+
|
|
29
|
+
After the dependency installation, you need to integrate the Rsdoctor plugin into your project. Below are some examples of common tools and frameworks:
|
|
30
|
+
|
|
31
|
+
### Rspack
|
|
32
|
+
|
|
33
|
+
Initialize the RsdoctorRspackPlugin in the [plugins](https://www.rspack.dev/config/plugins.html#plugins) of `rspack.config.js`:
|
|
34
|
+
|
|
35
|
+
```js title="rspack.config.js"
|
|
36
|
+
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
// ...
|
|
40
|
+
plugins: [
|
|
41
|
+
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
|
|
42
|
+
process.env.RSDOCTOR &&
|
|
43
|
+
new RsdoctorRspackPlugin({
|
|
44
|
+
// plugin options
|
|
45
|
+
}),
|
|
46
|
+
].filter(Boolean),
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
51
|
+
|
|
52
|
+
### Rsbuild
|
|
53
|
+
|
|
54
|
+
Initialize the RsdoctorRspackPlugin in the [tools.rspack](https://rsbuild.dev/config/tools/rspack) of `rsbuild.config.ts`:
|
|
55
|
+
|
|
56
|
+
```js title="rsbuild.config.ts"
|
|
57
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
// ...
|
|
61
|
+
tools: {
|
|
62
|
+
rspack(config, { appendPlugins }) {
|
|
63
|
+
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
|
|
64
|
+
if (process.env.RSDOCTOR) {
|
|
65
|
+
appendPlugins(
|
|
66
|
+
new RsdoctorRspackPlugin({
|
|
67
|
+
// plugin options
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
77
|
+
|
|
78
|
+
### Webpack
|
|
79
|
+
|
|
80
|
+
Initialize the RsdoctorWebpackPlugin in the [plugins](https://webpack.js.org/configuration/plugins/#plugins) of `webpack.config.js`:
|
|
81
|
+
|
|
82
|
+
```js title="webpack.config.js"
|
|
83
|
+
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
84
|
+
|
|
85
|
+
module.exports = {
|
|
86
|
+
// ...
|
|
87
|
+
plugins: [
|
|
88
|
+
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
|
|
89
|
+
process.env.RSDOCTOR &&
|
|
90
|
+
new RsdoctorWebpackPlugin({
|
|
91
|
+
// plugin options
|
|
92
|
+
}),
|
|
93
|
+
].filter(Boolean),
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
98
|
+
|
|
99
|
+
### Modern.js Framework
|
|
100
|
+
|
|
101
|
+
Initialize the plugin in the [tools.rspack](https://modernjs.dev/configure/app/tools/rspack) of `modern.config.ts`:
|
|
102
|
+
|
|
103
|
+
```ts title="modern.config.ts"
|
|
104
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
105
|
+
|
|
106
|
+
export default {
|
|
107
|
+
// ...
|
|
108
|
+
tools: {
|
|
109
|
+
rspack(config, { appendPlugins }) {
|
|
110
|
+
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
|
|
111
|
+
if (process.env.RSDOCTOR) {
|
|
112
|
+
appendPlugins(
|
|
113
|
+
new RsdoctorRspackPlugin({
|
|
114
|
+
// plugin options
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
124
|
+
|
|
125
|
+
:::tip
|
|
126
|
+
For projects using Modern.js Webpack mode, please register the `RsdoctorWebpackPlugin` plugin through [tools.webpack](https://modernjs.dev/configure/app/tools/webpack).
|
|
127
|
+
:::
|
|
128
|
+
|
|
129
|
+
### Next.js Framework
|
|
130
|
+
|
|
131
|
+
Initialize the RsdoctorWebpackPlugin plugin in the [Webpack Config](https://nextjs.org/docs/app/api-reference/next-config-js/webpack) of `next.config.mjs`.
|
|
132
|
+
|
|
133
|
+
```ts title="next.config.mjs"
|
|
134
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
135
|
+
|
|
136
|
+
export default {
|
|
137
|
+
// ...
|
|
138
|
+
webpack: (config, { isServer }) => {
|
|
139
|
+
config.plugins.push(
|
|
140
|
+
new RsdoctorWebpackPlugin({
|
|
141
|
+
// plugin options
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return config;
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
151
|
+
|
|
152
|
+
#### 📢 Next.js Project Notice
|
|
153
|
+
|
|
154
|
+
1. Next.js Project Reporting Page Issues
|
|
155
|
+
|
|
156
|
+
For more details, see: [FAQ](../more/faq#nextjs)
|
|
157
|
+
|
|
158
|
+
2. Loader Analysis with Rules Overriding Not Supported in Next.js
|
|
159
|
+
|
|
160
|
+
For more details, see: [FAQ](../more/faq#nextjs)
|
|
161
|
+
|
|
162
|
+
### Vue Framework
|
|
163
|
+
|
|
164
|
+
Initialize the `@rsdoctor/webpack-plugin` or `@rsdoctor/rspack-plugin` plugin in the configuration file. Here is an example using `rsbuild`:
|
|
165
|
+
|
|
166
|
+
```ts title="rsbuild.config.ts"
|
|
167
|
+
import { defineConfig } from '@rsbuild/core';
|
|
168
|
+
import { pluginVue } from '@rsbuild/plugin-vue';
|
|
169
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
170
|
+
|
|
171
|
+
export default defineConfig({
|
|
172
|
+
plugins: [pluginVue()],
|
|
173
|
+
performance: {
|
|
174
|
+
buildCache: false,
|
|
175
|
+
},
|
|
176
|
+
tools: {
|
|
177
|
+
bundlerChain: (chain, { CHAIN_ID }) => {
|
|
178
|
+
chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
|
|
179
|
+
{
|
|
180
|
+
// plugin options
|
|
181
|
+
},
|
|
182
|
+
]);
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- **Options:** The plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
189
|
+
|
|
190
|
+
#### 📢 Vue Project Notice
|
|
191
|
+
|
|
192
|
+
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.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Step 3: Run Build
|
|
197
|
+
|
|
198
|
+
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.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Enable Rsdoctor
|
|
202
|
+
RSDOCTOR=true npm run build
|
|
203
|
+
|
|
204
|
+
# Disable Rsdoctor
|
|
205
|
+
npm run build
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
:::tip
|
|
209
|
+
The Rsdoctor plugin provides some configurations, please refer to [Options](../../config/options/options).
|
|
210
|
+
:::
|
|
@@ -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.
|