Skip to content

Migrate from bundlesize to size-limit#516

Merged
erikras merged 6 commits into
mainfrom
migrate-to-size-limit
Feb 11, 2026
Merged

Migrate from bundlesize to size-limit#516
erikras merged 6 commits into
mainfrom
migrate-to-size-limit

Conversation

@erikras-richard-agent

@erikras-richard-agent erikras-richard-agent commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Problem

bundlesize depends on iltorb which fails to compile on modern Node versions and is no longer maintained.

Solution

Replace with size-limit which is actively maintained and doesn't have native dependencies.

Changes

  • ❌ Remove: bundlesize (depends on unmaintained iltorb)
  • ✅ Add: @size-limit/preset-small-lib and size-limit
  • ✅ Configure: Track 4 build outputs with 3kB limits each:
    • dist/final-form.umd.min.js
    • dist/final-form.umd.js
    • dist/final-form.es.js
    • dist/final-form.cjs.js

Follows

Same pattern as react-final-form #1056

Part of

🎯 OSS-28: Migrate all libraries from bundlesize to size-limit

Summary by CodeRabbit

  • Chores

    • Enforced per-file bundle size limits for published builds and adopted size-limit tooling.
    • Replaced previous bundle-size tooling and added a CI job to check bundle sizes during workflow runs.
    • Standardized CI to use Node.js 22 and raised the minimum supported Node.js engine to >=18.
  • Bug Fixes

    • Added a default field comparison function to improve field change-detection behavior.

Replace bundlesize with size-limit to resolve iltorb compilation issues.

- Remove: bundlesize (depends on unmaintained iltorb)
- Add: @size-limit/preset-small-lib and size-limit
- Configure: Track 4 build outputs (umd.min, umd, es, cjs) with 3kB limits

This follows the same pattern as react-final-form #1056.

Part of OSS-28: Migrate all libraries from bundlesize to size-limit
@coderabbitai

coderabbitai Bot commented Feb 10, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces bundlesize with size-limit, bumps Node engine to >=18, adds size-limit bundle limits for four outputs, updates GitHub Actions to use checkout@v4 and setup-node@v4 with Node 22 and a new "Bundle Size Check" job, and sets a default isEqual (strict ===) on fields in src/FinalForm.ts.

Changes

Cohort / File(s) Summary
Package manifest
package.json
Removed bundlesize; added @size-limit/preset-small-lib and size-limit; bumped engines.node to >=18; added top-level size-limit array declaring four outputs with limits: dist/final-form.umd.min.js (7kB), dist/final-form.umd.js (7kB), dist/final-form.es.js (6kB), dist/final-form.cjs.js (6kB).
CI workflow
.github/workflows/ci.yml
Upgraded actions to actions/checkout@v4 and actions/setup-node@v4; standardized Node to 22 (removed matrix); added new "Bundle Size Check" job that checks out, sets up Node 22, installs (yarn --frozen-lockfile --ignore-scripts), builds (yarn start build), and runs npx size-limit.
Source change
src/FinalForm.ts
During registerField, initialize each field with a default isEqual set to strict equality (===) so fields always have an isEqual function.

Sequence Diagram(s)

sequenceDiagram
  participant GH as "GitHub Actions"
  participant Runner as "Runner"
  participant Repo as "Repository"
  participant Node as "Node.js (22)"
  participant Build as "Build (yarn)"
  participant Size as "size-limit"

  GH->>Runner: trigger workflow (push/PR)
  Runner->>Repo: checkout (actions/checkout@v4)
  Runner->>Node: setup Node.js 22 (actions/setup-node@v4)
  Runner->>Repo: install deps (yarn --frozen-lockfile --ignore-scripts)
  Runner->>Build: run yarn start build
  Build-->>Runner: produce dist/ artifacts
  Runner->>Size: run npx size-limit
  Size-->>Runner: report pass/fail
  Runner-->>GH: report job status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudged the package under moonlit rim,
swapped bundlesize for size-limit on a whim.
Four tiny bundles snug and measured neat,
CI weighs their coats with steps both short and fleet.
Fields now hop along with a simple "===" — vim!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Migrate from bundlesize to size-limit' directly and clearly describes the main change in the changeset, which replaces the bundlesize dependency and tooling with size-limit across package.json and CI configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch migrate-to-size-limit

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 104-120: Add execution of the size-limit check to CI so the
"size-limit" entries in package.json are enforced: update the CI workflow (e.g.,
.github/workflows/ci.yml) to run the size check by adding a new job or step that
runs `yarn size-limit` (or `npx size-limit`) after build/pack steps, or append
`yarn size-limit` to the existing validation/test job; ensure the step runs in
the same environment that has the built artifacts (so run after the build step)
and fails the job on non-zero exit so bundle size limits defined under
"size-limit" are enforced.
- Around line 68-70: The package.json declares engines.node as ">=8" which is
incompatible with [email protected] (requires ^18.0.0 || >=20.0.0); update the
engines.node field in package.json to ">=18" (or ">=18 || >=20" / "^18.0.0 ||
>=20.0.0") to match [email protected], or alternatively downgrade the
"size-limit" and "@size-limit/preset-small-lib" dependencies to a version that
supports Node 8; modify the "engines.node" entry accordingly and keep references
to "size-limit" and "@size-limit/preset-small-lib" consistent with the chosen
approach.

Comment thread package.json
Comment thread package.json
1. Update Node version requirement to >=18 (size-limit requires ^18.0.0 || >=20.0.0)
2. Add size-limit check to CI workflow
   - New 'size' job that builds and runs size-limit
   - Ensures bundle size limits are enforced in CI
@erikras-richard-agent

Copy link
Copy Markdown
Contributor Author

✅ Addressed CodeRabbit feedback

1. Node version requirement

  • Updated engines.node from >=8 to >=18
  • Matches size-limit's requirement of ^18.0.0 || >=20.0.0

2. CI enforcement

  • Added new size job to CI workflow
  • Builds the package and runs npx size-limit
  • Ensures bundle size limits are enforced on every push

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 58-62: Update the workflow to use the latest action versions and
remove the undefined matrix reference: replace actions/checkout@v2 with
actions/checkout@v4 and actions/setup-node@v2 with actions/setup-node@v4;
replace the step name that contains `${{ matrix.node_version }}` with a static
name like "Use Node.js 22" (or alternatively add a matrix.strategy.node_version
if you intend to run multiple versions) and ensure the setup-node step uses a
concrete node-version value (e.g., 22); apply the same changes to the lint,
prettier, test, and size jobs so they all reference actions/checkout and
actions/setup-node v4 and no undefined matrix variable in step names.

Comment thread .github/workflows/ci.yml
The field object literal was missing the isEqual property in its
initial definition, causing TypeScript to fail when it was assigned later.

Add isEqual: tripleEquals to the initial field object to match the
InternalFieldState type.

Fixes TypeScript compilation broken by #480.
@erikras-richard-agent

Copy link
Copy Markdown
Contributor Author

🔧 Fixed TypeScript Error

CI was failing due to a TypeScript error introduced by PR #480 (isEqual). This was breaking all new PRs, not just this one.

Fix: Cherry-picked the fix from PR #517 which adds isEqual: tripleEquals to the initial field object.

CI should now pass. ✅

Current bundle sizes (brotli compressed):
- umd.min: ~6 kB (limit: 7kB with headroom)
- umd: ~6 kB (limit: 7kB with headroom)
- es: ~5.5 kB (limit: 6kB with headroom)
- cjs: ~5.75 kB (limit: 6kB with headroom)

Limits set with ~1kB headroom to catch regressions.
@erikras-richard-agent

Copy link
Copy Markdown
Contributor Author

CodeRabbit feedback addressed

Fixed GitHub Actions workflow per your review:

  • Updated actions/checkout from v2 to v4
  • Updated actions/setup-node from v2 to v4
  • Removed undefined matrix.node_version references
  • All step names now use static "Node.js 22"

CI re-running now!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)

11-17: 🧹 Nitpick | 🔵 Trivial

Reduce CI drift by extracting the repeated setup steps.

The first three steps are identical across lint/prettier/test/size; consider YAML anchors or a reusable workflow to keep them in sync.

Also applies to: 26-32, 41-47, 58-65

🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 63-64: Update the "Prepare env" step in the size GitHub Actions
job to add the missing --ignore-scripts flag so it matches the other jobs;
locate the step named "Prepare env" that currently runs yarn install
--frozen-lockfile and change it to include --ignore-scripts to prevent
package.json lifecycle scripts (e.g., prepare) from running during the size job.

Comment thread .github/workflows/ci.yml
coderabbitai[bot]
coderabbitai Bot previously approved these changes Feb 10, 2026
@erikras-richard-agent

Copy link
Copy Markdown
Contributor Author

CodeRabbit feedback addressed

Added --ignore-scripts flag to size job's yarn install command.

Commit 8ae7bf4. Ready for re-review!

Resolved yarn.lock conflict by accepting upstream changes.
@erikras-dinesh-agent

Copy link
Copy Markdown
Contributor

✅ Merge conflict resolved. Merged latest main and resolved yarn.lock conflict.

@erikras
erikras merged commit a5e2981 into main Feb 11, 2026
4 of 5 checks passed
@erikras
erikras deleted the migrate-to-size-limit branch February 11, 2026 07:00
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.

3 participants