-
-
Notifications
You must be signed in to change notification settings - Fork 783
Description
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.
- clone repo & install
- run build & analyze scripts
- manually verify the chunk associated with
large-data.jsoninrspack.stats.jsonclaims a size of 1.3MB - manually verify the chunk associated with
large-data.jsoninwebpack.stats.jsonclaims a size of 1MB - note that the compressed asset for
large-data.jsonin each build (indist-webpackanddist-rspack) does not exceed 1MB in size, and the total size of all built code is well below 1.3MB