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

[Bug]: In Next project with the experimental-nextjs-vite we need to install @storybook/core in the user's package #29798

Closed
shilman opened this issue Dec 4, 2024 · 1 comment · Fixed by #29802

Comments

@shilman
Copy link
Member

shilman commented Dec 4, 2024

Describe the bug

Reproduction: https://github.com/storybookjs/storybook-rsc-demo/

Upgrade using:

npx storybook@next upgrade

You will get the error:

4:17:54 PM [vite] Pre-transform error: Failed to resolve import "@storybook/core/preview/runtime" from "/virtual:/@storybook/builder-vite/vite-app.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /virtual:/@storybook/builder-vite/vite-app.js:1:24
  1  |  import { setup } from '@storybook/core/preview/runtime';
     |                         ^
  2  |    import '/virtual:/@storybook/builder-vite/setup-addons.js';
  3  |  
4:17:54 PM [vite] Internal server error: Failed to resolve import "@storybook/core/preview/runtime" from "/virtual:/@storybook/builder-vite/vite-app.js". Does the file exist?
  Plugin: vite:import-analysis

Installing @storybook/core in package.json fixes the problem, but we shouldn't have to do that.

Reproduction link

N/A

Reproduction steps

No response

System

any?

Additional context

No response

@JReinhold
Copy link
Contributor

JReinhold commented Dec 4, 2024

This happens because of the faulty change from storybook/internal to @storybook/core here: https://github.com/storybookjs/storybook/pull/29172/files#diff-1dccfe4dfb3f001d9d6a83bd9f73476be42896870722a32c1c56cc54ac1c9ae9R70

It happens in all Vite-based sandboxes that uses pnpm because of its stricter dependency system - probably also happens in Yarn PnP as well. Basically the user's project depends on storybook, not @storybook/core, so it can't import from it in a strict environment. So it's not related to experimental-nextjs-vite.

I've confirmed that this doesn't happen in alpha.15, #29172 was released in alpha.16.

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

Successfully merging a pull request may close this issue.

2 participants