为什么 babel-preset-env 不接受箭头功能?
.babelrc configuration reference
{
"presets": [
"react",
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
"safari >= 7"
]
},
"debug": true,
"modules": "commonjs",
"include": [
"transform-es2015-arrow-functions",
"es6.map"
],
"exclude": [
"transform-regenerator",
"es6.set"
]
}
]
],
"plugins": [
"transform-es2015-destructuring",
"transform-object-rest-spread"
]
}
的package.json
{
"name": "myapp",
"version": "0.1.0",
"main": "index.js",
"private": true,
"dependencies": {
"babel-core": "6.25.0",
"babel-loader": "7.1.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"css-loader": "0.28.4",
"file-loader": "0.11.2",
"react": "^15.6.1",
"react-datepicker": "^0.52.0",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.1.2",
"react-router-dom": "^4.1.2",
"webpack": "3.5.1",
"webpack-dev-server": "2.7.1",
"webpack-node-externals": "^1.6.0"
},
"scripts": {
"build": "webpack"
},
"devDependencies": {
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0"
}
}
答案:完全正常工作.babelrc
{
"presets": [
"react",
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
"safari >= 7"
]
},
"debug": true,
"modules": "commonjs"
}
]
],
"plugins": [
"transform-object-rest-spread",
"transform-class-properties"
]
}