-
Notifications
You must be signed in to change notification settings - Fork 645
Update Babel transpilation options #802
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
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/primer/primer-components/5iriuaip4 |
|
Okay, here are my findings:
The first row is the baseline chunk with v18, and the second row is the v19-rc. The bundle size grew 47.4 KB, even though the PC source didn't change size, because by default PC points to the CJS files and tree-shaking no longer works. In the third row, I changed Babel so that it didn't touch the module format, making all the files in In the next-to-last row, I decided to keep compiling My gut is to leave it this way assuming it doesn't cause any issues. If you're using the ESM build, you don't need to be able to import components individually because tree-shaking takes care of it for you; the individual built files in What do you all think? |
|
After a bunch of back-and-forth with teams using this canary in a real-world app, I've decided to remove all the unknown variables and do the simplest thing: transpile a copy of the source separately for ESM users and CJS users. So here's the way the package would look after fetching it from npm:
|
Teams at GitHub saw a significant increase in their built bundle sizes upgrading from PC v18 to the v19 release candidate built from #764. Upon investigation, it appears webpack is including the entirety of the PC lib in their bundle, instead of tree-shaking like it was in the past.
This is probably due to the changes I made to the Babel compilation; in particular, in development, it transpiles the
src/files into CJS modules.