react icon indicating copy to clipboard operation
react copied to clipboard

The theme object inflates bundle size.

Open cihad opened this issue 1 year ago • 1 comments

Description

theme object gets total 9 colorSchemes. And importing these color schemes under the themes object does not allow tree shaking. I bundled only theme object:

Capture

Only theme object took 327 Kb | gzip: 52 Kb.

I recommend export each color scheme something like import { light, dark } fro "@primer/react/color-schemes". And it can be pass the <ThemeProvider> as generated theme object. Because overall UI's don't need more than 2 schemes.

Steps to reproduce

  1. Go to Stackblitz example
  2. Run npm run build
  3. See the results.

Version

^36.12.0

Browser

No response

cihad avatar Mar 24 '24 23:03 cihad

Hi! Thanks for taking the time to report this!

Good news: This current solution is temporary and we are already discussion a replacement which should lead to a much smaller bundlesize (not too dissimilar than the one you suggested)

Bad news: It's still in the planning phase so I don't have a exact date for you right now when that change will happen

Until then, I'm not sure if there is an easy workaround 🤔

siddharthkp avatar Mar 25 '24 13:03 siddharthkp

Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days.

github-actions[bot] avatar Sep 21 '24 14:09 github-actions[bot]