react-starter-kit icon indicating copy to clipboard operation
react-starter-kit copied to clipboard

Add transform-decorators-legacy to the project

Open visualskyrim opened this issue 9 years ago • 4 comments

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!

visualskyrim avatar Mar 06 '17 02:03 visualskyrim

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 avatar Mar 06 '17 06:03 frenzzy

@frenzzy Thanks a lot! You saved my day :)

visualskyrim avatar Mar 06 '17 07:03 visualskyrim

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.

badarshahzad avatar Jul 11 '18 05:07 badarshahzad

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.

Can you show how to add the plugin here? I have done so but nothing happened?

Waqar-Ul-Khaf avatar Oct 10 '18 13:10 Waqar-Ul-Khaf