Repository navigation
Conversation
The zustand root entry also loads zustand's React hooks. With zustand 5 and no React installed, importing zundo in Node fails with "Cannot find module 'react'". zundo only needs the vanilla store, so import it from zustand/vanilla.
Both versions are below the peer range (^4.3.0 || ^5.0.0). Before 4.3.0, zustand/vanilla exports createStore only as a default export, so the build and tests fail on them after the previous commit. The tsup patch step ran only for 4.0.0, so it goes too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Importing zundo no longer loads React with this change. zundo uses
createStoreonly to build the store that holds the undo history (store.temporal), and this PR imports it fromzustand/vanillainstead of thezustandroot.In zustand 5, the root entry also re-exports
zustand/react, which importsreact. So a project that uses zundo only with a vanilla store still loads React. If React is not installed, importing zundo fails:require('zundo')fails the same way. With this branch, both load.#98 made the same change in 2023. It was closed with "Actual issue fixed in #99", and its description said the bundle got bigger. I rebuilt #98 and the commit it was based on with the tools of that time (tsup 6.7.0, size-limit 8.2.4, zustand 4.3.8). The repo's size check (
pnpm size) went from 860 B to 866 B. Neither build includes zustand's code, so the 6 bytes are the longer import path. Todaypnpm sizegoes from 628 B to 634 B. I also bundled a small app that uses zundo with a vanilla store. Minified and gzipped, it is 708 B before and after this change. Without React installed, the app fails to build before this change and builds after it.The second commit removes zustand 4.0.0 and 4.2.0 from the CI matrix, with the tsup patch step that ran only for 4.0.0. Before 4.3.0,
zustand/vanillaexportscreateStoreonly as a default export, so the build and tests fail on those two versions. Both are below the peer range (^4.3.0 || ^5.0.0), and every release in that range exports the namedcreateStorefromzustand/vanilla. The commit is separate so you can drop it. If you want to keep support for zustand below 4.3.0, I can follow up with an import that falls back to the default export.To test, run
pnpm build && pnpm test:ci. Then run the repro above with the built package (npm pack, and install the tarball in place ofzundo@2.3.0).