在Vue-CLI项目中,Babel不为IE11移植块供应商 [英] Babel not transpiling chunk-vendors for IE11, in Vue-CLI project

查看:92
本文介绍了在Vue-CLI项目中,Babel不为IE11移植块供应商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a Vue-CLI webapp that needs to support IE11. In package.json we have set:

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

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

and this seems to work for the generated app.x.js files: they don't contain any ... operators for instance.

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

However, the generated chunk-vendors.x.js do contain ... operators, and hence fail on IE11.

package.json的相关部分:

Relevant parts of the 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中没有相关更改,因此使用的是默认行为.

There are no relevant changes in vue.config.js, so the default behaviour is being used.

我需要更改哪些内容以确保将chunk-vendors.x.js转换为IE11?

What do I need to change to ensure chunk-vendors.x.js is transpiled for IE11?

推荐答案

答案似乎不是,而是确保所有依赖项都已转译"(这显然会引起很多问题),而是确保导致问题的特定依赖关系会被移植".

The answer seems to be, not so much "make sure all dependencies are transpiled" (which apparently can cause a lot of problems), but "make sure the specific dependencies which are causing issues are transpiled".

您可以通过在vue.config.js上添加一行来实现此目的:

You can do this by adding a line to vue.config.js:

transpileDependencies: ['/node_modules/myproblematicmodule/']

这篇关于在Vue-CLI项目中,Babel不为IE11移植块供应商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆