Missing React peer dependency
noahtallen opened this issue · comments
Hey @luisherranz! I've been working on incorporating @wordpress/
package updates into Calypso. The published packages has a peer dependency violation:
deepsignal@npm:1.3.4 [411e6] doesnt provide react (p9b425), requested by @preact/signals-react
yarn explain peer-requirements p9b425
➤ YN0000: deepsignal@npm:1.3.4 [411e6] doesnt provide react, breaking the following requirements:
➤ YN0000: @preact/signals-react@npm:1.3.4 [ed871] → ^16.14.0 || 17.x || 18.x ✘
➤ YN0000: use-sync-external-store@npm:1.2.0 [23689] → ^16.8.0 || ^17.0.0 || ^18.0.0 ✘
➤ YN0000: Note: these requirements start with @preact/signals-react@npm:1.3.4 [ed871]
While I've just ignored the error on our side, I think this warning will show up in most dependency tools when installing deepsignal.
I didn't want to add @preact/signals
(Preact version), and @preact/react-signals
(React version) as peer dependencies because I thought it was nice to just install deepsignal
and nothing else. But maybe I should do so because you don't really need preact
if you are using react
, and vice-versa.
What do you think? Would that solve the issue?
Another option would be to subdivide deepsignal
into different packages so they can have their own dependencies.
Yeah, that could work too! I think the only problem at that point would be use-sync-external-store
, which expects React to be provided somewhere. (But at the same time, I couldn't see it used anywhere in the repo, so maybe it's ok! I just saw yarn complaining about it.)
I take it that adding React as a peer dependency isn't a good idea because folks might use preact instead?
You could also set react or preact to be optional peer dependencies; that way the consumer can choose which one to use
I opened a PR to address this:
@noahtallen may you try again with deepsignal@1.3.6?
Yep, that works! I added a PR in Gutenberg to incorporate this. WordPress/gutenberg#53549
Awesome. Thanks, Noah!