[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:
- Created 2 years ago
- Comments:12 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok so pure linaria issue, can I close this issue and share your analyse?
@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.