1

I installed grunt-babel in order to allow IE 11 users on our site. Right now the site is broken for those users. I've been mostly successful except I've gotten the following error that I don't know how to address.

ReferenceError: regeneratorRuntime is not defined

It looks like polyfills are deprecated so I'm wondering what is the best solution.

EDIT Following justDan and David's advice, I installed regenerator/runtime package and am now getting an error require is not defined

This code will be run through the browser. My company is using a custom CMS which requires us to compress the theme file and there are large sections requiring dynamically populated text which is part of the reason for using ES6 template literals.

package.json file

{
  "name": "Some Site",
  "version": "1.0.0",
  "description": "",
  "main": "Gruntfile.js",
  "dependencies": {
    "regenerator-runtime": "^0.13.3"
  },
  "devDependencies": {
    "@babel/core": "^7.7.2",
    "@babel/preset-env": "^7.7.1",
    "@babel/preset-es2015": "^7.0.0-beta.53",
    "babel-preset-es2015-nostrict": "^6.6.2",
    "grunt": "^1.0.4",
    "grunt-autoprefixer": "^3.0.4",
    "grunt-babel": "^8.0.0",
    "grunt-contrib-compress": "^1.5.0",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-cssmin": "^3.0.0",
    "grunt-contrib-imagemin": "^3.1.0",
    "grunt-contrib-less": "^2.0.0",
    "grunt-contrib-uglify": "^4.0.1",
    "grunt-contrib-watch": "^1.1.0",
    "grunt-purifycss": "^0.1.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

.babelrc file

{
  "presets": ["@babel/preset-env"]
}
g-ulrich
  • 41
  • 5
  • 1
    Did you try to use/import the `core-js/stable` and `regenerator-runtime/runtime` in place of `@babel/polyfill`? https://babeljs.io/docs/en/babel-polyfill – justDan Dec 03 '19 at 19:07
  • I did but I am now getting another error `ReferenceError: require is not defined`. Should I be using Browserify? – g-ulrich Dec 03 '19 at 20:01
  • Are you running your code with node or through the browser? Either way, I think you might find this useful: https://stackoverflow.com/questions/31931614/require-is-not-defined-node-js – justDan Dec 03 '19 at 20:08
  • 1
    If possible, can you please try to inform us the detailed information about your developing environment and it can be better if you post any small sample code for reproducing the issue. It can help us to understand the issue in better way. Thanks for your understanding. – Deepak-MSFT Dec 04 '19 at 01:50
  • Part of the problem I'm having is knowing why regenerator-runtime/runtime is required. I'm just using some template literals and arrow functions, nothing crazy, so I just need a simple transpile from ES6 -> ES5. – g-ulrich Dec 04 '19 at 16:33
  • You can try to refer this link may give you some helpful information. Ref: https://ccoenraets.github.io/es6-tutorial/setup-babel/ – Deepak-MSFT Dec 05 '19 at 05:47

1 Answers1

2

You need to install and run this package

https://www.npmjs.com/package/regenerator-runtime

David Bradshaw
  • 11,859
  • 3
  • 41
  • 70