zustand icon indicating copy to clipboard operation
zustand copied to clipboard

v5

Open dai-shi opened this issue 2 years ago â€ĸ 38 comments

  • [x] drop default exports #2238
  • [x] drop deprecated features #2235
  • [x] make React 18 as minimal requirement #2236
  • [x] make use-sync-external-store a peer dependency #2237 #2301 #2302
  • [x] make TS version requirement and tests in CI precise (follow Jotai) #2257
  • [x] drop "module" condition (follow Jotai) #2270
  • [x] use "./*" in package.json exports and change Node.js requirement #2272
  • [x] drop UMD/SystemJS builds and simplify build configs #2287
  • [x] drop getServerState #2300
  • [x] separate react entry point #2303
  • [x] drop es5 #2380 #2433
  • [x] #2395
  • [x] #2427
  • [x] #2466
  • [x] write v5 migration guide
  • [x] #2580

dai-shi avatar Oct 22 '23 00:10 dai-shi

The latest updates on your projects. Learn more about Vercel for Git â†—ī¸Ž

Name Status Preview Comments Updated (UTC)
zustand-demo ✅ Ready (Inspect) Visit Preview đŸ’Ŧ Add feedback Aug 16, 2024 0:34am

vercel[bot] avatar Oct 22 '23 00:10 vercel[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codesandbox-ci[bot] avatar Oct 22 '23 00:10 codesandbox-ci[bot]

Size Change: -48.8 kB (-80.05%) 🏆

Total Size: 12.2 kB

Filename Size Change
./dist/context.js 0 B -789 B (removed) 🏆
./dist/esm/context.js 0 B -608 B (removed) 🏆
./dist/esm/context.mjs 0 B -612 B (removed) 🏆
./dist/esm/index.js 0 B -739 B (removed) 🏆
./dist/esm/index.mjs 64 B -686 B (-91.47%) 🏆
./dist/esm/middleware.js 0 B -3.95 kB (removed) 🏆
./dist/esm/middleware.mjs 3.56 kB -405 B (-10.23%) 👏
./dist/esm/middleware/immer.js 0 B -210 B (removed) 🏆
./dist/esm/react/shallow.js 0 B -464 B (removed) 🏆
./dist/esm/react/shallow.mjs 267 B -197 B (-42.46%) 🎉
./dist/esm/shallow.js 0 B -499 B (removed) 🏆
./dist/esm/shallow.mjs 82 B -426 B (-83.86%) 🏆
./dist/esm/traditional.js 0 B -424 B (removed) 🏆
./dist/esm/traditional.mjs 416 B -8 B (-1.89%)
./dist/esm/vanilla.js 0 B -653 B (removed) 🏆
./dist/esm/vanilla.mjs 403 B -259 B (-39.12%) 🎉
./dist/esm/vanilla/shallow.js 0 B -355 B (removed) 🏆
./dist/esm/vanilla/shallow.mjs 550 B +195 B (+54.93%) 🆘
./dist/index.js 244 B -662 B (-73.07%) 🏆
./dist/middleware.js 3.56 kB -923 B (-20.57%) 🎉
./dist/middleware/immer.js 229 B -99 B (-30.18%) 🎉
./dist/react/shallow.js 282 B -804 B (-74.03%) 🏆
./dist/shallow.js 189 B -944 B (-83.32%) 🏆
./dist/system/context.development.js 0 B -689 B (removed) 🏆
./dist/system/context.production.js 0 B -388 B (removed) 🏆
./dist/system/index.development.js 0 B -918 B (removed) 🏆
./dist/system/index.production.js 0 B -432 B (removed) 🏆
./dist/system/middleware.development.js 0 B -4.09 kB (removed) 🏆
./dist/system/middleware.production.js 0 B -2.66 kB (removed) 🏆
./dist/system/middleware/immer.development.js 0 B -292 B (removed) 🏆
./dist/system/middleware/immer.production.js 0 B -188 B (removed) 🏆
./dist/system/react/shallow.development.js 0 B -564 B (removed) 🏆
./dist/system/react/shallow.production.js 0 B -387 B (removed) 🏆
./dist/system/shallow.development.js 0 B -545 B (removed) 🏆
./dist/system/shallow.production.js 0 B -330 B (removed) 🏆
./dist/system/traditional.development.js 0 B -536 B (removed) 🏆
./dist/system/traditional.production.js 0 B -361 B (removed) 🏆
./dist/system/vanilla.development.js 0 B -694 B (removed) 🏆
./dist/system/vanilla.production.js 0 B -325 B (removed) 🏆
./dist/system/vanilla/shallow.development.js 0 B -427 B (removed) 🏆
./dist/system/vanilla/shallow.production.js 0 B -309 B (removed) 🏆
./dist/traditional.js 430 B -42 B (-8.9%) ✅
./dist/umd/context.development.js 0 B -894 B (removed) 🏆
./dist/umd/context.production.js 0 B -561 B (removed) 🏆
./dist/umd/index.development.js 0 B -1.03 kB (removed) 🏆
./dist/umd/index.production.js 0 B -557 B (removed) 🏆
./dist/umd/middleware.development.js 0 B -4.63 kB (removed) 🏆
./dist/umd/middleware.production.js 0 B -2.99 kB (removed) 🏆
./dist/umd/middleware/immer.development.js 0 B -483 B (removed) 🏆
./dist/umd/middleware/immer.production.js 0 B -341 B (removed) 🏆
./dist/umd/react/shallow.development.js 0 B -1.22 kB (removed) 🏆
./dist/umd/react/shallow.production.js 0 B -883 B (removed) 🏆
./dist/umd/shallow.development.js 0 B -1.24 kB (removed) 🏆
./dist/umd/shallow.production.js 0 B -874 B (removed) 🏆
./dist/umd/traditional.development.js 0 B -650 B (removed) 🏆
./dist/umd/traditional.production.js 0 B -464 B (removed) 🏆
./dist/umd/vanilla.development.js 0 B -828 B (removed) 🏆
./dist/umd/vanilla.production.js 0 B -426 B (removed) 🏆
./dist/umd/vanilla/shallow.development.js 0 B -1.12 kB (removed) 🏆
./dist/umd/vanilla/shallow.production.js 0 B -838 B (removed) 🏆
./dist/vanilla.js 416 B -295 B (-41.49%) 🎉
./dist/vanilla/shallow.js 562 B -421 B (-42.83%) 🎉
./dist/esm/react.mjs 333 B +333 B (new file) 🆕
./dist/react.js 353 B +353 B (new file) 🆕
â„šī¸ View Unchanged
Filename Size
./dist/esm/middleware/immer.mjs 210 B

compressed-size-action

github-actions[bot] avatar Oct 22 '23 00:10 github-actions[bot]

Maybe consider changing React Snowpack to React Vite on CodeSandbox?

sewera avatar Oct 22 '23 10:10 sewera

I think you can just add it, if you are talking about .codesandbox/ci.json. Feel free to open a PR to the main branch. I don't know if the container sandbox is already supported.

dai-shi avatar Oct 22 '23 10:10 dai-shi

I'll see if I've got some time in the nearest future :)

sewera avatar Oct 22 '23 10:10 sewera

I'm a noob learning things and asking around.

I noticed many libraries dropping default exports. may I ask why?

TheMikeyRoss avatar Nov 22 '23 17:11 TheMikeyRoss

@TheMikeyRoss Can you open a new discussion? https://github.com/pmndrs/zustand/discussions/new

dai-shi avatar Nov 22 '23 23:11 dai-shi

@dai-shi, I see the checklist in the PR description, could I help tackle some of the bullet points? Thanks

charkour avatar Dec 09 '23 03:12 charkour

@charkour I was wondering when we should start this, but if you are interested please go ahead. Note that I may have some hidden requirements which isn't described well in the bullet points, so bear with me. (I think I should work on the TS one on my own.)

We do something like this https://github.com/pmndrs/valtio/pull/810, so please open PRs for each point against v5 branch.

dai-shi avatar Dec 09 '23 03:12 dai-shi

Sounds great! I can start on dropping the default exports.

No worries on the hidden requirements, I'm happy to help and let you take over if you disagree with one of my changes.

charkour avatar Dec 09 '23 03:12 charkour

@dai-shi, are you willing to take on the next step on the task list? I can review but don't have time to code as much this week. Thanks

charkour avatar Dec 18 '23 14:12 charkour

@dbritto-dev if you are interested you can take the next item.

dai-shi avatar Dec 20 '23 11:12 dai-shi

@dai-shi let me take the next two tasks

dbritto-dev avatar Dec 20 '23 11:12 dbritto-dev

Thanks! Please work on them one by one.

dai-shi avatar Dec 20 '23 11:12 dai-shi

@dai-shi I'll take the second last too

dbritto-dev avatar Dec 23 '23 01:12 dbritto-dev

Published: https://www.npmjs.com/package/zustand/v/5.0.0-alpha.0

dai-shi avatar Jan 20 '24 05:01 dai-shi

I wonder if we should separate zustand/react entry point. We've done it in Jotai and Valtio.

dai-shi avatar Jan 20 '24 06:01 dai-shi

Published: https://www.npmjs.com/package/zustand/v/5.0.0-alpha.1

dai-shi avatar Jan 20 '24 08:01 dai-shi

I wonder if we should separate zustand/react entry point. We've done it in Jotai and Valtio.

We shall follow Jotai and Valtio

dbritto-dev avatar Jan 20 '24 11:01 dbritto-dev

I wonder if we should separate zustand/react entry point. We've done it in Jotai and Valtio.

We shall follow Jotai and Valtio

#2303

dai-shi avatar Jan 20 '24 12:01 dai-shi

Published: https://www.npmjs.com/package/zustand/v/5.0.0-alpha.2

Would anyone try it and see if there are any issues?

dai-shi avatar Jan 21 '24 05:01 dai-shi

Published: https://www.npmjs.com/package/zustand/v/5.0.0-alpha.3

dai-shi avatar Feb 17 '24 02:02 dai-shi

Published: https://www.npmjs.com/package/zustand/v/5.0.0-alpha.4

dai-shi avatar Mar 02 '24 14:03 dai-shi

FYI @DavideSegullo We consider it a bad practice. #2395

dai-shi avatar Mar 09 '24 00:03 dai-shi

Published: https://www.npmjs.com/package/zustand/v/5.0.0-alpha.5

dai-shi avatar Mar 09 '24 00:03 dai-shi

FYI @DavideSegullo We consider it a bad practice. #2395

Oh thank you!! I tought, by reading It that It was a good pattern. Why isn't it a good practice?

DavideSegullo avatar Mar 09 '24 09:03 DavideSegullo

The fact that it works now doesn't mean it works for the future version. use-sync-external-store is provided by React and they say they maintain it to make it work for the future. (If there was a bug, we would report it to them.) So, it's better for the community than having our own hacks.

dai-shi avatar Mar 09 '24 11:03 dai-shi

The fact that it works now doesn't mean it works for the future version. use-sync-external-store is provided by React and they say they maintain it to make it work for the future. (If there was a bug, we would report it to them.) So, it's better for the community than having our own hacks.

Makes sense, thank you!

DavideSegullo avatar Mar 09 '24 12:03 DavideSegullo

Hi. Thanks for the library, always nice. I have one minor question: why the code is remained for createState that being nullable in createStore, which was previously left for context? I checked out v5 and saw that removing it still passes all my tests, is it for external libraries?

export const createStore = ((createState) =>
  createState ? createStoreImpl(createState) : createStoreImpl) as CreateStore

bluejoyq avatar Mar 10 '24 16:03 bluejoyq