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

Babel not transpiling chunk-vendors for IE11, in Vue-CLI project

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

"browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8",
    "ie 11"
  ]

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

但是,生成的 chunk-vendors.x.js do 包含 ... 运算符,因此在 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"
  },

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

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

答案似乎不是"make sure all dependencies are transpiled"(这显然会导致很多问题),而是"make sure the specific dependencies which are causing issues are transpiled"。

您可以通过向 vue.config.js 添加一行来完成此操作:

transpileDependencies: ['/node_modules/myproblematicmodule/']