Revisit @babel/present-env browserslist polyfills
See original GitHub issueIs this a bug report?
No
In the babel-preset-react-app
project https://github.com/facebook/create-react-app/blob/master/packages/babel-preset-react-app/create.js#L92 it specifically overrides the browserslist configuration and targets ie 9
with useBuiltIns: false
. I believe this should be revisited as a configuration option to avoid the requirement for most people to eject create-react-app
to run it in production. It seems that the configuration would be much nicer if we could avoid having to include polyfills manually and instead use browserslist
configuration with @babel/preset-env
and @babel/polyfill
to do the heavy lifting. Then you’d only need to import @babel/polyfill
in the top of the index.js file (could be included by default with a sensible default browserslist configuration) and you’d automatically get all of the polyfills needed. If this idea is of interest, i’d be happy to submit a PR with the required changes.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:12 (3 by maintainers)
Top GitHub Comments
@duhseekoh my guess is that at the time this was done when
useBuiltIns
was in experimental status and they didn’t want to risk compatibility issues. Since it’s quite stable now it should be the default behavior. Maybe we should maintain a fork of cra that respectsbrowserslist
until this gets some attention by the core team.I’ve created #6608 which adds
browserslist
support for @babel/preset-env. It addsuseBuiltIns: 'entry'
which supports importing @babel/polyfill in the entry point of your application, while respecting yourbrowerslist
to only include the polyfills necessary by your target browsers. This should be a safe pattern for users that want to polyfill an ES2015+ environment.