简体   繁体   English

使用 Grunt-Babel 使 ES6 Internet Explorer 11 兼容

[英]Make ES6 Internet Explorer 11 compliant using Grunt-Babel

I installed grunt-babel in order to allow IE 11 users on our site.我安装了 grunt-babel 以允许 IE 11 用户访问我们的网站。 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.看起来 polyfills 已被弃用,所以我想知道最好的解决方案是什么。

EDIT Following justDan and David's advice, I installed regenerator/runtime package and am now getting an error require is not defined编辑按照 justDan 和 David 的建议,我安装了 regenerator/runtime 包,现在收到一个错误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.我的公司正在使用自定义 CMS,它要求我们压缩主题文件,并且有很大一部分需要动态填充的文本,这是使用 ES6 模板文字的部分原因。

package.json file package.json 文件

{
  "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 .babelrc 文件

{
  "presets": ["@babel/preset-env"]
}

You need to install and run this package你需要安装并运行这个包

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM