Questions tagged [babel-polyfill]

Babel Polyfill will emulate a full ES6 environment. This polyfill is automatically loaded when using babel-node.

Installation:

$ npm install babel-polyfill

To find more information :

265 questions
146
votes
7 answers

How do I install the babel-polyfill library?

I just started to use Babel to compile my ES6 javascript code into ES5. When I start to use Promises it looks like it's not working. The Babel website states support for promises via polyfills. Without any luck, I tried to…
Shlomi
  • 3,622
  • 5
  • 23
  • 34
98
votes
11 answers

`regeneratorRuntime` is not defined when running Jest test

The title pretty much explains what I'm facing. I'm trying to test a React component that has some state, and I attempt to provide my store to the component in order to get what it needs. When I run the test of the component using Jest, I get the…
rafafan2010
  • 1,559
  • 2
  • 14
  • 23
59
votes
1 answer

babel vs babel-core vs babel-loader vs babel-preset-2015 vs babel-preset-react vs babel-polyfill

I was setting up Webpack for my React project and got confused between babel, babel-core, babel-loader, babel-preset-2015 and babel-preset-react. I know that Babel is needed to transform ES7 or ES6 code to ES5 but in my package.json I have installed…
ankita.gulati
  • 899
  • 1
  • 8
  • 15
22
votes
1 answer

How do I use babel's `useBuiltIns: 'usage'` option on the vendors bundle?

Since I need to support also IE11, I need to transpile also node_modules. This is the babel config I use on the node_modules: presets: [ ['@babel/preset-env', { modules: false, useBuiltIns: 'usage' }], ], I use the useBuiltIns options because it…
Pontiacks
  • 1,118
  • 2
  • 13
  • 23
20
votes
2 answers

Promise is undefined in IE11 using babel-polyfill

As the title says, even I'd like to use babel-polyfill to allow me to use promises in my code, but I get that undefined error in IE11. I've been trying to make this work for a while as I've seen that has been asked in different sites a few times,…
mitomed
  • 2,006
  • 2
  • 29
  • 58
15
votes
4 answers

.flat is not a function only with jest

When running my tests with jest, I had the above error; Error: Uncaught [TypeError: array.map(...).flat is not a function] Following the solution from that issue, https://github.com/kulshekhar/ts-jest/issues/828 I've installed core-js on…
Guilherme Bayer
  • 161
  • 1
  • 1
  • 4
15
votes
2 answers

babel-polyfill vs babel-plugins

I am a bit lost in the Babel options / config. I want to use recent js features and compile (with webpack) to browser code. What is the difference between babel-polyfill and babel plugins with babel-preset-env? Are they intended to work together?
François Romain
  • 13,617
  • 17
  • 89
  • 123
15
votes
5 answers

"Only one instance of babel-polyfill is allowed" error

I need help diagnosing and fixing this error: "Error: only one instance of babel-polyfill is allowed" I have the following in my package.json: "devDependencies": { "babel-core": "^6.23.1", "babel-jest": "^19.0.0", "babel-loader":…
foobar
  • 3,849
  • 8
  • 22
  • 32
13
votes
1 answer

babel polyfill being included, but forEach still doesn't work in IE11 on NodeLists

I've got Webpack working with Babel and including the @babel/polyfill, yet IE11 is still throwing a SCRIPT438 error when trying to use .forEach on a NodeList. Here's my package.json { ... "scripts": { "build:js": "webpack --config…
Robert_QSS
  • 213
  • 1
  • 4
  • 9
13
votes
1 answer

babel-minify vs terser (instead uglify-js)

I'm relatively new to ES6+ (called modern JavaScript) but it seems if I want to use it in browsers I need babel-minify or terser. (First I thought Babili is another player but it's just the old name of Babel-Minify) About polyfills for the browser…
szegheo
  • 4,175
  • 4
  • 31
  • 35
12
votes
2 answers

Axios Catch being called even when response is 200 (Successful)

I am using a Electron Vue App with Axios for my HTTP calls to my Laravel Server. Everything was perfect in Dev mode of Electron. But as soon as I build my Electron App into a install and put it on the clients computer all chaos broke out. I fix some…
Zach C.
  • 187
  • 2
  • 14
11
votes
3 answers

ChildNode.remove() polyfill with babel-polyfill

I am using ChildNode.remove() and I described by Mozilla I need a polyfill for IE. I am using webpack with the babel-polyfill configured: "babel-polyfill": "^6.13.0", "webpack": "^2.4.1", webpack.config.babel.js: entry: ['babel-polyfill',…
Nicolas Després
  • 1,279
  • 1
  • 12
  • 12
11
votes
2 answers

What's wrong with my Webpack config?

I started to use Webpack for a student project, but I'm stuck configuring Webpack to include React and Babel. Here's my node packages : +-- babel-core@6.18.0 +-- babel-loader@6.2.5 +-- babel-polyfill@6.16.0 +-- babel-preset-es2015@6.18.0 +--…
Thaledric
  • 539
  • 2
  • 8
  • 17
10
votes
1 answer

Is it better to have polyfills as import statements with babel-preset-env or add them in entries at webpack.config.js?

babel-preset-env offers the option useBuiltIns to apply it to babel-polyfill and transform import 'babel-polyfill' to specific, environment-based, import 'core-js/whatever. Is this transformation applied if I add babel-polyfill in my Webpack entry…
Alf
  • 1,414
  • 1
  • 15
  • 27
9
votes
2 answers

Error with babel-polyfill and webpack

I am following along a tutorial from Udemy, and we've just downloaded babel. Everything was working fine until I downloaded babel-polyfill and tried to integrate it. Currently this is my webpack and babelrc files: Webpack & Babel and this is what…
Leslie O
  • 193
  • 1
  • 1
  • 8
1
2 3
17 18