Error in IE11 caused by babel polyfill - delegate.

2019-06-02 02:12发布

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条回答
一夜七次
2楼-- · 2019-06-02 02:52
登录 后发表回答