Skip to content

Implement bundle size CI check #2146

@AbanoubGhadban

Description

@AbanoubGhadban

Overview

Add CI check that monitors bundle sizes of the npm packages and fails if they have a significant increase in size compared to the base branch.

Implementation

Implemented in PR #2149 with the following features:

CI Workflow (.github/workflows/bundle-size.yml)

  • Triggers on PRs that modify packages/**, package.json, pnpm-lock.yaml, or .size-limit.json
  • Compares PR bundle sizes against the base branch
  • Fails if any package increases by more than 0.5KB (configurable threshold)
  • Posts a size report comment on the PR via size-limit-action

What Gets Measured

  • react-on-rails: Raw, gzip, and brotli compressed sizes
  • react-on-rails-pro: Raw, gzip, and brotli compressed sizes
  • react-on-rails-pro-node-renderer: Raw, gzip, and brotli compressed sizes
  • Webpack bundled imports: Client-side bundle sizes when importing packages via webpack

Local Tools

  • pnpm run size - Check current bundle sizes
  • bin/compare-bundle-sizes - Compare your branch against master locally
  • bin/skip-bundle-size-check - Bypass the CI check for intentional size increases

Configuration Files

  • .size-limit.json - size-limit configuration defining what to measure
  • .bundle-size-skip-branch - Contains branch name to skip the size check
  • scripts/bundle-size.mjs - Utility script for setting dynamic limits and comparing sizes

Documentation

  • Added "Bundle Size Checks" section to CONTRIBUTING.md
  • Added CHANGELOG entry

Related PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions