Babel 在 Vue-CLI 项目中不为 IE11 转译块供应商

Ste*_*ett 7 internet-explorer-11 webpack vue.js babeljs vue-cli

我有一个需要支持 IE11 的 Vue-CLI webapp。在 package.json 中我们设置了:

"browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8",
    "ie 11"
  ]
Run Code Online (Sandbox Code Playgroud)

这似乎适用于生成的app.x.js文件:例如,它们不包含任何...运算符。

但是,生成的chunk-vendors.x.js 确实包含...运算符,因此在 IE11 上失败。

package.json 的相关部分:

  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.3.0",
    "@vue/cli-plugin-eslint": "^3.3.0",
    "@vue/cli-service": "^3.3.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "pug": "^2.0.3",
    "pug-plain-loader": "^1.0.0",
    "vue-cli-plugin-pug": "^1.0.7",
    "vue-template-compiler": "^2.5.21"
  },
Run Code Online (Sandbox Code Playgroud)

vue.config.js 中没有相关更改,因此使用默认行为。

我需要更改什么才能确保chunk-vendors.x.js为 IE11 转译?

Ste*_*ett 8

答案似乎是,与其说“确保所有依赖项都被转换”(这显然会导致很多问题),而是“确保导致问题的特定依赖项被转换”。

您可以通过添加一行来做到这一点vue.config.js

transpileDependencies: ['/node_modules/myproblematicmodule/']

  • 关于确定哪些模块导致问题的任何提示? (3认同)