Error in IE11 caused by babel polyfill - delegate.iterator.return

折月煮酒 提交于 2019-12-08 05:08:19

问题


Hope to get some help with following:

The problem

@babel/polyfill causes error in IE11:

SCRIPT1010: Expected identifier

Debugger point on the line:

if (delegate.iterator.return) {

in the function maybeInvokeDelegate() in regenerator-runtime plugin.

But

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.

What I've already tried:

  1. babel-plugin-transform-member-expression-literals doesn't seem to help.

  2. 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.

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

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

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.

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

My 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"],
... })

I have updated all babel packages to latest versions.

Appreciate any help or ideas.


回答1:


Take a look at the link below

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



来源:https://stackoverflow.com/questions/54593298/error-in-ie11-caused-by-babel-polyfill-delegate-iterator-return

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!