Skip to content

chore(pwa): offline shell bundle budget check (#50) - #94

Merged
devudilip merged 2 commits into
mainfrom
chore/bundle-budget
Sep 16, 2026
Merged

devudilip merged 2 commits into
mainfrom
chore/bundle-budget

Conversation

@devudilip

@devudilip devudilip commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Linked issue

Closes #50 (accepted).

What changed and why

npm run check:bundle measures what the service worker precaches as the app shell — every PRECACHE_SHELL route's HTML, the /_next/static scripts, styles and fonts those pages reference, the manifest and its icons — from the static export, prints a table by group, and compares the total with a budget (default 2 MB, --budget <bytes>). Pure parsing and summing live in scripts/lib/bundle.ts with 9 unit tests. CI runs the check after the build.

Measured today: JS chunks 977 KB, HTML 743 KB, fonts 338 KB, CSS 55 KB, icons 43 KB — 2,159 KB against a 2,048 KB budget, about 5 % over. The check therefore warns (exit 0) rather than fails until the owner decides whether to raise the budget or trim: the two ~128 KB font subsets and the shared JS chunks are the first candidates.

Checklist

  • npm run typecheck clean
  • npm test green (671)
  • next build green; check run against the real export
  • No new dependencies; no runtime fetch; no corpus change
  • DCO sign-off

Update (owner decision)

Owner asked that not everything be precached: only core routes are installed offline, and every other page is cached the first time it is opened (the navigation handler already does this). Shell dropped from 2,159 KB to 1,757 KB, so the check now fails CI when over the 2 MB budget. Tests 671 green, typecheck clean.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 16, 2026

Copy link
Copy Markdown

Deploying sirigannada with  Cloudflare Pages  Cloudflare Pages

Latest commit: efa9aae
Status: ✅  Deploy successful!
Preview URL: https://2e21b676.sirigannada.pages.dev
Branch Preview URL: https://chore-bundle-budget.sirigannada.pages.dev

View logs

scripts/check-bundle.ts sums the precached shell (routes, their
/_next/static assets, manifest, icons) from the static export and prints
a table; CI runs it after the build. The shell measures 2.16 MB today,
about 5 % over, so the check warns rather than fails until the owner
picks a budget or trims fonts and JS.

Signed-off-by: Devu Dilip <devu.dilip@gmail.com>
… budget (#50)

The install shell had grown to 2,159 KB. Precaching now covers the core
routes only (home, dictionary, library, proverbs, collections, practice,
games, the stories and picture-book hubs, More, offline manager); about,
credits, contact, tools and learn pages are cached on first visit by the
navigation handler, so recently opened pages keep working offline and the
rest need the network once. Shell is 1,757 KB; the check now fails CI.

Signed-off-by: Devu Dilip <devu.dilip@gmail.com>
@devudilip
devudilip merged commit 95ca92a into main Sep 16, 2026
5 checks passed
@devudilip
devudilip deleted the chore/bundle-budget branch September 16, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A-07: Bundle size for TWA/offline: confirm total shell + fonts < 2 MB; dictionary shards fetched on demand

1 participant