Description
Note from maintainers
For people coming to this thread later—if you use MobX or a similar library, you don’t need decorators. They are just syntax sugar in this case.
Learn more: #214 (comment), #411 (comment).
Here is why we don’t include them: #411 (comment).
In the project created by create-react-app
, I want to add some code with ES Next decorators. So, I installed babel-plugin-transform-decorators-legacy
and babel-preset-stage-1
with npm, and created a .babelrc
file in the project root folder.
npm start
doesn't work and it reports like this
Module build failed: ReferenceError: [BABEL] /Users/morgan.cheng/test/create-react-app-demo/mobx/src/index.js: Unknown option: /Users/morgan.cheng/test/create-react-app-demo/mobx/node_modules/react/react.js.Children. Check out http://babeljs.io/docs/usage/options/ for more info
The error message doesn't tell much about the root cause.
And below is .babelrc
and package.json
file.
.babelrc
{
"name": "mobx",
"version": "0.0.1",
"private": true,
"devDependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-stage-1": "^6.5.0",
"react-scripts": "0.1.0"
},
"dependencies": {
"react": "^15.2.1",
"react-dom": "^15.2.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject"
}
}
package.json
{
"presets": [
"react",
"es2015",
"stage-1"
],
"plugins": [
"transform-decorators-legacy"
]
}
Any hint to attack this problem?