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.

[Bug]: Legacy decorator not parsed anymore on class (regression from 7.14)

See original GitHub issue

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

Similar code & conf than this REPL

except you have to set decorator to legacy (REPL does not save this parameter)

Configuration file name

none, babel-loader options

Configuration

See REPL above

Current and expected behavior

Current behavior

SyntaxError: /Foo.jsx: Unexpected token, expected "{" (43:7)

  41 | }) => isButton ? <button {...restProps} /> : <a {...restProps} />;
  42 |
> 43 | export @withRoute
     |        ^
  44 | class Foo extends React.Component {
  45 |   static propTypes = {

notice the export being before the decorator (in real code it is after)

Expected behavior

no error

Environment

  • Babel v7.15.3
  • Node v14
  • Webpack 5
  • babel-loader 8

Possible solution

No response

Additional context

I really do not understand why it fails with my base code and not in REPL, it is very disturbing 😦

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JSteunoucommented, Sep 6, 2021

Ok so pure linaria issue, can I close this issue and share your analyse?

1reaction
JSteunoucommented, Sep 3, 2021

@nicolo-ribaudo I made a repo with minimal code so you can help analyze this issue https://github.com/JSteunou/babel-linaria-decorator-issue

Our babel configuration might seems over-engineered but that is because we have a really large code base and I based this repo on it, keeping the same structure to be sure to keep everything that could help.

You can play with it and see that rolling back linaria to 1.4 solve it but not rolling back babel, so the issue is really on linaria side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When using legacy decorators, accessing a class in a static ...
[Bug]: When using legacy decorators, accessing a class in a static method of said class gives the non-decorated class #14245.
Read more >
@babel/plugin-transform-react-jsx | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
@babel/runtime: Versions | Openbase
Full version history for @babel/runtime including change logs.
Read more >
Support for the experimental syntax 'decorators-legacy' isn't ...
Is there a non-scoped package for plugin-proposal-decorators? I downgraded babel to babel 6 but I need this package to use mobx. All I...
Read more >
Change log for 4.11.0-rc.6 - Red Hat OpenShift
Bug 2060068: return error when no security group found #41 ... and add request decorator to CRUD functions #1687; Fix “api-version” query not...
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