Я бы использовал core- js для того, чтобы добавить функции ECMAscript в ваше приложение.
npm i core-js
import 'core-js/stable'; // <- at the top of your entry point
Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, [2, 3], [4, [5]]].flat(2); // => [1, 2, 3, 4, 5]
Promise.resolve(32).then(x => console.log(x)); // => 32
Редактировать
Если вы хотите включить только то, что нужно, вы можете отредактировать файл .babelr c, включив в него опцию «useBuiltIns»
// .babelrc
{
"presets": [
["@babel/preset-env", {
"targets": [
"Last 2 versions",
]
// This option configures how @babel/preset-env handles polyfills. The 'usage' value imports
// only the specific polyfill module when they are used in each file.
"useBuiltIns": "usage"
}]
],
}