Skip to content

[code-infra] Add bundle size monitor #1791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Apr 28, 2025

Porting the bundle size monitor from core. This establishes a baseline. This bundles each entrypoint with its dependencies. Bundles are stored in S3 for comparison. Peer dependencies are ignored. To inspect the created bundles run

pnpm size:why

examples:

Screenshot 2025-05-09 at 10 06 31

Screenshot 2025-05-15 at 15 01 28

Copy link

netlify bot commented Apr 28, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 60edf24
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6836fa8955028800080be00e
😎 Deploy Preview https://deploy-preview-1791--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mui-bot
Copy link

mui-bot commented Apr 28, 2025

Bundle size report

🚫 No bundle size snapshot found for base commit d27e8c2.

Total Size Change: +1.34MB(0.00%) - Total Gzip Change: +455KB(0.00%)
Files: 40 total (40 added, 0 removed, 0 changed)

@base-ui-components/reactparsed:${\tiny{\color{orangered}▲}}$+292KB(new) gzip:${\tiny{\color{orangered}▲}}$+88.3KB(new)
@base-ui-components/react/menuparsed:${\tiny{\color{orangered}▲}}$+114KB(new) gzip:${\tiny{\color{orangered}▲}}$+37.6KB(new)
@base-ui-components/react/context-menuparsed:${\tiny{\color{orangered}▲}}$+112KB(new) gzip:${\tiny{\color{orangered}▲}}$+36.6KB(new)
@base-ui-components/react/selectparsed:${\tiny{\color{orangered}▲}}$+110KB(new) gzip:${\tiny{\color{orangered}▲}}$+36.8KB(new)
@base-ui-components/react/popoverparsed:${\tiny{\color{orangered}▲}}$+85.6KB(new) gzip:${\tiny{\color{orangered}▲}}$+28.8KB(new)
@base-ui-components/react/tooltipparsed:${\tiny{\color{orangered}▲}}$+63.3KB(new) gzip:${\tiny{\color{orangered}▲}}$+21.4KB(new)
@base-ui-components/react/preview-cardparsed:${\tiny{\color{orangered}▲}}$+58.6KB(new) gzip:${\tiny{\color{orangered}▲}}$+19.9KB(new)
@base-ui-components/react/dialogparsed:${\tiny{\color{orangered}▲}}$+52.2KB(new) gzip:${\tiny{\color{orangered}▲}}$+17.5KB(new)
@base-ui-components/react/alert-dialogparsed:${\tiny{\color{orangered}▲}}$+51.9KB(new) gzip:${\tiny{\color{orangered}▲}}$+17.4KB(new)
@base-ui-components/react/number-fieldparsed:${\tiny{\color{orangered}▲}}$+28.8KB(new) gzip:${\tiny{\color{orangered}▲}}$+10.3KB(new)

Show 30 more bundle changes

@base-ui-components/react/tabsparsed:${\tiny{\color{orangered}▲}}$+26.5KB(new) gzip:${\tiny{\color{orangered}▲}}$+9.15KB(new)
@base-ui-components/react/toastparsed:${\tiny{\color{orangered}▲}}$+26.4KB(new) gzip:${\tiny{\color{orangered}▲}}$+9.5KB(new)
@base-ui-components/react/sliderparsed:${\tiny{\color{orangered}▲}}$+24.5KB(new) gzip:${\tiny{\color{orangered}▲}}$+9.2KB(new)
@base-ui-components/react/accordionparsed:${\tiny{\color{orangered}▲}}$+23.1KB(new) gzip:${\tiny{\color{orangered}▲}}$+7.98KB(new)
@base-ui-components/react/radio-groupparsed:${\tiny{\color{orangered}▲}}$+20.3KB(new) gzip:${\tiny{\color{orangered}▲}}$+7.74KB(new)
@base-ui-components/react/menubarparsed:${\tiny{\color{orangered}▲}}$+19.6KB(new) gzip:${\tiny{\color{orangered}▲}}$+7.34KB(new)
@base-ui-components/react/toolbarparsed:${\tiny{\color{orangered}▲}}$+19.6KB(new) gzip:${\tiny{\color{orangered}▲}}$+6.84KB(new)
Base UI checkboxparsed:${\tiny{\color{orangered}▲}}$+18.4KB(new) gzip:${\tiny{\color{orangered}▲}}$+6.91KB(new)
@base-ui-components/react/checkboxparsed:${\tiny{\color{orangered}▲}}$+18.4KB(new) gzip:${\tiny{\color{orangered}▲}}$+6.91KB(new)
@base-ui-components/react/collapsibleparsed:${\tiny{\color{orangered}▲}}$+18.1KB(new) gzip:${\tiny{\color{orangered}▲}}$+6.28KB(new)
@base-ui-components/react/scroll-areaparsed:${\tiny{\color{orangered}▲}}$+15.8KB(new) gzip:${\tiny{\color{orangered}▲}}$+5.63KB(new)
@base-ui-components/react/radioparsed:${\tiny{\color{orangered}▲}}$+15KB(new) gzip:${\tiny{\color{orangered}▲}}$+5.7KB(new)
@base-ui-components/react/switchparsed:${\tiny{\color{orangered}▲}}$+14.5KB(new) gzip:${\tiny{\color{orangered}▲}}$+5.57KB(new)
@base-ui-components/react/toggle-groupparsed:${\tiny{\color{orangered}▲}}$+13.8KB(new) gzip:${\tiny{\color{orangered}▲}}$+5.36KB(new)
@base-ui-components/react/fieldparsed:${\tiny{\color{orangered}▲}}$+13.7KB(new) gzip:${\tiny{\color{orangered}▲}}$+5.26KB(new)
@base-ui-components/react/inputparsed:${\tiny{\color{orangered}▲}}$+10.9KB(new) gzip:${\tiny{\color{orangered}▲}}$+4.36KB(new)
@base-ui-components/react/toggleparsed:${\tiny{\color{orangered}▲}}$+8.99KB(new) gzip:${\tiny{\color{orangered}▲}}$+3.66KB(new)
@base-ui-components/react/checkbox-groupparsed:${\tiny{\color{orangered}▲}}$+8.38KB(new) gzip:${\tiny{\color{orangered}▲}}$+3.48KB(new)
@base-ui-components/react/utilsparsed:${\tiny{\color{orangered}▲}}$+8.17KB(new) gzip:${\tiny{\color{orangered}▲}}$+3.15KB(new)
@base-ui-components/react/progressparsed:${\tiny{\color{orangered}▲}}$+7.48KB(new) gzip:${\tiny{\color{orangered}▲}}$+3.04KB(new)
@base-ui-components/react/meterparsed:${\tiny{\color{orangered}▲}}$+7.36KB(new) gzip:${\tiny{\color{orangered}▲}}$+3.03KB(new)
@base-ui-components/react/avatarparsed:${\tiny{\color{orangered}▲}}$+7.22KB(new) gzip:${\tiny{\color{orangered}▲}}$+2.89KB(new)
@base-ui-components/react/fieldsetparsed:${\tiny{\color{orangered}▲}}$+5.93KB(new) gzip:${\tiny{\color{orangered}▲}}$+2.47KB(new)
@base-ui-components/react/formparsed:${\tiny{\color{orangered}▲}}$+5.74KB(new) gzip:${\tiny{\color{orangered}▲}}$+2.46KB(new)
@base-ui-components/react/separatorparsed:${\tiny{\color{orangered}▲}}$+4.28KB(new) gzip:${\tiny{\color{orangered}▲}}$+1.84KB(new)
@base-ui-components/react/use-renderparsed:${\tiny{\color{orangered}▲}}$+3.84KB(new) gzip:${\tiny{\color{orangered}▲}}$+1.67KB(new)
@base-ui-components/react/unstable-use-media-queryparsed:${\tiny{\color{orangered}▲}}$+1.95KB(new) gzip:${\tiny{\color{orangered}▲}}$+941B(new)
@base-ui-components/react/merge-propsparsed:${\tiny{\color{orangered}▲}}$+1.55KB(new) gzip:${\tiny{\color{orangered}▲}}$+764B(new)
@base-ui-components/react/unstable-no-ssrparsed:${\tiny{\color{orangered}▲}}$+1.27KB(new) gzip:${\tiny{\color{orangered}▲}}$+681B(new)
@base-ui-components/react/direction-providerparsed:${\tiny{\color{orangered}▲}}$+644B(new) gzip:${\tiny{\color{orangered}▲}}$+390B(new)

Details of bundle changes

Generated by 🚫 dangerJS against 60edf24

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 30, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 6, 2025
Copy link

pkg-pr-new bot commented May 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@1791

commit: 9160734

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 8, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 19, 2025
@Janpot
Copy link
Member Author

Janpot commented May 19, 2025

I noticed that the icons in the bundle size report look unreadable in light mode:

Will change it to something that works better for both themes:

Screenshot 2025-05-19 at 16 20 48

Screenshot 2025-05-19 at 16 21 27

@oliviertassinari
Copy link
Member

For #201

@Janpot
Copy link
Member Author

Janpot commented May 20, 2025

Oh, and mind you that I updated it to allow for arbitrary code if you want to check something custom:

// bundle-size/bundle-size-checker.config.mjs

      {
        id: 'custom-entry',
        code: `
          import { Field } from '@base-ui-components/react/field';
          console.log(Field.Root, Field.Label);
        `,
        externals,
      },

(Doesn't accept jsx yet I just noticed, but will look into that)

return {
id: entrypoint,
import: entrypoint,
externals,
Copy link
Member Author

@Janpot Janpot May 20, 2025

Choose a reason for hiding this comment

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

This is unnecessary if @base-ui-components/react adds an export condition for ./package.json. Then we can just return entrypoint from this function and the bundle size monitor will infer the externals from the peer dependencies. Right now it has no real way to find the package.json location reliably for a module. (besides using a custom resolver)

Copy link
Member

Choose a reason for hiding this comment

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

I don't mind exporting package.json. Can you do it in this PR or prefer me to open a new one?

Copy link
Member Author

Choose a reason for hiding this comment

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

had it before in this PR, will bring it back.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've seen that many packages adopted this convention, it will become obsolete though once findPackageJSON becomes more stable

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 20, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 21, 2025
@michaldudak michaldudak added scope: infra Infrastructure work going on behind the scenes and removed scope: code-infra labels May 22, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 22, 2025
@Janpot Janpot requested a review from michaldudak May 22, 2025 12:55
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 27, 2025
@Janpot Janpot requested a review from colmtuite as a code owner May 28, 2025 09:25
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels May 28, 2025
@michaldudak
Copy link
Member

I checked https://bundlephobia.com/package/@base-ui-components/[email protected] and it shows drastically different values. Do you have any idea where this difference might come from?
One reason could be measuring a different version (alpha.8 vs. the latest master), but it's hard to believe we almost doubled the library size since the latest release.

@Janpot
Copy link
Member Author

Janpot commented May 28, 2025

bundlejs also measures around 100KB gzipped

Bundle size is 316 kB -> 100 kB (gzip)

In general I don't trust bundlephobia too much. They, for instance, measure the data grid at 47B. No idea how they work exactly under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance PR: out-of-date The pull request has merge conflicts and can't be merged scope: infra Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants