Skip to content
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

use-sync-external-store should be marked as a peerDep #698

Closed
maraisr opened this issue Mar 21, 2023 · 7 comments
Closed

use-sync-external-store should be marked as a peerDep #698

maraisr opened this issue Mar 21, 2023 · 7 comments

Comments

@maraisr
Copy link

maraisr commented Mar 21, 2023

Hi 👋🏻

We are using valtio in a context where react isnt used. So exclusively the /vanilla package.

But NPM is throwing an install warning for us:

npm ERR! code ELSPROBLEMS
npm ERR! missing: react@^16.8.0 || ^17.0.0 || ^18.0.0, required by use-sync-external-store@1.2.0

Believe its because valtio requires use-sync-external-store which has a peer dep on react, which we do not want.

https://github.com/pmndrs/valtio/blob/7fe26c2a8ff2df8a5b8df019f8878dbf48e40876/package.json#LL140C18-L140C18


Perhaps there is an alternative to valtio that doesnt depend on react?

@dai-shi
Copy link
Member

dai-shi commented Mar 21, 2023

I see it's because use-sync-external-store has peer dep, and it's not optional.

We could mark it as peer dep, but that would require react users to install it. (some new package managers can do it automatically.)

Curious, how "bad" is it to install react for you?

@maraisr maraisr closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2023
@maraisr
Copy link
Author

maraisr commented Mar 21, 2023

thank you for your time. appreciate the response. But no thank you, installing react is an insurmountable sin I do not wish to commit.

@dai-shi
Copy link
Member

dai-shi commented Mar 21, 2023

Does --legacy-peer-deps option help? Otherwise, patch-package might be a last resort.

@maraisr
Copy link
Author

maraisr commented Mar 21, 2023

use-sync-external-store is only used in your react submodule — can that not be an optional peer dependency as it rightly is?

@dai-shi
Copy link
Member

dai-shi commented Mar 21, 2023

It could. (Theoretically, same applies to proxy-compare which is only meaningfully used in react. vanilla part is meaningless without it.)

It's just a matter of usability. If we remove use-sync-external-store from the dependency, 99.9% of users would have to re-install it. note valtio depends on it.
Say, 1% of users is using valtio/vanilla, and probably only one tenth would actually have a trouble with the react peer dependency.

I feel like a dummy react library would help in your case. or dummy use-sync-external-store.

btw, we will be removing it in the future version.

@maraisr
Copy link
Author

maraisr commented Mar 21, 2023

Oh this is fantastic news, looking forward to it!

@dai-shi
Copy link
Member

dai-shi commented Mar 21, 2023

By the future version, I meant v2 with React >= 18 requirement. It won't happen very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants