由Babel Polyfill引起的IE11错误-委托.iterator.return [英] Error in IE11 caused by babel polyfill - delegate.iterator.return

查看:201
本文介绍了由Babel Polyfill引起的IE11错误-委托.iterator.return的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望在以下方面获得帮助:

Hope to get some help with following:

@ babel/polyfill导致IE11错误:

@babel/polyfill causes error in IE11:

SCRIPT1010: Expected identifier

在线调试器点:

if (delegate.iterator.return) {

regenerator-runtime插件的功能maybeInvokeDelegate()中.

但是

问题仅在测试环境中发生.当我使用完全相同的构建,相同的浏览器在本地运行我的应用程序时,它就可以正常工作.它包含相同的代码,但不会破坏任何内容.

Problem occures only in test environment. When I run my aplication locally, with exactly same build, same browser it works just fine. It contains same code, but it doesn't break anything.

  1. babel-plugin-转换成员表达文字似乎无济于事.

我尝试仅用必要的polyfill替换@ babel/polyfill,但失败了.在破坏应用程序时会出现很多错误,这些错误很难捕获/调试/理解.

I tried to replace @babel/polyfill with only necessary polyfills but I failed. To much errors breaking application which are hard to catch/debug/understand.

.babelrc中设置useBuiltIns: "usage",但是在导入必要模块的方式上遇到了问题.我将再尝试一次.

Set useBuiltIns: "usage" in .babelrc but faced a problem with way it imports necessary modules. I'm going to give this one more try.

我在github上浏览了regeerator-runtime和babel-polyfill的所有相同问题,但没有找到可行的解决方案.

I looked through all same issues with regeerator-runtime and babel-polyfill on github, but haven't found working solution.

配置

目前,我需要在webpack配置中使用@ babel/polyfill并将其用作入口点.我相信我什至不需要再生器运行时,因为据我所知它用于异步功能(也许我弄错了),我们不使用它们.

Config

At the moment I'm requiring @babel/polyfill in webpack config and use it as an entry point. I believe I don't even need regenerator-runtime, because as far as I understand it used for async function (maybe I'm mistaken) and we don't use them.

我没有为webpack使用babel loader,而是在webpack之后为/dist目录运行babel.

I'm not using babel loader for webpack but run babel for /dist directory after webpack.

我的babelrc:

{
    plugins: ["transform-member-expression-literals"],
    presets: [
        [ "@babel/preset-env",
          {
              useBuiltIns: "entry",
              modules: "false",
              targets: {
                  ie: 11
              }
          }]
    ]
}

webpack.config

require("@babel/polyfill")

const getDefaultConfig = env => ({
  mode: "development",
  entry: ["whatwg-fetch", "@babel/polyfill", "./src/index.js"],
... })

我已将所有babel软件包更新为最新版本.

I have updated all babel packages to latest versions.

感谢任何帮助或想法.

推荐答案

看看下面的链接

github.com/facebook/create-react-app/issues/4255

这篇关于由Babel Polyfill引起的IE11错误-委托.iterator.return的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆