Skip to content
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 5 breaks with Emotion 9 #6337

Closed
elliotdickison opened this issue Mar 28, 2019 · 6 comments
Closed

Storybook 5 breaks with Emotion 9 #6337

elliotdickison opened this issue Mar 28, 2019 · 6 comments

Comments

@elliotdickison
Copy link

Describe the bug

I'm working on react@16.3.x components that use emotion@9.2.x. I recently upgraded to @storybook/react@5.0.x, but when I boot it up I get the following runtime error:

Uncaught TypeError: Cannot read property 'length' of undefined
    at serializeStyles (main.3173126555acebfe0d1a.bundle.js:445)
    at css (vendors~main.ad7bd95803918bf0d539.bundle.js:643)
    at Module.keyframes (vendors~main.ad7bd95803918bf0d539.bundle.js:504)
    at Object../node_modules/@storybook/theming/dist/animation.js (vendors~main.ad7bd95803918bf0d539.bundle.js:7687)
    at __webpack_require__ (runtime~main.7b4918090cfe19b7778a.bundle.js:79)
    at Object../node_modules/@storybook/theming/dist/create.js (vendors~main.ad7bd95803918bf0d539.bundle.js:7845)
    at __webpack_require__ (runtime~main.7b4918090cfe19b7778a.bundle.js:79)
    at Object../node_modules/@storybook/theming/dist/index.js (vendors~main.ad7bd95803918bf0d539.bundle.js:8126)
    at __webpack_require__ (runtime~main.7b4918090cfe19b7778a.bundle.js:79)
    at Object../node_modules/@storybook/router/dist/visibility.js (vendors~main.ad7bd95803918bf0d539.bundle.js:7643)

I dug into it and it appears that this is due to the fact that storybook is pulling in @storybook/theming, which is in turn pulling in emotion 10, which does not play nice with emotion 9.

To Reproduce

Install Storybook 5 in a project that uses Emotion 9.

Expected behavior

I would expect to be able to drop components into Storybook without having to use the same css-in-js library/version as Storybook.

Additional context

Thanks for the great work on storybook!

@shilman
Copy link
Member

shilman commented Mar 29, 2019

@elliotdickison What addons are you using?

@elliotdickison
Copy link
Author

No addons, @storybook/react@5.0.5 is my only storybook dependency.

@shilman
Copy link
Member

shilman commented Mar 29, 2019

Storybook runs two separate webpacks: one for the "preview" (user code, running in an iframe) and a second for the "manager" (UI wrapping that iframe). AFAIK the preview has no dependency on emotion unless you happen to be using a buggy addon (which you're not). So this makes me think that simply running emotion 9/10 together in the same browser window, even if they are in different iframes, is causing an issue.

I could be wrong since I'm not an emotion expert (and since there are lots of moving parts). But if that's the case, what would you suggest we could do differently, short of not using emotion to theme our UI?

@elliotdickison
Copy link
Author

That is good to know. It sounds like this is more likely an emotion issue. I'll close for now, thank you for the help!

@qoalu
Copy link
Contributor

qoalu commented Apr 23, 2019

having this issue @elliotdickison , did you file an issue to emotion?

@elliotdickison
Copy link
Author

I did not, I was never really able to get to the bottom of it. Our plan is to just upgrade to emotion 10 when we upgrade storybook since we’re using the framework-agnostic API that didn’t change between 9 and 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants