-
Notifications
You must be signed in to change notification settings - Fork 0
chore: update zod to version 4 #56
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
Draft
evilpeach
wants to merge
1
commit into
main
Choose a base branch
from
improve/zodv4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Consider making zod a peerDependency (to avoid duplicate instances and type incompatibilities)
If any exported APIs expose Zod schemas/types or consumers are expected to use z.infer on your exported schemas, zod should be a peerDependency (and a devDependency for local build/tests) rather than a runtime dependency. This prevents multiple Zod copies in downstream apps and avoids type identity issues.
To decide, scan for Zod usage in exported surfaces:
If results indicate exposure, consider this change:
"dependencies": { @@ - "zod": "^4.0.17" + }, + "peerDependencies": { + "zod": "^4.0.0" }, "devDependencies": { @@ + "zod": "^4.0.17",If Zod is strictly internal and never leaks through the public API, keeping it in dependencies is acceptable.
🏁 Script executed:
Length of output: 4532
Move Zod into peerDependencies & devDependencies
Zod schemas and
z.infertypes are exposed in your public API (seesrc/schema/**/*.tsandsrc/utils/find-move-events.ts), so you must declare Zod as a peerDependency (and as a devDependency for tests/build) rather than a runtime dependency:• Remove from dependencies (currently at package.json:61)
• Add to peerDependencies (e.g.
"zod": "^4.0.0")• Add to devDependencies (e.g.
"zod": "^4.0.17")Suggested diff in package.json:
"dependencies": { - "zod": "^4.0.17" }, + "peerDependencies": { + "zod": "^4.0.0" + }, "devDependencies": { + "zod": "^4.0.17", …other dev deps }Note: if you officially support Yarn (classic/berry), you may keep Zod in
dependenciesto ensure installation for Yarn users (since Yarn does not auto‐install peerDependencies) while still declaring it as a peerDependency to avoid duplicate instances.📝 Committable suggestion
💡 Verification agent
🧩 Analysis chain
Major version bump to Zod v4: audit for breaking changes and ESM/CJS interop
Upgrading from v3 → v4 is a breaking change. Given this package publishes both ESM and CJS builds (Lines 14–28), verify:
Run the following to quickly assess impact in-repo and locate build config:
And please fetch authoritative details on v4 to confirm expectations:
🏁 Script executed:
Length of output: 25136
🌐 Web query:
💡 Result:
Zod v4 introduces several breaking changes (with an official migration guide), and it is published in a way that supports both ESM and CommonJS consumers—but Zod v4 is accessed via the subpath import zod/v4, which can require Node/TypeScript “Node16/NodeNext/Bundler” module resolution when used from CommonJS toolchains.[5][8][9]
Key Zod v4 breaking changes and migration notes
Official migration resources and ecosystem transition
ESM vs. CommonJS: does Zod v4 ship a CJS build?
Additional notes and cautions
If you share a small snippet of your current Zod v3 usage, I can map the exact v4 replacements and flag any path/error handling you’ll need to adjust.[5][1]
Citations:
Major version bump to Zod v4: replace default import & verify build interop
src/schema/transaction.ts, change the default import to a named import (v4 no longer provides a default export):zod/…were found—every schema uses top-level APIs (z.object,z.union,z.preprocess,z.coerce, etc.), all compatible with v4."zod"; double-check your tsup build (inline CLI flags inpackage.json) to ensure:•
zodis either externalized or bundled correctly in both your ESM and CJS outputs• your TypeScript
moduleResolution(e.g. Node16/NodeNext) aligns with Node’s subpath export rules if you ever switch tozod/v4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evilpeach any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check and test it first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider
yarnwhich does not automatically installpeerDependencies.