-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorators syntax usage is broken #6069
Comments
This likely has to do with legacy implementation of
|
I've tried to set up this and I got another error:
Can not use the new decorator's implementation because of mobxjs/mobx#1352. @mweststrate maybe you have a solution for this one? |
|
There you go - https://github.com/darkowic/storybook-mobx-decorators-example I was able to reproduce it in react-create-app based example. Thanks! |
@darkowic this is not what maintainers typically call a minimal reproduction ;-). Can you link to the babel config in that repo? Edit: or is a blank storybook that large? Sorry, zero experience with storybook, just wanted to peek at the babel config to see if there is something obvious |
Well :D Actually what I post in the first commit is IMHO the minimal In the repo is only ejected CRA, initiated storybook with https://github.com/storybooks/storybook/tree/next/app/react and added babel config to
The actual code that reproduces it is in
There have to be something with storybook internals, I guess. Probably MobX itself is doing nothing wrong here. I ping you after @pgoforth comment because I thought that maybe you've seen similar case before. Let's wait for some maintainers answer @shilman |
Looks superficially fine (assuming it is using babel 7, not 6). Maybe the config is not picked up at all from that place? Anyway, leaving it to the storybook maintainers for now... :) |
I forgot about it - storybook does not read config from I've updated the example. The issue still there. |
@darkowic I did notice one thing. When using |
@darkowic note that error in the screenshot actually signals that it should be in loose mode, which is also in your config, which seems to suggest the config isn't actually picked up? MobX requires loose mode, that is correct. It seems that that is what storybook expects as well from the above message. (loose mode is also the typescript behavior, and with loose mode it is easier to change descriptors with decorators, which is harder in strict mode, which seems to be a problem with the spec that sadly not everybody agrees upon, but it's on hold now anyway) |
The config is picked. When I break anything in the babel config, storybook will throw that cannot read the config. |
@darkowic
I realize you need to use legacy decorators, but maybe there's a different legacy config that will work for you. |
You guys are awesome, not sure what to add here. I'm working on some tools/process for debugging webpack issues right now #6081. Hopefully it will help but this is fundamentally complex stuff 😦 |
@shilman @darkowic @mweststrate |
Just met the same issue with The issue is about the order of overriding options passed to {
"plugins": [
["@babel/plugin-proposal-decorators"],
["@babel/plugin-proposal-class-properties", { "loose" : true }],
]
} The default option for The babel configuration from The work-round for me is to eject |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
@darkowic I can't tell if you found the solution to your issue, but I was experiencing the same problem. After struggling for a while, I found this comment babel/babel#8577 (comment) which helped lead me to the solution that worked for me. Adding the plugins to |
FYI: Storybooks 5.1 solved the issue in my project. Though, I did not test it in the repository I created. |
I have got a solution 😄 Try add to
After this common babel config got applied. |
Should it be in place in default |
I'm also using create-react-app, mobx and storybook and having issues with decorators. I managed to get around this by having duplicate
The second
I had to give everything alias name so it didn't clash with the root level babelrc. So far things look good.... |
@richardwardza Tried every solution around and yours is the only one that worked for me, Thaks a Lot!! |
Can someone help me with this same issue please? I'm using CRA with react-app-rewired. The config files are as follows. .storybook/main.js
config-override.js
I don't have bable plugin currently in my package.json file right now. Do let me know what I can do about it right now, thank you! |
Describe the bug
When trying to write a story that contains code using decorators syntax (In this case Mobx - the decorators works totally fine in the project) it throws an error:
The babel configuration in
.babelrc
is correct, the file is read:To Reproduce
Steps to reproduce the behavior:
Expected behavior
Decorators can be used.
System:
The text was updated successfully, but these errors were encountered: