website icon indicating copy to clipboard operation
website copied to clipboard

@babel/preset-env: Clarify `useBuiltIns` usage and purpose

Open bowernite opened this issue 6 years ago • 5 comments

This PR clarifies what useBuiltIns is for, and how to use it, better (IMO 🙂).

Specifically, I really struggled using this option in one of my projects. It took me a long time to understand:

  • That this option only told Babel how to import polyfills, and that it didn't come with them
    • Specifically, that you had to npm install them yourself
  • core-js and regenerator/regenerator-runtime were exactly the two polyfills it supported
    • The old documentation focuses on core-js, and brushes over regenerator
  • regenerator-runtime/runtime was installed via the regenerator npm package
    • Just took me a while to figure which exact package to install (regenerator-runtime? Just regenerator?)

Feedback welcome 😃

bowernite avatar Jul 19 '19 14:07 bowernite

Deploy preview for babel failed.

Built with commit 6f82595890be62a7fc6748d0b27a02a1cd5f2cd4

https://app.netlify.com/sites/babel/deploys/5e6c15e822b418000b7f7649

netlify[bot] avatar Jul 19 '19 14:07 netlify[bot]

Could we also add a note that it is incompatible with transform-runtime? (ref: https://github.com/babel/babel/issues/10271)

nicolo-ribaudo avatar Sep 05 '19 14:09 nicolo-ribaudo

Could we also add a note that it is incompatible with transform-runtime? (ref: babel/babel#10271)

@nicolo-ribaudo But if preset-env and transform-runtime don't work together, won't people lose the benefit of sharing the runtime/helper code across the entire project? Not sure people are going to like that.

patrick-mcdougle avatar Sep 26 '19 23:09 patrick-mcdougle

Sorry, I meant with transform-runtime's core-js option

nicolo-ribaudo avatar Sep 26 '19 23:09 nicolo-ribaudo

Could we also add a note that it is incompatible with transform-runtime? (ref: babel/babel#10271)

Do you have wording in mind on this? Might be easier than me trying to come up with something and having it be inaccurate 😅

bowernite avatar Oct 01 '19 12:10 bowernite