useShallow introduces dependency on react #2095
Replies: 6 comments 16 replies
-
|
@birtles you're right for now let's downgrade for now |
Beta Was this translation helpful? Give feedback.
-
|
I kind of knew this could be an issue, but not with what exactly the cases.
and, okay it's the one. In Jotai, we explicitly divide entry points. If we follow that it will be:
I thought it's too much for Zustand.
and, I hoped that workaround worked. In the end, if dead code elimination works well, it should be gone. I wonder if there's a simpler alternative... |
Beta Was this translation helpful? Give feedback.
-
|
I wish vitest can do it. Does jest work or not? cc: @Aslemammad |
Beta Was this translation helpful? Give feedback.
-
|
Would something like this help you? https://pnpm.io/aliases |
Beta Was this translation helpful? Give feedback.
-
|
#2096 from @bkimminich.
So, it's another case, hmm. See: #2095 (comment)
Even if you are not using it, is it correct that if you install |
Beta Was this translation helpful? Give feedback.
-
|
@dai-shi I'm wondering if would be better if we split zustand in two main packages like other FOSS projects, for instance They have two packages the non-react/core package and the react package. They follow this convention: Where And, We can import from
We can import from
The goal with splitting the packages in two is not only separate the functions but also the code so people don't need to install extra packages when wants to work with the vanilla/non-react version
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
With the introduction of
useShallow, usingzustand/shallownow introduces a dependency on'react'.For me that's problematic because I'm using Preact. Normally I can easily alias
'react'topreact/compatin my webpack config etc. but when usingvitestthere seems to be no way to alias dependencies insidenode_modules(there are aliases in the test config but they don't apply insidenode_modules). See vitest-dev/vitest#1652 (comment)Effectively this means I can't test any code using
zustand/shallowfromvitestwithout installing React in addition to Preact.Would it make sense to ship
useShallowin a separate file?Beta Was this translation helpful? Give feedback.
All reactions