[PR #3619] [MERGED] chore: ensure zod version alignment via peerDependency #4916

Closed
opened 2026-03-13 12:04:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3619
Author: @Kinfe123
Created: 7/26/2025
Status: Merged
Merged: 7/26/2025
Merged by: @Bekacru

Base: mainHead: chore/zodv4-versioning


📝 Commits (5)

📊 Changes

5 files changed (+35 additions, -25 deletions)

View changed files

📝 packages/better-auth/package.json (+5 -4)
📝 packages/cli/package.json (+6 -3)
📝 packages/sso/package.json (+6 -3)
📝 packages/stripe/package.json (+6 -3)
📝 pnpm-lock.yaml (+12 -12)

📄 Description

This PR updates the Zod import to use zod/v4 and ensures Zod is listed as a peerDependency rather than a direct dependency. This aligns with best practices for Zod v4 adoption and avoids bundling duplicate Zod versions in consuming applications.

Although the subpath import zod/v4 is conceptually tied to Zod v4, it was technically introduced and made available starting in Zod v3.21.0. However, I now explicitly target v4, based on the preference to support a major version moving forward.

I followed the official guidance from the Zod maintainers (issue #4371) to prevent runtime issues caused by subpath mismatches or schema identity conflicts. By using peer dependencies, I ensure version alignment with the consumer’s environment and avoid subtle bugs related to schema instantiation across multiple bundled versions of Zod.


Summary by cubic

Updated all packages to use Zod as a peerDependency and removed direct Zod dependencies to prevent duplicate versions and ensure version alignment with consuming apps.

  • Dependencies
    • Set Zod as a peerDependency with support for v3.25.0 and v4.0.0.
    • Updated devDependencies to use Zod v4 where needed.
    • Cleaned up pnpm-lock.yaml to reflect these changes.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3619 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 7/26/2025 **Status:** ✅ Merged **Merged:** 7/26/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `chore/zodv4-versioning` --- ### 📝 Commits (5) - [`1112eb5`](https://github.com/better-auth/better-auth/commit/1112eb5e7844a9fc433c8a15b20db79588019a07) zodv4 - [`62cbd91`](https://github.com/better-auth/better-auth/commit/62cbd91a265a96bb5865fa9d68b67dc3fcbe7a99) fix - [`a4049e0`](https://github.com/better-auth/better-auth/commit/a4049e026c0a6100f8ceee8224c527ef7e9cb5a3) lock - [`47b34d3`](https://github.com/better-auth/better-auth/commit/47b34d3149318797ae071a84795624b87e68713c) pkg - [`c484bd4`](https://github.com/better-auth/better-auth/commit/c484bd4064aa8e0c084aa6868db0a14f7a941aa8) Merge branch 'main' into chore/zodv4-versioning ### 📊 Changes **5 files changed** (+35 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/package.json` (+5 -4) 📝 `packages/cli/package.json` (+6 -3) 📝 `packages/sso/package.json` (+6 -3) 📝 `packages/stripe/package.json` (+6 -3) 📝 `pnpm-lock.yaml` (+12 -12) </details> ### 📄 Description This PR updates the Zod import to use zod/v4 and ensures Zod is listed as a peerDependency rather than a direct dependency. This aligns with best practices for Zod v4 adoption and avoids bundling duplicate Zod versions in consuming applications. Although the subpath import zod/v4 is conceptually tied to Zod v4, it was technically introduced and made available starting in Zod v3.21.0. However, I now explicitly target v4, based on the preference to support a major version moving forward. I followed the official guidance from the Zod maintainers ([issue #4371](https://github.com/colinhacks/zod/issues/4371)) to prevent runtime issues caused by subpath mismatches or schema identity conflicts. By using peer dependencies, I ensure version alignment with the consumer’s environment and avoid subtle bugs related to schema instantiation across multiple bundled versions of Zod. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Updated all packages to use Zod as a peerDependency and removed direct Zod dependencies to prevent duplicate versions and ensure version alignment with consuming apps. - **Dependencies** - Set Zod as a peerDependency with support for v3.25.0 and v4.0.0. - Updated devDependencies to use Zod v4 where needed. - Cleaned up pnpm-lock.yaml to reflect these changes. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:04:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#4916