This project demonstrates a bug in Rspack where chunk sizes are incorrectly calculated for dynamically imported JSON files.
When dynamically importing large JSON files, Rspack reports the source JSON file size as the chunk size, rather than the processed/minified output size. This causes chunk sizes to appear 20-30% larger than they actually are.
- Chunk size ≈ Asset size (within a few hundred bytes)
- Represents the actual bundled output size
- Chunk size ≈ Source JSON file size
- Does not account for JSON→JS transformation and minification
- Can be 20-30% larger than the actual asset size
-
Install dependencies:
pnpm install
-
Build with both bundlers:
pnpm build
-
Analyze the results:
pnpm analyze
You should see output similar to:
WEBPACK:
Chunk ID: 123
Chunk Size: 245,123 bytes
Asset Size: 245,280 bytes
Difference: 157 bytes (0.06%)
✅ Chunk size matches asset size
RSPACK:
Chunk ID: 456
Chunk Size: 312,456 bytes ← Source JSON size!
Asset Size: 245,897 bytes ← Actual output size
Difference: 66,559 bytes (27.07%)
❌ LARGE DISCREPANCY! Chunk size doesn't match asset size
src/index.js- Entry point with dynamic JSON importsrc/large-data.json- Generated ~300KB JSON file for examplewebpack.config.js- Webpack configurationrspack.config.js- Rspack configuration (same settings as webpack)analyze.js- Script to compare chunk sizes between bundlers
This bug affects:
- Bundle size analysis and monitoring
- Size budget enforcement
- Performance optimization decisions
- Stats-based tooling
The actual asset size is correct; only the chunk size metric is wrong.