我正在尝试使用web-pack捆绑一个react应用,该Web-pack使用babel loader编译由于语法错误而失败的jsx文件。
handleClick = () => {
this.props.handleFixedClick();
};
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (37:14)
35 | }
36 |
> 37 | handleClick = () => {
| ^
38 | this.props.handleFixedClick();
39 | };
40 |
我尝试将babel-loader版本更改为7.15,但毫不费力。以下是我的web-pack.config.js。
test: /\.jsx?/,
loader: 'babel-loader',
exclude: /node_modules/,
query:{
presets: ['react','es2015']
}
以下是我的package.json
"@babel/core": "^7.5.5",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",