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
3
votes
1 answer

Only include needed polyfills with babel-polyfill

Is there a way to "tree shake" babel-polyfill, such that only the features I use are polyfilled? That is, if I never use String.padStart in my code, it's polyfill should not be included.
Birjolaxew
  • 807
  • 9
  • 25
3
votes
1 answer

Using babel-polyfill in production entry file

I'm using babel to transpile ES7 js code, and everything works like a charm in dev/staging. Inside the application, I heavily rely on async/await features of ES7. My entry file looks like this: 'use…
Ivan
  • 769
  • 5
  • 17
3
votes
2 answers

Does core-js polyfill or does it always replace the function?

I have a react project that needs to support older browsers and we're using things like array.find() and array.map(). I see that our project already has core-js in the node_modules folder, so it would be nice to use it rather than adding another…
SomethingOn
  • 9,813
  • 17
  • 68
  • 107
3
votes
1 answer

Cannot read property '_babelPolyfill' of undefined

I'm trying to get babel-polyfill working with for a library but I'm getting the following error: TypeError: Cannot read property '_babelPolyfill' of undefined at Object. (/Users/foo/webpack-library-starter/lib/library.js:73:6) ... I'm…
Nelson Yeung
  • 3,262
  • 3
  • 19
  • 29
3
votes
1 answer

Iterating an HTMLCollection object using for-of loop

I'm using babel-polyfill and I'm trying to iterate an HTMLCollection object using for-of loop: const elements = document.getElementsByClassName('some-class') for (const element of elements) { console.log(element) } It's not working. I'm getting…
3
votes
2 answers

How can I use babel-polyfill for multiple separated entries / outputs?

I have this in my webpack.config.js to create two different outputs from two sources: module.exports = { entry: { 'dist/index.js': ['babel-polyfill', './src/Component.jsx'], 'example/bundle.js': ['babel-polyfill', './src/Page.jsx'], }, …
Rotareti
  • 49,483
  • 23
  • 112
  • 108
2
votes
0 answers

Uncaught ReferenceError: Buffer is not defined even after adding the webpack plugin for buffer

I followed the answer in https://stackoverflow.com/a/68723223/14758033 added the plugin inside the module.exports object of react-scripts webpack config and added fallback in my webpack.config.js of react-scripts fallback:{ "buffer":…
2
votes
0 answers

If I install both `@babel/runtime-corejs3` do I still need `core-js` as dependency?

As title, I'm learning about babel and current I'm trying to understand @babel/plugin-transform-runtime, here are my current conclusions: From my settings of @babel/preset-env below, I will need to install core-js@3 as dependency. (I'm not sure)…
NeoZoom.lua
  • 2,269
  • 4
  • 30
  • 64
2
votes
1 answer

why is my babel config ignoring this plugin?

this my babe.config.js : module.exports = { presets: [ '@babel/preset-react', [ '@babel/preset-env', { modules: false, }, ], ], plugins: [ '@babel/plugin-proposal-optional-chaining', …
سعيد
  • 1,547
  • 1
  • 14
  • 32
2
votes
2 answers

Async / Await using babel regenerator-runtime does not work in ie11

I have a template app that I want to make work with ie11, for that I'm using webpack + babel. For some reason I ignore, my JS does not work at all in ie11 even though I did set it as a target in my config. To test it, I use a ie11 on the internet…
2
votes
2 answers

Gulp & Babel polyfill Promises for IE11 issue

I have an old project written in Angular.js. I need to polyfill promises for IE11 but it's not working. In gulpfile.js I have requires for Babel stuff var corejs = require('core-js/stable'), regenerator = require('regenerator-runtime/runtime'), …
2
votes
1 answer

Seperate Babel Polyfills from Main Code when bundling

I am using Webpack and Babel. Babel is generating a single file main.js in my output directory with all the polyfills added along side my js files. I would like to separate the polyfills from the main code into two different files. polyfills.js and…
2
votes
3 answers

React App converting JS to ES5 to target IE 11

I currently have a react app which is not running / rendering in IE, I think due to an ES5 / ES6 problem. The error I get is this: Syntax error. On the line highlighted below. if(process.env.NODE_ENV == 'production') { => module.exports =…
Squiggs.
  • 4,299
  • 6
  • 49
  • 89
2
votes
3 answers

SCRIPT5022: Exception thrown and not caught

I am using Vuejs for my web project. As there are some users out there who are still using IE11, I need to make this web project compatible. Currently I am getting this error on IE11: SCRIPT5022: Exception thrown and not caught /***/…
SPQRInc
  • 162
  • 4
  • 23
  • 64
2
votes
0 answers

Page is not binding when angularjs version upgraded to 1.4.1 from 1.3.10

I have upgraded my current version of angular to 1.4.1 and as a result, the page is not loading I have a sample code to demo it. 'use strict';var app = angular.module('test').controller ('testcontroller', function () { return…