Skip to content
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

chore(react): use babel runtime on es builds #9833

Merged
merged 7 commits into from
Oct 25, 2021

Conversation

salvoravida
Copy link
Collaborator

chore(react): use babel runtime on es builds

Hi guys!

This PR adds @babel/runtime on es builds. -> less 60/100k on your bundle.js depended on how many components are used.

@salvoravida salvoravida requested a review from a team as a code owner October 11, 2021 02:34
@netlify
Copy link

netlify bot commented Oct 11, 2021

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: b02bb9d

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/61771b99b6b7ea00075ecac6

😎 Browse the preview: https://deploy-preview-9833--carbon-react-next.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2021

DCO Assistant Lite bot All contributors have signed the DCO.

@netlify
Copy link

netlify bot commented Oct 11, 2021

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: b02bb9d

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61771b99b6ea0500083d04de

😎 Browse the preview: https://deploy-preview-9833--carbon-components-react.netlify.app/

@netlify
Copy link

netlify bot commented Oct 11, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: b02bb9d

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61771b99b626b90007ac8821

😎 Browse the preview: https://deploy-preview-9833--carbon-elements.netlify.app

@salvoravida
Copy link
Collaborator Author

I have read the DCO document and I hereby sign the DCO.

@salvoravida
Copy link
Collaborator Author

recheck

@salvoravida
Copy link
Collaborator Author

DCO Assistant Lite bot: Thanks for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text:

I have read the DCO document and I hereby sign the DCO.

You can retrigger this bot by commenting recheck in this Pull Request

I have read the DCO document and I hereby sign the DCO.

@salvoravida
Copy link
Collaborator Author

recheck

@joshblack
Copy link
Contributor

@salvoravida Thanks for doing this! I think we'll also need to include @babel/runtime as a dependency, potentially? 👀

@salvoravida
Copy link
Collaborator Author

salvoravida commented Oct 17, 2021

@salvoravida Thanks for doing this! I think we'll also need to include @babel/runtime as a dependency, potentially? 👀

It is already included by babel. not needed.

@joshblack
Copy link
Contributor

@salvoravida I think it will need to be included based on: https://babeljs.io/docs/en/babel-plugin-transform-runtime#technical-details

Not everyone will be using babel directly, e.g. some could be using Rollup or esbuild so we can't transitively depend don't this through @babel/core or similar dependencies.

Let me know if I'm misunderstanding, I think the number one thing was just making sure that if a file gets transpiled to import @babel/runtime that the dependency is included and we don't depend on it transitively through other babel dependencies 👍

@salvoravida
Copy link
Collaborator Author

@salvoravida I think it will need to be included based on: https://babeljs.io/docs/en/babel-plugin-transform-runtime#technical-details

Not everyone will be using babel directly, e.g. some could be using Rollup or esbuild so we can't transitively depend don't this through @babel/core or similar dependencies.

Let me know if I'm misunderstanding, I think the number one thing was just making sure that if a file gets transpiled to import @babel/runtime that the dependency is included and we don't depend on it transitively through other babel dependencies 👍

Yes, I have added "@babel/runtime": "^7.14.6", as dependencies (is the one already downloaded by other dep, so it will not be duplicated)

TL;DR @babel/runtime share all the ES5 polyfill without duplication for each file!

@joshblack joshblack requested review from tay1orjones and removed request for andreancardona October 22, 2021 19:18
Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Sorry - actually needs a yarn to update the lockfile. I'll pull this down and do it.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Done 👍 LGTM if status checks pass

@joshblack
Copy link
Contributor

@salvoravida just wanted to ask, could this be something that works for CommonJS builds as well? I noticed that this one was only targeting ESM 👀

@salvoravida
Copy link
Collaborator Author

@salvoravida just wanted to ask, could this be something that works for CommonJS builds as well? I noticed that this one was only targeting ESM 👀

sure! done!

@kodiakhq kodiakhq bot merged commit 4c044be into carbon-design-system:main Oct 25, 2021
@salvoravida salvoravida deleted the fix/es-build-size branch October 25, 2021 22:38
@salvoravida salvoravida restored the fix/es-build-size branch October 25, 2021 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants