question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Revisit @babel/present-env browserslist polyfills

See original GitHub issue

Is 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:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
esetnikcommented, Feb 13, 2019

@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 respects browserslist until this gets some attention by the core team.

2reactions
ianschmitzcommented, Mar 9, 2019

I’ve created #6608 which adds browserslist support for @babel/preset-env. It adds useBuiltIns: 'entry' which supports importing @babel/polyfill in the entry point of your application, while respecting your browerslist 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/preset-env
babel /preset-env` is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, ......
Read more >
How babel preset-env, core-js, and browserslistrc work together
In this post we're going to see how babel preset-env, core-js, and browserslistrc work nicely together to enable newer JavaScript features ...
Read more >
Confused about useBuiltIns option of @babel/preset-env ...
1) Do I need to use that useBuiltIns: "entry" option? Yes, if you want to include polyfills based on your target environment. TL;DR....
Read more >
Supporting old browsers without hurting everyone - sgom.es
For Babel , make sure that you're using the env preset instead of an explicit set of transforms, otherwise it'll ignore your browserslist...
Read more >
What you don't know about BabelJS preset-env - PerimeterX
The Babel yearly presets — preset-2015, 2016, etc. — were focused on converting ES6 JavaScript features to ES5. This allowed developers to write ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found