Repository navigation
ci: enforce a 250 KB gzip JS budget per page - #10
TheSeydiCharyyev merged 3 commits into
Conversation
66831db to
95e3d8d
Compare
TheSeydiCharyyev
left a comment
There was a problem hiding this comment.
Checked 87644c8 locally and in CI. The table matches my build (173.21 / 173.54 KB), the 100 KB commit is red, the 250 KB head is green, and the step runs before the upload. Good.
Two things before merge:
-
A missing script is counted as 0 KB (
getGzipSizecatches the error and returns 0). I deleted one 28.9 KB chunk that/loads and ran the script: it printed 165.78 KB for/and exited with code 0. A budget check must not pass with a lower number when a file is missing. Please remove the try/catch there, and if a/_next/file that a page references does not exist, print the page and the file and exit with code 1. Also matchsrc.startsWith('/_next/')instead ofsrc.includes('/_next/'), so a full URL is never mapped to a local path. -
Please remove
"start": "next start"frompackage.json. It is not part of #6, and it does not work with our static export:npm startfails with"next start" does not work with "output: export" configuration.
Small thing: deploy.yml now ends with a line of spaces and no newline. Please remove that line.
|
All three points addressed in the new commit:
|
TheSeydiCharyyev
left a comment
There was a problem hiding this comment.
Checked 7703086. I deleted the same 28.9 KB chunk again: the script now marks every page with "1 missing", lists page -> file, and exits with code 1. On a normal build it passes with 173.21 / 173.54 KB. next start is gone and deploy.yml ends with one newline. CI is green.
Tiny and optional: "scripts": { in package.json is indented with 4 spaces, the rest of the file uses 2.
Closes #6 (hard CI budget for JS shipped per page).
What changed
scripts/check-size.mjs— new CI script, Node built-ins only (node:fs,node:zlib,node:path), zero new dependencies.index.htmlinout/.<script src="/_next/…">the page loads (deduped).zlib.gzipSyncsizes of those files and prints a per-page table (page, KB gzip).LIMIT_KBat the top of the file.package.json— adds"check:size": "node scripts/check-size.mjs"..github/workflows/deploy.yml— runsnpm run check:sizeafternpm run buildand the store-pages check, beforeupload-pages-artifact. An over-budget build fails thebuildjob and never reaches deployment; every PR tomaingets the check.Current numbers (static export, Next.js 16.3.6)
//ru//en//projects//ru/projects//en/projects//404/,/_not-found/All pages are ~174 KB today, so the 250 KB budget passes with ~76 KB of headroom for the upcoming animations work.
Proof the check actually fails
95e3d8dsetsLIMIT_KB = 100→ its CI run is red: all 8 pages (~173 KB) exceed the budget and thebuildjob fails at the "Check bundle size limit" step.87644e8restoresLIMIT_KB = 250→ CI is green again.Both runs are visible in the Checks timeline and in the Actions tab.
Why
Internet in Turkmenistan is slow and expensive. The old site shipped ~3 KB of JS; the Next.js migration took that to ~174 KB per page. A hard, CI-enforced budget prevents further silent growth (animations are next).