website icon indicating copy to clipboard operation
website copied to clipboard

[Docs] Make it clear what dependencies should be imported when using @babel/preset-env together with useBuiltIns options

Open wujekbogdan opened this issue 5 years ago • 4 comments

Hi,

I've read the @babel/preset-env documentation several times, but I'm still not 100% sure If I get it all correctly.

To me, it seems that:

  • when @babel/preset-env is used together with useBuiltIns: 'usage' then no additional dependencies need to be imported in our entry file. Babel will pick and import all the polyfills for us based on features used in the transpiled code (and based on an additional configuration like browserslist config or target config option).
  • when we use useBuiltIns: 'entry' then we need to add the following lines to our entry file:
    import 'core-js/stable';
    import 'regenerator-runtime/runtime';
    
  • when we use useBuiltIns: false then we have to import the entire @babel/polyfill or import individual polyfills.

Both: usage and entry options require the core-js lib to be installed.


Could you improve the docs and make it really clear? Some examples would be very helpful.

wujekbogdan avatar Jan 23 '20 14:01 wujekbogdan

Hey @wujekbogdan! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

babel-bot avatar Jan 23 '20 14:01 babel-bot

Hey @wujekbogdan! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

babel-bot avatar Jan 23 '20 16:01 babel-bot

@babel/polyfill has been deprecated.

danBamikiya avatar Apr 11 '21 21:04 danBamikiya

Yeah, because it was just a wrapper around core-js@2 and regenerator-runtime. We decided to let users include these two dependencies themselves so that they can control the version (and we don't take the merit of what core-js does).

nicolo-ribaudo avatar Apr 11 '21 21:04 nicolo-ribaudo