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 4 commits intostorybookjs:nextfrom
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
📝 WalkthroughWalkthroughModified the builder preset path resolution in the core server loader by replacing 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. |
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