Skip to content

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

Merged
kodiakhq[bot] merged 7 commits into
carbon-design-system:mainfrom
salvoravida:fix/es-build-size
Oct 25, 2021
Merged

chore(react): use babel runtime on es builds#9833
kodiakhq[bot] merged 7 commits into
carbon-design-system:mainfrom
salvoravida:fix/es-build-size

Conversation

@salvoravida

Copy link
Copy Markdown
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

netlify Bot commented Oct 11, 2021

Copy link
Copy Markdown

✔️ 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

github-actions Bot commented Oct 11, 2021

Copy link
Copy Markdown
Contributor

DCO Assistant Lite bot All contributors have signed the DCO.

@netlify

netlify Bot commented Oct 11, 2021

Copy link
Copy Markdown

✔️ 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

netlify Bot commented Oct 11, 2021

Copy link
Copy Markdown

✔️ 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
Copy Markdown
Collaborator Author

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

@salvoravida

Copy link
Copy Markdown
Collaborator Author

recheck

@salvoravida

Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

recheck

@joshblack

Copy link
Copy Markdown
Contributor

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

@salvoravida

salvoravida commented Oct 17, 2021

Copy link
Copy Markdown
Collaborator Author

@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
Copy Markdown
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
Copy Markdown
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

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

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.

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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