gpt4 book ai didi

vue.js - 将 "proposal-object-rest-spread"插件添加到 babel.config.js 以修复 Microsoft Edge 错误 SCRIPT1028

转载 作者:行者123 更新时间:2023-12-04 05:28:03 27 4
gpt4 key购买 nike

编辑:这个问题似乎在 Microsoft Edge Chromium 的新测试版中得到解决。 (2020 年 1 月 18 日)

我需要添加这个 Babel plugin babel.config.js 摆脱微软 边缘 浏览器错误

SCRIPT1028: Expected identifier, string or number



我安装了最新的软件包并将它们添加到 package.json。
以下是我尝试过的,但在运行后没有转换代码 npm 运行构建 :

babel.config.js
require("@babel/core").transform("code", {});

module.exports = {
presets: ["@vue/app"],
plugins: ["@babel/plugin-proposal-object-rest-spread"]
};

package.json
{
"name": "example",
"version": "0.2.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@babel/polyfill": "^7.6.0",
"core-js": "^2.6.5",
"date-fns": "^2.4.1",
"firebase": "^7.0.0",
"lodash": "^4.17.15",
"register-service-worker": "^1.6.2",
"vue": "^2.6.10",
"vue-flickity": "^1.2.1",
"vue-router": "^3.0.3",
"vuetify": "^2.0.0",
"vuex": "^3.0.1"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-plugin-pwa": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"@vue/eslint-config-prettier": "^5.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-vue": "^5.0.0",
"material-design-icons-iconfont": "^5.0.1",
"prettier": "^1.18.2",
"sass": "^1.17.4",
"sass-loader": "^7.1.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"terser-webpack-plugin": "^2.1.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"vue-cli-plugin-vuetify": "^0.6.3",
"vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.2.2"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"@vue/prettier"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

如何设置 Babel 插件以正确转换代码?

编辑:错误截图 - EDGE INSIDER 18 指向这段代码:
Error: EDGE INSIDER 18 points to this piece of code.

最佳答案

由于我无法尝试检查您正在处理的代码,因此我建议使用库配置中提到的以下 babel 配置:

  plugins: [["@babel/plugin-proposal-object-rest-spread", { "loose": true, "useBuiltIns": true }]]

关于vue.js - 将 "proposal-object-rest-spread"插件添加到 babel.config.js 以修复 Microsoft Edge 错误 SCRIPT1028,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58578878/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com