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.

How to add babel-polyfill

See original GitHub issue

I’m using redux-saga in my gatsby app and therefore generator functions. These are causing errors in IE11 and it seems like babel isn’t polyfilling them. I’ve been trying different techniques for including babel-polyfill but none seem to work, both of these seem relevant but don’t solve my issue:

https://github.com/gatsbyjs/gatsby/issues/341 https://github.com/gatsbyjs/gatsby/issues/2177

I’m trying to do the following, but still having the same error in IE. Is there a preferred approach for solving this?

if ( stage === 'build-javascript' || stage === 'develop' ) {
    config._config.entry.commons.unshift( 'babel-polyfill' );
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

18reactions
Kalcodecommented, Jan 3, 2018

In the very top of my gatsby-browser.js file i have

import 'babel-polyfill'

is the very first line in that file.

Then in gatsby-node.js I added ‘transform-regenerator’

exports.modifyBabelrc = ({ babelrc }) => ({
  ...babelrc,
  plugins: babelrc.plugins.concat(['transform-decorators-legacy', 'transform-regenerator']),
})

The ‘transform-decorators-legacy’ is not needed. Just showing you the exact working copy I use.

IE 11 and Edge work fine with Redux-Saga now, Saga uses generators for their side-effects.

Hope this helps.

4reactions
KyleAMathewscommented, Dec 22, 2017

Are you trying to require babel-polyfill? Or add it to the babel config?

For the 1st, require it in your layouts/index.js file or gatsby-browser.js.

For the later, add it to a .babelrc in the root of your site.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/polyfill
To include the polyfill you need to require it at the top of the entry point to your application. Make sure it is...
Read more >
@babel/polyfill - npm
Start using @babel/polyfill in your project by running `npm i ... See the @babel/polyfill docs ... Install. npm i @babel/polyfill ...
Read more >
How do I install the babel-polyfill library? - Stack Overflow
babel -polyfill allows you to use the full set of ES6 features beyond syntax changes. This includes features such ...
Read more >
BabelJS - Babel Polyfill - Tutorialspoint
Babel Polyfill adds support to the web browsers for features, which are not available. Babel compiles the code from recent ecma version to...
Read more >
Babel Polyfills - GitHub
A set of Babel plugins that enable injecting different polyfills with different strategies in your compiled code. Additionally, this repository contains a ...
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