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]: If 'src' is in the path above the storybook repo core does not build #30403

Open
boylec opened this issue Jan 28, 2025 · 1 comment · May be fixed by #30404
Open

[Bug]: If 'src' is in the path above the storybook repo core does not build #30403

boylec opened this issue Jan 28, 2025 · 1 comment · May be fixed by #30404

Comments

@boylec
Copy link

boylec commented Jan 28, 2025

Describe the bug

'core' build process uses the replace method which causes things to fail if the storybook repo is in a path with 'src' above it on the local hard drive.

Reproduction link

Can't using storybook.new because its a pathing issue

Reproduction steps

  1. Clone storybook repo in ~/src/storybook
  2. Run yarn start

You will receive a build error and some files will be built to ~/dist/

This appears to be because of the use of .replace('src', 'dist') throughout some of the core prepare scripts against entry files. .replace will replace the first occurrence of 'src' with 'dist'.

To fix .replace should be replaced with a utility function the replaces last occurrence of 'src' with 'dist'

System

N/A

Additional context

No response

Copy link
Contributor

greptile-apps bot commented Jan 28, 2025

** Disclaimer** This information might be inaccurate, due to it being generated automatically
This is caused by naive string replacement in the build scripts. The fix requires updating the path handling in the build process to only replace the last occurrence of 'src' with 'dist'. Key changes needed: 1. Replace instances of .replace('src', 'dist') with a function that replaces only the last occurrence: js const replaceLastSrc = (path) => { const lastIndex = path.lastIndexOf('src'); if (lastIndex === -1) return path; return path.substring(0, lastIndex) + 'dist' + path.substring(lastIndex + 3); }; 2. Main locations to update: - scripts/prepare.js - Any build scripts in code/lib/core-* packages that handle path transformations This will prevent the build process from incorrectly transforming parent directory paths that contain 'src'.

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

@boylec boylec linked a pull request Jan 28, 2025 that will close this issue
8 tasks
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.

1 participant