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: Move react
and react-dom
to peer deps
#12972
Conversation
You're right @Hypnosphi it's just a workaround we discuss this morning to avoid yarn/npm warnings. Do you have something in mind for this kind of feedbacks:
For the Other options: we keep react as peerDep everywhere and users need to add react to their own project. But @ndelangen told me it can be a pain to deal with react in a vue project for instance. 🤷🏻 |
OK let's make them optional until NPM 7 becomes mainstream (probably in a year) |
In #12925 I made them peer deps for everything except the non-React frameworks. So |
Monthly meeting sum up: Still one pending question:
|
Yes except NOTE: Currently |
- Set `react` and `react-dom` as peerDeps for all `lib` packages needing them - Set `react` and `react-dom` as peerDeps + optional tag for all `addon` packages needing them - Set `react` and `react-dom` as regular deps for all non react apps - Remove `react` and `react-dom` from root `package.json` - Set a fixed version of `react` in all examples Also: - Use "^16.8.0 || ^17.0.0" version range as some packages need React Hooks
They are now regular deps of SB packages for all non-react app so there is no more need to add them explicitly.
7ad9f84
to
b1a0f4b
Compare
Shouldn't our (non-react) examples only install react via the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great @gaetanmaisse
@tmeasday this PR already implements that (non-react frameworks automatically install react on behalf of users) |
that's actually not true for package manager which are strict about peer dependencies (pnpm and yarn 2 for instance). The yarn 1 and npm 6 are more lenient here, because they validate the peer dependencies based on hoisted packages too. |
@stof Actually it's still a bit more complex than that because there is a webpack alias in SB manager config so all React imports are aliased to the React version that satisfies |
@gaetanmaisse thanks for the link |
Follow up #12908 (comment)
More or less revert #11628
What I did
As stated by @Hypnosphi:
So I moved them to peerDep in some base packages. Plus, all packages depending on a package with
react
as peerDep should also have it as peerDeps (transitive peer dependencies, for details: https://dev.to/arcanis/implicit-transitive-peer-dependencies-ed0).Finally, packages in
examples/*
are "end" packages using Storybook so they must providereact
andreact-dom
in their deps/devDeps. So, I putreact
andreact-dom
to^16.14.0
(latest 16.x available).How to test
Questions
15 || 16 || ^17.0.0
as version range for bothreact
andreact-dom
when they are peerDep. Does it look good to you?app
packages should maybe havereact
andreact-dom
as deps instead of peerDeps, I mean@storybook/angular
would find weird to have to add these deps in their project themselves. 🤷🏻react
andreact-dom
as peerDeps inapp
packages we should update the CLI to detect and add if needed add them automagically when runningsb init
Did I miss something @Hypnosphi? and what's your opinion on that?