> For AI agents: the complete documentation index is available at https://rsdoctor.rs/llms.txt, the full documentation bundle is available at https://rsdoctor.rs/llms-full.txt.

# Bundle analysis

:::info
If you want to analyze the reference chain of a specific Module, you can check 👉🏻 [Module Analysis](https://rsdoctor.rs/guide/usage/module-analysis.md).
:::

## ⭐️ Overview

**Rsdoctor** provides the `Bundle Size` module for analyzing build artifacts, including **resource sizes**, **duplicate packages**, and **module relationships**:

- **Bundle Overview**: Displays the total number of artifacts, the number and size of each file type, as well as duplicate packages and their reference chains, 👉🏻 [**Bundle Overview**](#-bundle-overview).
- **Bundle Analysis (`Bundle Analysis`) Module**: Analyzes the size and code information of the build artifacts (**Assets**) and the included **Modules**. In this module, you can view the **actual code size of modules after packaging** in the Assets, the original code of modules, **packaged code segments**, and **module reference relationships**.

The **Bundle Analysis** displays two view modes, **Tree Map** and **Tree Graph**:

- 👉🏻 [**Tree Map**](https://rsdoctor.rs/guide/usage/bundle-size.md#-tree-map)

Tree Map is a classic build artifact analysis view that helps developers visualize and analyze the composition of bundles more intuitively, as well as the proportion of resources (Assets) and modules (Modules). It also supports searching for module resources, and clicking on module resources can zoom in to that module area.

![](https://assets.rspack.rs/others/assets/rsdoctor/treemap-intro.gif)
- 👉🏻 [**Tree Graph**](https://rsdoctor.rs/guide/usage/bundle-size.md#-tree-graph)

Tree Graph is a **file tree-based** build artifact analysis view that helps developers visualize and analyze the composition of artifacts more intuitively, as well as the proportion of artifacts (Assets) and modules (Modules). It also supports searching for module resources, and clicking on modules can view module details and code.

![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-overall.png)
## 🪐 Glossary

- **`Assets`**: Resources are files that ultimately exist in the output folder, including JavaScript, CSS, images, fonts, media, and other file types. Each Chunk has corresponding [Assets resources](https://rspack.rs/misc/glossary#asset).
- **`Module`**: Multiple Modules combine to form a Chunk. For more information about Module types, please refer to [Rspack Modules](https://rspack.rs/misc/glossary#module-type).
- **`Source Size`**: The original size of the file, before any transformations and minification.
- **`Bundle Size`**: The final output size of the files. If you enabled minification, this value shows the minified size.
- **`Gzip Size`**: The size of the file after gzip compression.
- **`Package Count`**: The number of third-party packages.
- **`Initial Chunk`**: **initial (initialization)** is the main Chunk of the entry point. This Chunk contains all the modules specified by the entry point and their dependencies, unlike the **Chunk** resources for "**on-demand loading**".
  - For more information about Initial Chunk, please refer to [Initial Chunk Introduction](https://rspack.rs/misc/glossary#initial-chunk).
- **`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](https://rsdoctor.rs/guide/usage/bundle-alerts.md).
- **`Concatenated Module`**: A concatenated module is a technique that combines multiple modules into one closure during packaging. Wrapping each module in a separate function adds runtime overhead in the browser. Optimization can be achieved by enabling the [`optimization.concatenateModules`](https://rspack.rs/misc/glossary#scope-hoisting) parameter.

## 🪐 Bundle overview

### Bundle information card

The bundle overview displays information about the number and size of files, such as `Total Files`. Clicking on the card expands the resource details, as shown in the following image:

![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-overall-1.png)
- Clicking on the details icon displays the corresponding resource tree on the right, indicating the resource sizes:

![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-tree.png)
- 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.

### Duplicate packages

- 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.

For more information, please refer to [Duplicate Packages](https://rsdoctor.rs/guide/usage/bundle-alerts.md).

## 🪐 Tree map

:::info
If module sizes or code are missing, see the troubleshooting steps in the [FAQ](https://rsdoctor.rs/guide/more/faq.md#no-bundledparsed-size-for-modules-in-bundle-analysis).
:::

Tree Map view can intuitively display the proportion and relationship between modules, as shown in the following image. Clicking on module resources can zoom in to that module area.

![](https://assets.rspack.rs/others/assets/rsdoctor/treemap-intro.gif)
- Tree Map view also supports searching for module resources. The left sidebar can filter resources (Assets) and search for modules (Modules). Clicking on the search results for modules can zoom in to that module area.

![](https://assets.rspack.rs/others/assets/rsdoctor/treemap-all.png)
- Double-clicking on a block can display its Module details card, as shown in the following image. For more information, see [Module Details](https://rsdoctor.rs/guide/usage/module-analysis.md).

![](https://assets.rspack.rs/others/assets/rsdoctor/treemap-dbclick.png)
## 🪐 Tree graph

:::info
If module sizes or code are missing, see the troubleshooting steps in the [FAQ](https://rsdoctor.rs/guide/more/faq.md#no-bundledparsed-size-for-modules-in-bundle-analysis).
:::

Tree Graph is a **file tree-based** build artifact analysis view used to analyze the size and code information of build artifact resources (**Assets**) and the included **Modules**. In this module, you can view the **actual code size of modules after packaging** in the Assets, the original code of modules, **packaged code segments**, and **module reference relationships**.

![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-overall.png)
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](https://rsdoctor.rs/config/options/options.md).

### Resource and module relationship display

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:

- 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.
- On the right side is the list of **Modules** corresponding to the **Assets**, also sorted in descending order by module size after packaging.

![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-analysis-tree.png)
### Search and filter box

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.

- **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**.
- **Search Assets Input Box**: Enter the keyword of an **Assets** in the input box to search for the corresponding **Assets**.
- **Assets Size Filter Tool**: Enter a number with units of KB or MB to filter out **Assets** resources smaller than the specified size.
- **Module Size Filter Tool**: Enter a number with units of KB or MB to filter out **Module** resources smaller than the specified size.

![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-analysis-selects.png)
### Search module

Module search functionality is supported. Users can 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.

As shown in the following image, the results of matching the search Module keyword can be seen:

![](https://assets.rspack.rs/others/assets/rsdoctor/search-modules.png)
### Module tag explanation

The **Assets** tag is shown in the left image, from left to right representing: **Resource Size**, **[Initial Chunk](https://rspack.rs/misc/glossary#initial-chunk)**, and **Code View**.


![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-assets-tags.png)![](https://assets.rspack.rs/others/assets/rsdoctor/bundle-size-modules-tags.png)

The **Modules** tag is shown in the right image, from left to right representing:

- **Bundled Size**
  - 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.
- **[Concatenated Module](https://rspack.rs/misc/glossary#scope-hoisting)**: Concatenated modules combine multiple modules into one closure during bundling. There are two types:
  - One is the concatenated main module, indicating how many `Modules` are concatenated.
  - The other is a sub-module, labeled with the concatenated module it belongs to.
- **Module Explorer** tag: Click to open the dependency analysis page between `Modules`.
- **Code View** tag: Click to expand code segments, including `Source` (source code), `Transformed` (compiled code), and `Bundled` (bundled code).

### Support for concatenated module analysis

A **[concatenated module](https://rspack.rs/misc/glossary#scope-hoisting)** combines several modules into a single closure. These modules can come from different packages. This is especially relevant for projects with [chunk splitting disabled](https://rsbuild.rs/config/split-chunks#disable-chunk-splitting).

Rsdoctor calculates the bundled size of each sub-module after tree shaking. This helps you see which modules contribute to the final bundle, understand the effect of module concatenation, and refine your code splitting strategy.

Rsdoctor 2.x automatically enables Rspack's native analysis plugin to collect the source map data it needs.

Concatenated module analysis does not support `eval` or `eval-*` values for `devtool`. Use a non-eval option such as `source-map`.

> The images below compare the same bundle before and after support for concatenated module analysis was added.

- Before: sub-module sizes are unavailable

![](https://assets.rspack.rs/others/assets/rsdoctor/all-in-one-before.png)
- After: sub-module sizes are displayed

![](https://assets.rspack.rs/others/assets/rsdoctor/all-in-one-after.png)
## 🪐 Module details

Click the module tag to view module details, as shown below:

![](https://assets.rspack.rs/others/assets/rsdoctor/bailout-reason.gif)
- **Reasons**: As the name suggests, it means the \[reason] why a Module exists. Reasons indicate which Modules import this Module, and the entire Reasons Tree shows the upstream reference chain of this Module, including both direct and indirect parents. This corresponds to Rspack's stats.reasons.
- **Dependencies**: The Modules that this Module depends on.
- **Bailout Reason**: The reason why this Module failed Tree Shaking.

> For more details, see: [Module details](https://rsdoctor.rs/guide/usage/module-analysis.md)
