Skip to content

[Bug]: Rspack stats reports incorrect chunk information for chunks with dynamically imported JSON files #12173

@cellison-figma

Description

@cellison-figma

System Info

System:
OS: macOS 15.6.1
CPU: (16) arm64 Apple M4 Max
Memory: 157.69 MB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.17.1 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.9.0 - /usr/local/bin/npm
pnpm: 9.15.4 - /usr/local/bin/pnpm
Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 142.0.7444.135
Firefox: 141.0
Safari: 18.6
npmPackages:
@rspack/cli: ^1.1.8 => 1.6.2
@rspack/core: ^1.1.8 => 1.6.2

Details

In the stats report, Rspack appears to use the source JSON file size for dynamically loaded JSON files when calculating the overall chunk size, rather than the processed/minified output size. Due to whitespace stripping, the size of each asset is reduced by 20-30%. This leads to an over-reporting of chunk size in the stats file, despite the asset size data being accurate.

I would expect the size of the built asset to be used in this calculation.

I first noticed this in v1.4.3, but my example uses v1.6.2 and it is still present.

Reproduce link

https://github.com/cellison-figma/rspack-json-size-issue

Reproduce Steps

In the example repo, there are webpack and rspack configs that build the same code. The project imports a 1.3MB file large-data.json, which compresses down to ~1MB.

  1. clone repo & install
  2. run build & analyze scripts
  3. manually verify the chunk associated with large-data.json in rspack.stats.json claims a size of 1.3MB
  4. manually verify the chunk associated with large-data.json in webpack.stats.json claims a size of 1MB
  5. note that the compressed asset for large-data.json in each build (in dist-webpack and dist-rspack) does not exceed 1MB in size, and the total size of all built code is well below 1.3MB

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending triageThe issue/PR is currently untouched.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions