-
Notifications
You must be signed in to change notification settings - Fork 124
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
designTokensTable causes app crush #140
Comments
I'm having issues reproducing this. What Storybook version are you using? |
6.5.12 |
I ran into a similar issue recently. Seems to be related to storybookjs/storybook#7914 |
Uses this theme property too, which seems to be the problem. This also does look like a valid Storybook theme property: Maybe not having that set in a custom theme is the issue? Reading the docs on SB Theming (https://storybook.js.org/docs/react/configure/theming) it suggests that custom themes can use the default 'light' or 'dark' themes as a base, but neither of those necessarily include that property either and that when theming:
So, if this add on requires a value not provided in a custom theme, that could be source of the error. I'll try to confirm this by adding that value to our theme and see what happens. Update: nothing happens, this was a bit of a naive comment. Sorry. Definitely looks like having multiple versions of Emotion is the culprit IMO. I believe the use of MDX Doc Blocks adds a copy and blows away Theme from ThemeProvider, hence no property found. If that's the case, I wonder if it's better if @storybook/theming is listed as a peer dependency? (It basically just wraps Emotion) - in which case it wouldn't be loaded a second time? |
I tried to create a fork from Main but had trouble running build - got several errors. Unsure what the exact dev process is and can't find documentation on contributing for this addon. Emotion maintainers recommend including it only as a peer dep to avoid the 'multiple copies of Emotion issue' - but in this case Emotion is bundled in @storybook/theming so I suppose that would need to be unbundled here as well? Storybook docs aren't totally clear, but they seem to suggest that Storybook addons should include other addons as peer dependencies as well. I'd be happy to try a PR but I'm not sure how to duplicate this weird edge case for testing. I should note, broadly updating Storybook seems to fix this issue, but that might be incidental. I'll check the changelog for @storybook/theming to see if there's an insight there re how they import/bundle Emotion. |
I‘m busy right now making the addon compatible with SB 7. I‘ll try to fix the theming issues with the next release. |
I was able to reproduce the issue when using the Vite builder. It seems to work fine with Webpack. @yarinsa @YoungElPaso Which builder are you using? |
@Sqrrl Vite |
@Sqrrl webpack. But basically you were correct in your original referenced Storybook issue I think. There's some Storybook addons that depend on @storybook/theming v6.15.5 and if you're not careful and use semver range (^) it's easy to upgrade to those, which at least my case, clashed (without error at npm install) with your addon's use of v6.15.13 (which wasn't upgraded). So in my case, I had a package-lock.json file that included references to both versions, which conflict and is a well known issue with Emotion (the package that is wrapped by @storybook/theming) and therefore in the Storybook bundle I get the 'you have 2 copies of Emotion' warning- see screenshot below, and see this issue: emotion-js/emotion#2639). Storybook itself uses the new version, which clobbers the version bundled in your addon. Thus no I suspect people run into this issue when they have the Storybook dependencies listed in package.json with the ^ range and delete their lock file, and in doing some unrelated work run For me, there's two possible solutions that both have worked so far, check these out @yarinsa :
The second approach is probably the best as it will result in a cleaner diff and better history for the lockfile while allowing the use of semver ranges with the core Storybook addons. That said, if you have time in the future, though this is basically an upstream issue, I wonder if making this addon only have @storybook/theme as a peer dep would work better to avoid this scenario? 🤷 Good Bad 'Double' Emotion warning in console, with broken Token Docs: My conclusion: This is a pretty subtle bug and took a long time to figure out but basically AFAIK isn't an issue ultimately with this repo but with adhering more strictly to npm best practices and being careful about ranged dependencies. Since the |
I am getting the following error:
I traced back and it seems like its expecting me to have theme.color.defaultText (which is not even storybook theme interface).
Willing to help with the fix
The text was updated successfully, but these errors were encountered: