next.js
5394d39a - [Turbopack] write route bundle stats to .next/diagnostics/route-bundle-stats.json (#90949)

Commit
6 days ago
[Turbopack] write route bundle stats to .next/diagnostics/route-bundle-stats.json (#90949) After a successful, Turbopack production build, this writes `.next/diagnostics/route-bundle-stats.json` containing First Load JS stats for every route. ## Why? We used to have route bundle size statistics print after every build. It was not very high-signal and could be misleading, often using heuristics to give a best-effort estimate of what sizes may be at runtime. **These kinds of metrics for route bundle sizes can be misleading, as pages can be slow to visual/interactive completeness even if they have small first load bytes.** However, a minimal gauge of how much JavaScript a route ships during initial page load can be a useful signal so long as users have additional context and awareness of their app structure. Let's provide just this number for now for those that could benefit. Additionally, this does so in the form of writing a json document to the build directory, rather than writing a table to stdout, where users have needed to write extra tools to parse. ## Format An array of route entries sorted descending by `firstLoadUncompressedJsBytes`: ```json [ { "route": "/blog/[slug]", "firstLoadUncompressedJsBytes": 124928, "firstLoadChunkPaths": [ ".next/static/chunks/framework.js", ".next/static/chunks/main.js", ".next/static/chunks/pages/blog/[slug].js" ] } ] ``` `firstLoadUncompressedJsBytes`: sum of uncompressed sizes of all JS chunks loaded on first navigation to the route (shared chunks included), for both Pages Router and App Router `firstLoadChunkPaths`: paths to those chunks relative to the project root ## Test Plan Added an integration test. Built with a create-next-app and verified the json document is written and the numbers align with what Chrome reports during initial load of a page.
Author
Parents
Loading