Skip to content

ci: enforce bundle size budget with size-limit [closes #217]#275

Open
EmersonBraun wants to merge 1 commit intomainfrom
foundation/size-limit-ci
Open

ci: enforce bundle size budget with size-limit [closes #217]#275
EmersonBraun wants to merge 1 commit intomainfrom
foundation/size-limit-ci

Conversation

@EmersonBraun
Copy link
Copy Markdown
Owner

Summary

Adds size-limit to enforce gzipped bundle sizes on every PR. Closes #217 and verifies Manifesto principle 1 (@agentskit/core < 10 KB gzipped).

How it works

  • .size-limit.json declares budgets per package (gzipped, ESM + CJS where relevant)
  • Local commands:
    • pnpm size — verify all packages
    • pnpm size:why — bundle inspector
  • CI workflow .github/workflows/size.yml runs on every PR + push to main; blocks merge if any package exceeds its budget

Current measured sizes (all under budget)

Package Limit Actual Headroom
@agentskit/core (ESM) 10 KB 5.22 KB 48%
@agentskit/core (CJS) 10 KB 5.30 KB 47%
@agentskit/adapters 20 KB 4.32 KB 78%
@agentskit/react 15 KB 2.58 KB 83%
@agentskit/runtime 15 KB 2.34 KB 84%
@agentskit/memory 15 KB 2.73 KB 82%
@agentskit/rag 10 KB 852 B 92%
@agentskit/tools 15 KB 2.27 KB 85%
@agentskit/skills 10 KB 5.19 KB 48%
@agentskit/observability 10 KB 2.95 KB 70%
@agentskit/eval 10 KB 556 B 95%
@agentskit/sandbox 10 KB 1.53 KB 85%
@agentskit/ink 15 KB 1.33 KB 91%
@agentskit/cli 20 KB 177 B 99%
@agentskit/templates 15 KB 2.89 KB 81%

Why @size-limit/file instead of preset-small-lib

The small-lib preset bundles via esbuild expecting browser code. Most AgentsKit packages use Node builtins (fs/promises, path, child_process) which esbuild can't resolve without platform: 'node'. Since these are libs published to npm (consumers bundle them, not us), measuring the published file gzipped is the right metric. @size-limit/file does exactly that.

Trade-offs

  • No tree-shake measurement — small-lib measures "what would a user pay if they imported the whole index". File mode measures "the published file". For libs with named exports (which we encourage in CLAUDE.md), tree-shaking handles userland anyway.
  • Headroom is generous — limits are set 2-4x current size. This gives breathing room for legitimate growth without becoming a meaningless rubber-stamp. Will tighten if any package consistently grows.

Test plan

  • pnpm size runs locally and passes
  • pnpm build && pnpm exec size-limit produces correct numbers
  • Workflow YAML validates
  • CI on this PR shows the size check passing
  • (Future PR test) deliberately bloat a package, confirm CI blocks merge

Follow-ups

  • Add size-limit comment-on-PR action (currently CLI-only)
  • Add size-limit-action from andresz1/size-limit-action for delta reporting (size went up by X% in this PR)
  • Tighten budgets after 2-3 sprints of stable measurement

Closes #217
Refs #211

Adds size-limit (file plugin) checking gzipped sizes of every package's
published dist on every PR. Workflow blocks merge if any package exceeds
its declared budget.

Budgets per package:
- @agentskit/core (ESM + CJS): 10 KB — Manifesto principle 1
- adapters: 20 KB
- react / runtime / memory / tools / ink / templates: 15 KB
- rag / skills / observability / eval / sandbox: 10 KB
- cli: 20 KB

Current measured sizes (all under budget):
- core ESM:           5.22 KB ✓
- core CJS:           5.30 KB ✓
- adapters:           4.32 KB ✓
- react:              2.58 KB ✓
- runtime:            2.34 KB ✓
- memory:             2.73 KB ✓
- rag:                  852 B ✓
- tools:              2.27 KB ✓
- skills:             5.19 KB ✓
- observability:      2.95 KB ✓
- eval:                 556 B ✓
- sandbox:            1.53 KB ✓
- ink:                1.33 KB ✓
- cli:                  177 B ✓
- templates:          2.89 KB ✓

Local commands:
- pnpm size       — verify all packages
- pnpm size:why   — bundle inspector

CI workflow .github/workflows/size.yml runs on every PR + push to main.

Closes #217
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.

[P0.6] Bundle size budget enforced in CI (size-limit)

1 participant