Greetings, community!
I'm trying to add transform-decorators-legacy to my project.
I have tried:
npm install babel-plugin-transform-decorators-legacy --save-dev
and add it to the package.json:
"babel": {
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
],
"stage-2",
"react"
],
"plugins": [
"transform-decorators-legacy"
],
"env": {
"test": {
"plugins": [
"rewire"
]
}
}
},
But that didn't work.
I also tried installing it using
yarn add babel-plugin-transform-decorators-legacy --dev
As mentioned here: https://github.com/kriasoft/react-starter-kit/issues/1110#issuecomment-279684371
But didn't work either.
The error was still there:
ERROR in ./src/XXXXXXX.js
Module build failed: SyntaxError: C:/Users/XXXXXX/XX/src/XXXXXX.js: Decorators are not officially supported yet in 6.x pending a proposal update.
However, if you need to use them you can install the legacy decorators transform with:
npm install babel-plugin-transform-decorators-legacy --save-dev
and add the following line to your .babelrc file:
{
"plugins": ["transform-decorators-legacy"]
}
The repo url is: https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy.
Is there something I should be aware of when I want to add transform-decorators-legacy to the project?
Thanks!
You need to add plugin here: tools/webpack.config.js#L69-L76
Babel configuration which mentioned in package.json used only for tools and tests.
@frenzzy
Thanks a lot!
You saved my day :)
Can someone enlighten me what it is for? I going to add in react as a plugin but know now what it is. I am beginner to javascript and react world.
You need to add plugin here: tools/webpack.config.js#L69-L76
Babel configuration which mentioned inpackage.jsonused only for tools and tests.
Can you show how to add the plugin here? I have done so but nothing happened?
Most helpful comment
Can you show how to add the plugin here? I have done so but nothing happened?