Skip to content

[Bug]: Storybook builders use imports incorrectly #31558

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

Open
yannbf opened this issue May 23, 2025 · 1 comment
Open

[Bug]: Storybook builders use imports incorrectly #31558

yannbf opened this issue May 23, 2025 · 1 comment
Labels
bug builder-vite builder-webpack5 internal-qa This issue was reported by the Storybook team, potentially on unreleased or prerelease software. needs triage

Comments

@yannbf
Copy link
Member

yannbf commented May 23, 2025

Describe the bug

This is a subtle issue, but it could hit anyone using multiple Storybooks in a monorepo with differing versions.

Storybook's virtual entry files created by both builder-webpack5 and builder-vite do a direct import of storybook (webpack, vite).

That virtual file is executed at the project root, and not at the location of the builder's node module. This means the import will resolve to node_modules/storybook which is not at all guaranteed to be the right version of the Storybook you're running.

Those virtual entry files should be updated to take the resolved path to the storybook package as input.

This might not be the only place this sort of thing happens, so we should take a deeper look into it.

Reproduction link

Reproduction steps

No response

System

-

Additional context

No response

@yannbf yannbf added bug builder-webpack5 needs triage builder-vite internal-qa This issue was reported by the Storybook team, potentially on unreleased or prerelease software. labels May 23, 2025
Copy link
Contributor

greptile-apps bot commented May 23, 2025

** Disclaimer** This information might be inaccurate, due to it being generated automatically
This requires changes in two locations: 1. In builder-webpack5/templates/virtualModuleModernEntry.js, replace: js import { renderToCanvas } from 'storybook'; with a template variable that takes the resolved path: js import { renderToCanvas } from '<%- storybookPackagePath %>'; 2. In builder-vite/src/codegen-modern-iframe-script.ts, replace: ts import { renderToCanvas } from 'storybook'; with: ts import { renderToCanvas } from '${storybookPackagePath}'; The resolved package path should be passed in when generating these virtual modules from the respective builders.

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Edit Issue Bot Settings · Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug builder-vite builder-webpack5 internal-qa This issue was reported by the Storybook team, potentially on unreleased or prerelease software. needs triage
Projects
None yet
Development

No branches or pull requests

1 participant