Skip to content

ci(core): bundle-size gate for every export entry - #372

Merged
lorant-one merged 3 commits into
feat/3-0-breaking-cleanupfrom
feat/bundle-size-gate
Oct 31, 2026
Merged

lorant-one merged 3 commits into
feat/3-0-breaking-cleanupfrom
feat/bundle-size-gate

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Before: nothing measured what an import of core costs, so a component that started pulling in half the library would go unnoticed.

After: CI measures every entry point in exports, gzipped, and fails when one grows more than 5% and 512 B past packages/core/bundle-size.json. That covers 98 entries, including the new ./components/<Name> subpaths from #358, plus css/styles.css and css/tokens.css. Current largest:

.                         170.7 KB
./emoji                    88.0 KB
./mdx                      84.7 KB
./data                     80.0 KB
./components/DateInput     60.7 KB
./components/DatePicker    59.6 KB
./components/Table         57.2 KB
./components/User          51.6 KB

How: scripts/bundle-size.mjs bundles each entry with esbuild the way an app's bundler would:

  • minified;
  • the package's own dependencies included, peers (react, next, recharts, maplibre-gl…) left external;
  • the CSS from CSS modules counted alongside the JS.

A new or removed entry also fails the check until it is recorded. When an entry is meant to grow, run node scripts/bundle-size.mjs --update in the same PR, so the size change shows in the diff.

It runs as one step in the existing "Build, typecheck and test" job, after the build it already does. It takes about 4 s and needs no new job, so it costs almost no extra CI minutes. [email protected] is a new devDependency but was already in the lockfile.

Checked: --update then a check run locally gives "every entry is within 5%". Biome is clean.


Generated by Claude Code

scripts/bundle-size.mjs bundles each JS entry in core's exports (98 of
them, the per-component subpaths included) the way an app would:
minified, peers external, CSS modules counted. It also measures the two
stylesheets, gzipped. Sizes are compared with bundle-size.json, and the
step fails when an entry grows by more than 5% and 512 B. Record an
intended growth with --update. It runs as a step in the existing build
job and takes a few seconds. esbuild 0.27.7 is already in the lockfile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YJHdG7ZbpQS64MtL5PVbT1

Copy link
Copy Markdown
Member Author

Docs build fails here on /form-controls/datePicker (React #418). This PR didn't cause it. The failure reproduces on the base branch: a DatePicker with no date hydrates the build's month against the check's clock, 25 hours later, and that clock has crossed into November. The fix is #376. Once it merges, I'll merge the base branch into this PR so CI re-runs.


Generated by Claude Code

…chunks

Bundled without splitting, esbuild inlines each import() into the entry,
so the gate counted Icon's lazy tooltip card in every component that
draws an icon. With splitting, an entry costs itself and the chunks it
imports statically. Re-recorded on the 3.0 branch with #374 in it:
Button 35.3 -> 24.1 KB, Icon 31.3 -> 19.8 KB, ./code 49.0 -> 25.0 KB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YJHdG7ZbpQS64MtL5PVbT1
@lorant-one
lorant-one merged commit 5159d7c into feat/3-0-breaking-cleanup Oct 31, 2026
8 checks passed
@lorant-one
lorant-one deleted the feat/bundle-size-gate branch October 31, 2026 21:34
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.

2 participants