Skip to content

Why can't preset-env automatically polyfill the latest features #12642

Answered by nicolo-ribaudo
myNameIsDu asked this question in Q&A
Discussion options

You must be logged in to vote

Babel uses this list to determine which polyfills are supported by your core-js version. es.* packages are stable, esnext.* are proposal.

As you can see, the stable polyfill for matchAll (es.string.match-all) has been introduced in core-js 3.1.

Your configure specifies corejs: 3 which means "Babel should generate code compatible with any core-js version": it cannot inject the es.string.match-all polyfill because it would throw with core-js 3.0.
You can specify something like corejs: "3.8" instead, which tells Babel "I'm using at least version 3.8": Babel can them safely inject by default the polyfills introduced after version 3.0.0 of core-js.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@myNameIsDu
Comment options

Comment options

You must be logged in to vote
1 reply
@myNameIsDu
Comment options

Answer selected by myNameIsDu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants