-
-
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
addDecorator doesn't work on config.js #7058
Comments
Do you have some custom webpack config? I suppose not, since you're using CRA, but I figure I'd ask anyway. If I try that in one of our examples it works just fine, so I'm puzzled why it's not working for you. |
You can fix it by adding preset-env and preset-react to your babel config. I'm not sure why you need to do this. 😭 |
I think the problem is CRA. addDecorator works fine after I set up my react project with webpack. |
@shilman @chingchinglcc I had similar problem. Storybook has @babel/core and babel-loader in its peer dependencies and relies on you to install them. Check this link https://storybook.js.org/docs/guides/guide-react/ |
This fixed it for me. I also am unclear on why we need to do this. Everything was working just fine with storybook 5.0, but as soon as I upgraded to the 5.1 releases it stopped working. Smells like someone made a breaking change. |
Yes. It fixed for me as well. |
@ZebraFlesh These are the two explicitly babel-related changes in 5.1. I don't see anything suspicious here, but if anybody wants to dig in, this might be a good place to start: #6634 #6878 These workarounds are not required for every project, so it would be useful to understand what's in common with all the projects here. Are they all CRA projects? What version? @chingchinglcc @ZebraFlesh @Yankovsky |
Mine is hand rolled, not CRA. |
Looking over those PRs and combining it with the behavior I’m seeing, it looks SB 5.1 is loading my root babel.config.js file. Previously this only had a simple @babel/preset-env preset; due to a lack of preset-react, JSX wouldn’t parse. I do not have a custom babel config file in the .storybook config folder. This is hard, because I really wanted the fix from the first PR for a different project. 😢 |
More detailed steps to reproduce now that I'm not on my phone:
I'm not sure if step 3 is necessary, but I've included it for completeness. |
Definitely still an issue |
Good news, I think @mrmckeb is going to fix this! |
OK here's what's happening: #6634 was an unintentional breaking change. If you used a The change was a weird, inconsistent one. The code should probably either read:
OR
Now we're in a funny situation where if we fix it the first way, we'll break a lot more people. The second one is also a breaking change since we're removing support for project-level config. My vote is the second fix. And potentially adding the first fix as part of 6.0. Thoughts @ndelangen @ZebraFlesh @igor-dv ? |
I think if it was a break change we need to fix it back and wait for the v6. |
Reading the discussion on the PR by @LukeAskew, it was never supposed to load from the project root. |
Yo-ho-ho!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-beta.10 containing PR #7573 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Shiver me timbers!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.1.10 containing PR #7573 that references this issue. Upgrade today to try it out! |
Somehow project root Reopening this 😭 |
@ZebraFlesh @chingchinglcc can you give an example fix for this? thanks |
@justinlazaro-iselect Does creating module.exports = {
presets: [
"@babel/preset-env",
"@babel/preset-react"
]
}; |
Fixed for me |
Hey @shilman This still doesn't work from me. I'm using v5.3.18 and it's still picking the babel.config.js from the root directory. Specifying custom |
@ravikp7 have you tried 6.0-beta? |
@shilman I just tried v6.0.0-beta.8, it is also picking up the root babel.config.js Let me know if I can provide more debugging info or can contribute in any way to help fix this :) |
@ravikp7 do you have a Add a module.exports = {
babel: async (babelConfig) => {
// do anything with the babel config for preview
return babelConfig;
},
}; That should allow you to change the babel config exactly to your liking. I assume you have a monorepo and there's many babel configs in your project? |
@ndelangen Thanks for this! I don't have a monorepo, it's a react project setup with react-boilerplate. Currently, I don't have an issue with the root babel.config.js being picked up in storybook as I changed the config which was conflicting with storybook. I'm not sure if this is the expected behavior with storybook that it picks root babel.config.js |
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! |
|
Describe the bug
I am trying to implement some global style. And I think config.js is the good place to put my code. I copied the addDecorator from the official storybook doc to test. But it shows the error:
I am using the create-react-app and
@storybook/react": "^5.1.3
It is a problem with Create-react-app?
The addDecorator works fine on individual components but it does not work on config.js
The text was updated successfully, but these errors were encountered: