所以我安装了最新版本的Babel / core和Babal-loader,因为我正尝试升级到Webpack 4,但是它说:
Plugin/Preset files are not allowed to export objects, only functions.
当我在开发人员模式下运行Webpack时。我不能真正降级,因为那样Webpack 4将无法工作。这是我的开发依赖项:
devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-es2015": "^7.0.0-beta.53",
"acorn": "^6.1.1",
"ajv": "^6.10.0",
"autoprefixer": "6.7.2",
"babel-eslint": "7.1.1",
"babel-loader": "8.0.5",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "6.22.0",
"babel-register": "6.22.0",
"bootstrap": "4.3.1",
"bootstrap-loader": "3.0.4",
"chalk": "1.1.3",
"compression-webpack-plugin": "2.0.0",
"connect-history-api-fallback": "1.3.0",
"copy-webpack-plugin": "5.0.3",
"css-loader": "2.1.1",
"eslint": "3.14.1",
"eslint-config-standard": "6.2.1",
"eslint-friendly-formatter": "2.0.7",
"eslint-loader": "2.1.2",
"eslint-plugin-html": "2.0.0",
"eslint-plugin-promise": "3.4.0",
"eslint-plugin-standard": "2.0.1",
"eventsource-polyfill": "0.9.6",
"exports-loader": "0.6.4",
"express": "4.14.1",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "0.10.0",
"friendly-errors-webpack-plugin": "1.7.0",
"function-bind": "1.1.0",
"html-webpack-plugin": "3.2.0",
"http-proxy-middleware": "0.17.3",
"imports-loader": "0.8.0",
"mini-css-extract-plugin": "^0.6.0",
"node-sass": "4.12.0",
"opn": "4.0.2",
"optimize-css-assets-webpack-plugin": "5.0.1",
"ora": "1.1.0",
"popper.js": "^1.15.0",
"postcss-input-range": "github:whatknight/postcss-input-range#bugfix",
"postcss-loader": "3.0.0",
"resolve-url-loader": "2.0.2",
"rimraf": "2.6.0",
"sass-loader": "7.1.0",
"semver": "6.0.0",
"style-loader": "0.14.1",
"url-loader": "0.5.8",
"vue-loader": "15.7.0",
"vue-style-loader": "2.0.0",
"vue-template-compiler": "2.3.3",
"webpack": "4.30.0",
"webpack-bundle-analyzer": "3.3.2",
"webpack-dev-middleware": "3.6.2",
"webpack-hot-middleware": "2.24.4",
"webpack-merge": "4.2.1"
},
这是我的babelrc:
{
"presets": ["stage-2", "@babel/preset-env"],
"plugins": ["transform-runtime"],
"comments": false
}
这是导致问题的部分:
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
include: [resolve('src'), resolve('test'), resolve('node_modules/vue-awesome'), resolve('node_modules/vue-uploader')],
use: {
loader: 'babel-loader',
options: {
presets: ['stage-2', '@babel/preset-env']
}
}
},
我该怎么办?
答案 0 :(得分:0)
'stage-2'
预设适用于Babel6。由于您使用的是Babel 7,因此将失败。舞台预设已在Babel 7中完全删除(https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets)。您应该安装实际要使用的特定投标插件。