-
-
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
Storybook 6.1.0-rc.4 & Emotion 11.0 support #13145
Comments
Does this workaround help? chakra-ui/chakra-ui#2527 (comment) |
sadly no. :(
|
FYI - i'm not actually using any emotion theming atm. I'm simply using the "framework agnostic" flavour of emotion (https://emotion.sh/docs/introduction) |
@shilman just putting more info here, I also need to update my lib to emotion-11 and my problem lies on Analysing the final bundled code from storybook, looks like the webpack is serving the old styled package instead of the new one: As you can see on the following image running the SB with Emotion-11, the path is pointing to the old version of emotion. The expected path should be: The problem might be here? https://github.com/storybookjs/storybook/blob/next/lib/theming/paths.js The current side effect of this in my project is: because internally, the ThemeProvider is using the |
FWIW - When running with all updated deps (as above) and the following alias inside .storybook/main.js:
i get the following logs when starting storybook:
|
looks like this is being worked on atm. #13300 |
I changed webpack.config in Storybook and it helped! const toPath = (_path) => path.join(process.cwd(), _path) module.exports = { |
Still not working for me either. I'm getting this error:
My main.js:
And inside my failing module:
|
I published my package on npm (mavlikwowa.ui) and github: https://github.com/mavlikwowa/mavlikwowa.ui |
So somehow, by splitting storybook out from the components repo that utilises it, i now no longer see any of these issues. So I feel like from my end, this ticket can be closed. |
Thanks for sharing that link. My versions are:
My alias block is identical to yours, but they are not being honored. @mavlikwowa can I assist in any way by providing you any specific additional information? |
I successfully managed to do this in the Next Right Now boilerplate, at UnlyEd/next-right-now#251 (I wasn't aware of this issue until now). Next Right Now uses Emotion 11, while its associated Storybook uses Emotion 10, this complicates things. (see Note below) Here are my findings: The underlying issue is due to Emotion 11 webpack configuration, which can use a Babel setup in either classic or automatic modes, or JSX pragma. JSX pragma requires Creating a
/**
* Babel configuration for Storybook
*
* Doesn't affect Next.js babel configuration, specific file for Storybook only.
* Need to apply Emotion babel configuration, otherwise Emotion "css" cannot be used in Storybook.
*
* XXX We use the "classic" way instead of the "automatic" way for Storybook, that's because MDX isn't compatible with "automatic".
*
* @see https://emotion.sh/docs/css-prop#babel-preset Configuring Emotion 11
*/
module.exports = {
"presets": ["@emotion/babel-preset-css-prop"]
}; If this fix doesn't work for you, or you encounter issues, I suggest studying what I did at https://github.com/UnlyEd/next-right-now/pull/251/commits (commit by commit), in particular:
|
I fell into a similar issue but it was with
The issue I think is that my
My Fix
By using this
https://storybook.js.org/docs/react/configure/theming Sorry in advance that my grammar is complete poo. |
@shilman Is this issue being worked on? |
@pixelass you can take a look at this repository: https://github.com/openpatch/patches. In this repository I have a working storybook 6.1.21 and emotion 11. Take a look at the main.ts for how I have setup it up: https://github.com/openpatch/patches/blob/main/.storybook/main.ts. |
This is a breaking change to Storybook 6.x users so the workaround will have to do for the moment. It seems like this is a major obstacle for users, and I see two possible paths forward: Direct support. There is an open PR for Emotion 11 #13300, and I could merge this and release it as an early 7.0 prerelease while the 6.x proceeds as scheduled. I don't think this is realistic. We could also release 7 earlier, which also conflicts with our plans. Custom theming. There is also a staled-out PR for a custom theming implementation: #10438. This is nice because it should eliminate this conflict in both the short and long term, even as Storybook/Emotion evolve on different timelines. I'll try to prioritize this as part of 6.3. |
Thank you for looking into this @shilman! |
@rrsai I have added My VersionsI am using yarn and overrode my dependencies in {
....
"resolutions": {
"@storybook/**/@emotion/styled": "^11",
"@storybook/**/@emotion/core": "^11",
"@storybook/**/@emotion/sheet": "^1"
} I got all Also (from
ErrorI get errors like the following:
Analysis
|
I would not use the resolutions while the feature flag is in place @Domiii . In the end including only the : module.exports = { features: { emotionAlias: false }, ... …in main.js provided the correct behavior. |
@tchalvak If you don't force the version, how can you make sure, which version your build is currently using? Can you please verify that you are on If you don't have |
FWIW, we also found that We upgraded to Storybook 6.4 (PR) and added the Not sure if this |
@robinmetral Why do you alias |
I've tried to remove the aliases but it looks like Emotion can't find our theme afterwards 🤷 we had these for a while and they seem to work, so we figured that we'll keep them until proper compat instead of fighting with our config for hours 😛 |
Hello @robinmetral, I had a similar issue when setting up the storybook with the recent version and theme. However, there seems to be a conflict with versioning from the emotion theme provider and @storybook/theming version. Storybook favored ThemeProvider from ~Let me know if you have any issues! |
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! |
I'm commenting here because the last comment was 29 days ago and stalebot is lurking! |
I'm also still very confused as to how to make the supposed workaround work? I tried it and it errors out as described here because the To explain:
|
Switching to
|
FYI we are working on a proper fix for this--not a workaround--hopefully arriving in the next few days. |
rocket emoji |
Hi guys. Not sure if this issue is related to this but at least it's about emotion and storybook. If it will make sense I'll open a new issue. The issue is happening when you are using We are using in project Here is a repo with reproduction In If there is any import storybook in After fun hours of debugging I found out that issue happens because Here is also a minimal repro in codesandbox I'm not sure what possible solutions could be, like enforcing types from emotion 11, I'll appreciate any suggestions on how it could be hotfixed. Casting I'm feeling that issue lies in storybook land as it seems to be only one proper way is to bump emotion version in storybook packages to fix those type conflicts. Unless I'm missing something. Update: Fix is in emotion@11 but there are some suggestion on hotfixing storybook with emotion@10 |
Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.31 containing PR #17000 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
I just tried with module.exports = {
framework: '@storybook/react',
core: {
builder: 'webpack5',
},
features: {
emotionAlias: false,
},
addons: [
// ...
]
}; And I can confirm that I can successfully:
Very great improvement @shilman @ndelangen, thanks a lot guys 🙌 |
|
Yes, if I follow the thread, I think migrating to @emotion v11 is still a BC breaking change and cannot be achieved in Storybook v6. That fix though should solve conflict problems between the emotion version used by Storybook and the one used by your own UI library :) |
Hey guys, I was facing the same problem and I tried so many things that I didn't remember how much time I've spent to fix this, and finally, I figured out how to build Storybook + Emotion 11 properly. Before we continue, I just want to say that I'm working on a shared lib component with Emotion 11 + Storybook + JEST + Babel. First I updated the Storybook version to the pre-release as @shilman told above: npx sb upgrade --prerelease Here is my package.json after the upgrade: "@storybook/addon-a11y": "^6.5.0-alpha.41",
"@storybook/addon-actions": "^6.5.0-alpha.41",
"@storybook/addon-docs": "^6.5.0-alpha.41",
"@storybook/addon-essentials": "^6.5.0-alpha.41",
"@storybook/addon-links": "^6.5.0-alpha.41",
"@storybook/addon-storyshots": "^6.5.0-alpha.41",
"@storybook/addon-storysource": "^6.5.0-alpha.41",
"@storybook/addons": "^6.5.0-alpha.41",
"@storybook/node-logger": "^6.5.0-alpha.41",
"@storybook/react": "^6.5.0-alpha.41",
"@storybook/testing-react": "^1.2.3",
"@storybook/theming": "^6.5.0-alpha.41", I also have these peerDependencies: "peerDependencies": {
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@types/react": "^16.8.6 || ^17.0.0",
"react": "^17.0.0",
"react-dom": "^17.0.0"
}, After that, I changed my storybook config to look like this: .storybook/main.js module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|mdx|tsx)'],
framework: '@storybook/react',
core: {
builder: 'webpack4',
channelOptions: { allowFunction: false, maxDepth: 10 }
},
features: {
emotionAlias: false
},
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-a11y',
'@storybook/addon-storysource',
{ name: '@storybook/addon-docs', options: { configureJSX: true } },
'@storybook/addon-controls'
],
webpackFinal: async config => {
// React preset + Emotion props
config.module.rules[0].use[0].options.presets = [
require.resolve('@babel/preset-react'),
require.resolve('@babel/preset-env'),
require.resolve('@emotion/babel-preset-css-prop')
];
return config;
}
}; Hope this helps you guys! |
Describe the bug
When you upgrade emotion (@emotion/css) to version 11.0 - storybook seems to build successfully, but on every single set of stories, simply renders this error screen:
To Reproduce
@emotion/css
and@emotion/babel-plugin
@emotion/css
npm run build-storybook
Code snippets
System
The text was updated successfully, but these errors were encountered: