Babel与core-js-Polyfills与IE11不兼容

问题描述 投票:1回答:1

我已经使用webpack配置了babel,并最初将@ babel / polyfill用作webpack配置中的条目。通过这种配置,我可以在IE11中运行我的Web应用程序而没有任何错误。由于不推荐使用@ babel / polyfill,因此我尝试使用core-js,这是我的问题开始的地方。 IE11现在给我一个关于webpack:///node_modules/core-js/modules/es.object.set-prototype-of.js文件的错误:

SCRIPT1002:语法错误

脚本本身看起来像这样:

enter image description here

据我了解,不应将core-js包含在要翻译的babel-loader中,但在我看来,上面显示的脚本使用的是IE11无法理解的功能。我在这里想念什么?

当前配置如下:

babel-loader

{
  test: /\.js$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    configFile: './.babelrc',
  },
}

。babelrc

{
  "sourceType": "unambiguous",
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "usage",
        "corejs": {"version": 3, "proposals": true}
      }
    ]
  ]
}

package.json

 "browserslist": [
    "defaults"
 ]

我还从webpack条目和程序包管理器中删除了@ babel / polyfill,而是安装了core-js。

webpack babel core-js
1个回答
0
投票

尝试删除“排除”选项以查看是否为npm模块。然后,您可以尝试排除除该模块以外的所有模块。看看https://github.com/babel/babel-loader/issues/171帮助

© www.soinside.com 2019 - 2024. All rights reserved.