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/theming does not work with Next.js #17957

Open
kylegach opened this issue Apr 13, 2022 · 3 comments
Open

@storybook/theming does not work with Next.js #17957

kylegach opened this issue Apr 13, 2022 · 3 comments
Assignees

Comments

@kylegach
Copy link
Contributor

kylegach commented Apr 13, 2022

Describe the bug

  1. Create new Next.js project
    • I also tested these steps in a fresh CRA project, which does not produce the error
  2. Add @storybook/theming@6.5.0-alpha.31 or later
    • @storybook/theming@6.5.0-alpha.30 or earlier does not produce the error (see commit history)
  3. Use within project
  4. Run yarn dev or yarn build

Here's the error:

Screenshot of error

To Reproduce

https://github.com/kylegach/storybook-theming-bundling-bug-2

System

Output
  System:
    OS: macOS 12.3
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 3.2.0 - ~/.nvm/versions/node/v16.13.2/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  Browsers:
    Chrome: 100.0.4896.88
    Firefox: 98.0
    Safari: 15.4
  npmPackages:
    @storybook/theming: 6.5.0-alpha.31 => 6.5.0-alpha.31

Additional context

I think these links are relevant:

@kylegach
Copy link
Contributor Author

Just noting that the @storybook/theming/dist/cjs/... path in that error is likely noteworthy. This is likely because Next.js is attempting to render the page on the server, in Node.

@thebuilder
Copy link
Contributor

I don't think you should be using anything related to Storybook outside your story files. This would include it in your production code. If you need to add global styles to pages, then you should add it as a decorator. Maybe in preview.js?

@kylegach
Copy link
Contributor Author

kylegach commented Apr 18, 2022

@thebuilder — Generally, you're absolutely correct. In this case, I'm using @storybook/theming for my project because it's part of the Storybook website and needs to be themed to match. This is the primary reason we distribute the package independently of the rest of Storybook, even though the Storybook UI itself is by far the biggest consumer.

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

4 participants