question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

decorator support

See original GitHub issue

Hi! I am trying to add mobx to a project, I have proper transformer added to my .babelrc, but the compilation keeps failing!

Here is my .babelrc

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
    '@babel/preset-stage-2',
    '@babel/preset-flow',
    '@babel/preset-react',
    "@babel/preset-es2015",
    "@babel/preset-stage-1"
  ],
  plugins: [
    "@babel/plugin-proposal-decorators"
  ],
  ignore: ['node_modules', 'build'],
};

Here is the error

ERROR in ./src/routes/admin/Admin.js
Module build failed: SyntaxError: /WorkSpace/opalcoin/opalweb/src/routes/admin/Admin.js: Support for the experimental syntax 'decorators' isn't currently enabled (16:1):

  14 | import {Provider, observer, inject} from 'mobx-react';
  15 |
> 16 | @observer
     | ^
  17 | @inject("uistore")
  18 | class Admin extends React.Component {
  19 |   static propTypes = {

Add @babel/plugin-proposal-decorators (https://git.io/vb4ST) to the 'plugins' section of your Babel config to enable transformation.
    at _class.raise (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:832:15)
    at _class.expectOnePlugin (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:2229:18)
    at _class.parseDecorator (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:4373:10)
    at _class.parseDecorators (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:4355:28)
    at _class.parseStatement (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:4203:12)
    at _class.parseStatement (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:6998:55)
    at _class.parseBlockOrModuleBlockBody (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:4764:23)
    at _class.parseBlockBody (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:4750:10)
    at _class.parseTopLevel (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:4174:10)
    at _class.parse (/WorkSpace/opalcoin/opalweb/node_modules/@babel/core/node_modules/babylon/lib/index.js:5613:17)
 @ ./src/routes/admin/index.js 13:0-28
 @ ./src/routes/index.js
 @ ./src/router.js
 @ ./src/client.js
 @ multi @babel/polyfill ./tools/lib/webpackHotDevClient ./src/client.js

This does look like a babel issue, but has anyone recently integrated mobx with react-starter-kit? Thanks a lot!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
MikeKovalcommented, Feb 7, 2018

I could make decorators work.

Here my .babelrc.js:

module.exports = {
  ...
  plugins: ['transform-decorators-legacy'],
};

webpack.config.js

....
plugins: [
            'transform-decorators-legacy',
...
]
...

messages.js

...
        plugins: ['react-intl', 'transform-decorators-legacy'],
....
1reaction
bronchacommented, Dec 9, 2018

@langpavel me too. No longer using decorators

Read more comments on GitHub >

github_iconTop Results From Across the Web

Decorators | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Documentation - Decorators - TypeScript
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use...
Read more >
How To Use Decorators in TypeScript - DigitalOcean
One of those extra features is decorator support. Decorators are a way to decorate members of a class, or a class itself, ...
Read more >
Native Decorator Support (3.10) | What's New in Ember
Native Decorator Support (3.10). Learn what Ember's commitment to Stage 1 Decorators means for your app code. What's New in Ember. 10 ...
Read more >
evanw/esbuild · GitHub - Feature request: Decorators support
So I'm not planning on supporting decorators based on the spec, at least not any time soon. Separate from that, decorators in TypeScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found