Core: resolve builder preset path correctly in pnpm strict mode#33750
Core: resolve builder preset path correctly in pnpm strict mode#33750braedenfoster wants to merge 5 commits into
Conversation
Use resolvePackageDir instead of dirname when resolving builder preset paths.
This fixes preset resolution in pnpm monorepos with shamefully-hoist=false.
The issue occurs because dirname('@storybook/builder-vite') returns '@storybook',
which is not a valid package path. Using resolvePackageDir properly resolves
the full package directory path, allowing the preset.js file to be found.
Fixes storybookjs#33748
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaced use of Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Package BenchmarksCommit: No significant changes detected, all good. 👏 |
|
Thank you for your contribution! Some of our mocking-related tests seem to fail due to that change. Would you mind taking a look? |
Sure, I'll take a look 👍 |
|
@braedenfoster Let me know if you need any help. |
|
Closing due to inactivity. Just open a new PR if you plan to bring it over the finish line :) |
Cheers. My apologies, I am struggling to get the time to work on this. For now, I have a local patch that fixes this issue for me. I'll aim to open a new PR when I have some time if it's still unresolved. |
What I did
Fixed builder preset path resolution in pnpm monorepos with strict module resolution (
shamefully-hoist=false).Problem
The current code uses
dirname(builderName)to construct the path to the builder's preset file. WhenbuilderNameis@storybook/builder-vite,dirname()returns@storybook, which is not a valid package path and causesERR_MODULE_NOT_FOUNDerrors in pnpm's strict resolution mode.Solution
Changed
dirname(builderName)toresolvePackageDir(builderName)on line 66 ofcode/core/src/core-server/load.ts. This properly resolves the full package directory path, allowing the preset.js file to be found.The
resolvePackageDirfunction is already imported and used elsewhere in the same file (line 73), so this change maintains consistency with existing code patterns.Testing
shamefully-hoist=false@storybook/builder-viteand vitest browser modeCloses #33748
Summary by CodeRabbit