-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Core: Fix monorepo compatibility #11753
Conversation
Thanks @merceyz, this looks interesting! I will deep dive in this when I will come back from holidays in 10 days. |
This reverts commit 83831a5.
Storybook doesn't work correctly in monorepos with both node_modules (Yarn 1/2) and PnP (Yarn 2) because it's trying to require the addons declared in .storybook/main.js from @storybook/core instead of requiring them on behalf of the config. Also makes checks on preset names less restrictive as they are now resolved path and not simple name anymore.
@merceyz All green! 🎉 Do you have something to add or we can open the PR? |
@gaetanmaisse Nope, all good, thanks for finding the issue with the CRA preset 🎉 |
Note to whomever merges this: You should use Squash and Merge since the commit history is a bit messy here @gaetanmaisse NIT on the title: This isn't exclusive to Yarn monorepos, it fixes monorepos using pnpm / npm + lerna as well |
@merceyz no worries about the commit history. we don't use squash merges in this project! 😁 |
That makes the commit history really hard to read but alright |
How to resolve preset relative to storybook installed folder, but not config? After changes in this pull request storybook tries to look |
Resolve the presets upfront yourself using |
@merceyz thank your for answer |
in case of using addon-essentials with custom full path like: upd: i have found same implementation already done |
Issue
Storybook doesn't work correctly in monorepos with both node_modules (Yarn 1/2) and PnP (Yarn 2) because it's trying to require the addons declared in
.storybook/main.js
from@storybook/core
instead of requiring them on behalf of the config.The e2e tests currently pass because Yarn has a compatability feature, called
fallbackMode
, that allows dependencies to require top-level dependencies without declaring them as their own. In a monorepo this fails as the top level no longer declares these dependencies, the workspace does, and under the node_modules linker the addons are not guaranteed to be hoisted to the same level as@storybook/core
.What I did
fallbackMode
to highlight the issue in the e2e tests https://yarnpkg.com/configuration/yarnrc#pnpFallbackModeHow to test
Disable the
fallbackMode
and try to use storybook in a PnP projectExtra
cc @gaetanmaisse since you worked on PnP compatability