PolicyEngine / PolicyEngine/policyengine-app-v2

Add bundle-size budget check to CI

Open
#997 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
HTML
Stars
1
Forks
3
Avg merge
1d 50m
Merged PRs (30d)
39

Description

Summary

The repo has no bundle-size budget or regression test in CI. The Vercel previews show size only on click-through; contributors have no automated warning when a commit fattens the bundle, and no historical size trend for comparison.

What goes wrong

  • Unnecessary imports (e.g., rehype-raw was carried as a dep after PR #992 stopped using it; react-plotly.js lingers pending migration in #669; react-syntax-highlighter lingers pending #773) accumulate silently.
  • Large dependencies can be added to package.json without any indicator of their bundle impact.
  • Route-level code splitting regressions (e.g., a shared chunk suddenly containing a 500 KB vendor blob) are caught only during live slow-load reports from users.

Related active issues that would benefit from this (making them observable and prioritizable):

  • #669 — Remove react-plotly.js
  • #773 — Replace react-syntax-highlighter with Prism

Suggested fix

Add one or both:

  1. Bundle-size budget CI check using size-limit or @next/bundle-analyzer:
# .github/workflows/pr.yaml (new job)
bundle-size:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v4
    - uses: oven-sh/setup-bun@v2
    - run: bun install --frozen-lockfile
    - run: bun run build
    - uses: andresz1/size-limit-action@v1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}

…with per-route budgets in size-limit.config.js.

  1. Lighthouse CI on the Vercel preview URL for perf + bundle metrics, posting a PR comment with the deltas.

Start with budgets based on current sizes (First Load JS per route from next build output); ratchet down over time.

Severity

Low — nice-to-have, becomes higher ROI once #669 / #773 / MarkdownFormatter dedupe (#990) land and you want to lock in the wins.

Relates to

#669, #773, #990.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading .github/workflows/pr.yaml and the build scripts in package.json, then inspect the First Load JS sizes reported by next build. The issue suggests either a size-budget check with size-limit.config.js or Lighthouse CI, so first determine which approach fits the existing workflow. Done means CI reports bundle-size changes against defined per-route budgets.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, github-actions, javascript, next.js
Domain
ci-cd, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.