Skip to content

[Bug]: Builders with implicit imports break monorepos with multiple SB versions #31545

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
vanessayuenn opened this issue May 22, 2025 · 1 comment

Comments

@vanessayuenn
Copy link
Contributor

vanessayuenn commented May 22, 2025

Describe the bug

Our virtual entry files for both builder-webpack5 and builder-vite currently import from 'storybook' directly:

import { setup } from 'storybook/internal/preview/runtime';
import '${SB_VIRTUAL_FILES.VIRTUAL_ADDON_SETUP_FILE}';
setup();
import { composeConfigs, PreviewWeb } from 'storybook/preview-api';
import { isPreview } from 'storybook/internal/csf';

These imports are relative to the project root, which can lead to the wrong version of Storybook being loaded in monorepo setups that include multiple versions. We should update builders to not rely on implicit, relative imports, but instead only accept the resolved path.

Copy link
Contributor

greptile-apps bot commented May 22, 2025

** Disclaimer** This information might be inaccurate, due to it being generated automatically
This issue requires modifying the import resolution in the virtual entry files for both builders: 1. In code/builders/builder-vite/src/codegen-modern-iframe-script.ts, replace direct imports from 'storybook' with resolved paths: ts // Replace import { composeConfigs } from '@storybook/preview-api'; // With import { composeConfigs } from '${resolvedStorybookPath}/preview-api'; 2. Add import resolution logic to both builders to determine the correct Storybook package path relative to the project being built. 3. Update the codegen functions to use these resolved paths when generating the virtual entry files. This will ensure the correct version of Storybook is loaded in monorepo setups with multiple versions.

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

@vanessayuenn vanessayuenn added this to the 10 milestone May 22, 2025
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

1 participant