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.

Pin babel-preset-react-app to a minor core-js version as per core-js readme

See original GitHub issue

Is your proposal related to a problem?

I’ve been trying to polyfill Promise.allSettled for Edge by using react-app-polyfill/stable but failing. My expectation was that it should work since react-app-polyfill@1.0.6 depends on core-js@3.6.4 and Promise.allSettled was moved into core-js/stable on v3.2.0.

I’ve dug a bit deeper to find that babel-preset-react-app has corejs set to major version 3 (https://github.com/facebook/create-react-app/blob/v3.4.1/packages/babel-preset-react-app/dependencies.js#L91)

Looking at the core-js readme I see this:

Warning! Recommended to specify used minor core-js version, like corejs: ‘3.6’, instead of corejs: 3, since with corejs: 3 will not be injected modules which were added in minor core-js releases.

Locally I’ve set corejs in babel-preset-react-app to 3.2 (just a proof this is the issue) and I can see Promise.allSettled is now polyfilled correctly.

It’s not clear to me why babel-preset-react-app does not follow the advice of core-js and pin to a minor version?

Describe the solution you’d like

Update babel-preset-react-app to pin to a minor version of corejs in it’s configuration.

Describe alternatives you’ve considered

Eject and manage babel-preset-env myself but I’m very reluctant to go down this route.

I look forward to being told why things aren’t as simple as changing babel-preset-react-app configuration 😃

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:5

github_iconTop GitHub Comments

4reactions
xprommercommented, Jan 9, 2022

The similar issue, babel-plugin-polyfill-corejs3 removes my side-effect import because of babel-preset-react-app provides old version of core-js and there is no way to specify a correct version at least 3.17. So I just wanted to use the latest stable ES with nice stuff like Array.prototype.at, Object.hasOwn and so on and importing it like a polyfill import "core-js/es/array/at"; with only side effect does not work 😦 The sole solution I’ve found so far is to use export * from "core-js/es/array/at"; instead of side effect import, but I don’t like it. It would be much better to add an option for corejs version, or at least update it to the latest 3.20

3reactions
Mrmancommented, Apr 16, 2020

I had the same problem four months ago.

At that time, I solved it by importing the specific polyfill instead of just corejs

import 'core-js/modules/esnext.string.match-all';

Thanks @pakaponk, I’m doing the same as you as a workaround in my project knowing the CRA is specifically targetting v3 of core-js.

This issue is really to explore what’s stopping CRA from targetting a more recent version of core-js. core-js@3.0.0 was released over a year ago now (19 Mar 2019).

Read more comments on GitHub >

github_iconTop Results From Across the Web

7.4.0 Released: core-js 3, static private methods and partial ...
Today we are releasing Babel 7.4.0! This release includes support for TypeScript 3.4, the proposal for partial application in function calls ...
Read more >
core-js/README.md
* `modules` path is internal API, does not inject all required dependencies and can be changed in minor or patch releases. Use it...
Read more >
why does Babel in create-react-app not polyfill Array. ...
Hey guys I believe I've fond the reason;. TLDR, the CRA is setting the wrong core-js version config for babel. I'm using create-react-app...
Read more >
react-scripts: Versions
v4.0.3 is a maintenance release that includes minor bug fixes and dependency updates. Bug Fix. react-scripts. #10590 Upgrade eslint-webpack-plugin to fix ...
Read more >
core-js-for-ie8 - npm Package Health Analysis
Learn more about core-js-for-ie8: package health score, popularity, security, maintenance, versions and more.
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