[PR #5995] [MERGED] chore: improve zod imports tree shaking #23271

Closed
opened 2026-04-15 21:35:26 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5995
Author: @sabaturgay
Created: 11/14/2025
Status: Merged
Merged: 11/15/2025
Merged by: @himself65

Base: canaryHead: canary


📝 Commits (2)

  • a057758 update zod imports for better tree shaking
  • 309204a fix: update zod imports to use import * as z from "zod" for consistency

📊 Changes

69 files changed (+81 additions, -68 deletions)

View changed files

📝 biome.json (+13 -0)
📝 docs/app/api/og-release/route.tsx (+1 -1)
📝 docs/app/api/og/route.tsx (+1 -1)
📝 docs/components/floating-ai-search.tsx (+1 -1)
📝 docs/lib/chat/inkeep-qa-schema.ts (+1 -1)
📝 docs/scripts/endpoint-to-doc/index.ts (+1 -1)
📝 docs/scripts/endpoint-to-doc/input.ts (+1 -1)
📝 docs/source.config.ts (+1 -1)
📝 packages/better-auth/src/api/middlewares/origin-check.test.ts (+1 -1)
📝 packages/better-auth/src/api/routes/account.ts (+1 -1)
📝 packages/better-auth/src/api/routes/callback.ts (+1 -1)
📝 packages/better-auth/src/api/routes/email-verification.ts (+1 -1)
📝 packages/better-auth/src/api/routes/reset-password.ts (+1 -1)
📝 packages/better-auth/src/api/routes/session.ts (+1 -1)
📝 packages/better-auth/src/api/routes/sign-in.ts (+1 -1)
📝 packages/better-auth/src/api/routes/sign-up.ts (+1 -1)
📝 packages/better-auth/src/api/routes/update-user.ts (+1 -1)
📝 packages/better-auth/src/api/to-auth-endpoints.test.ts (+1 -1)
📝 packages/better-auth/src/client/test-plugin.ts (+1 -1)
📝 packages/better-auth/src/cookies/session-store.ts (+1 -1)

...and 49 more files

📄 Description

Adjust Zod imports to avoid bundling locale files and reduce the esbuild bundle size by ~260kb.
With the current import { z } from 'zod', the Zod locales end up included in the bundle, which unnecessarily increases the output size.


Summary by cubic

Switched all Zod imports to namespace form to improve tree-shaking and exclude locale files, reducing the esbuild bundle by ~260 KB.

  • Refactors
    • Replaced import { z } from 'zod' with import * as z from 'zod' across core, auth routes, plugins, docs, and scripts; added a Biome rule to enforce this import style.
    • No API or runtime behavior changes.

Written for commit 309204a7a8. Summary will update automatically on new commits.


🔄 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/5995 **Author:** [@sabaturgay](https://github.com/sabaturgay) **Created:** 11/14/2025 **Status:** ✅ Merged **Merged:** 11/15/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `canary` --- ### 📝 Commits (2) - [`a057758`](https://github.com/better-auth/better-auth/commit/a0577584f52f5c681502ed0ed13ea267d687c494) update zod imports for better tree shaking - [`309204a`](https://github.com/better-auth/better-auth/commit/309204a7a8966ad0e6d0827268cab5f91649243a) fix: update zod imports to use `import * as z from "zod"` for consistency ### 📊 Changes **69 files changed** (+81 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `biome.json` (+13 -0) 📝 `docs/app/api/og-release/route.tsx` (+1 -1) 📝 `docs/app/api/og/route.tsx` (+1 -1) 📝 `docs/components/floating-ai-search.tsx` (+1 -1) 📝 `docs/lib/chat/inkeep-qa-schema.ts` (+1 -1) 📝 `docs/scripts/endpoint-to-doc/index.ts` (+1 -1) 📝 `docs/scripts/endpoint-to-doc/input.ts` (+1 -1) 📝 `docs/source.config.ts` (+1 -1) 📝 `packages/better-auth/src/api/middlewares/origin-check.test.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/account.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/callback.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/reset-password.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/session.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+1 -1) 📝 `packages/better-auth/src/api/to-auth-endpoints.test.ts` (+1 -1) 📝 `packages/better-auth/src/client/test-plugin.ts` (+1 -1) 📝 `packages/better-auth/src/cookies/session-store.ts` (+1 -1) _...and 49 more files_ </details> ### 📄 Description Adjust Zod imports to avoid bundling locale files and reduce the esbuild bundle size by ~260kb. With the current import { z } from 'zod', the Zod locales end up included in the bundle, which unnecessarily increases the output size. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Switched all Zod imports to namespace form to improve tree-shaking and exclude locale files, reducing the esbuild bundle by ~260 KB. - **Refactors** - Replaced `import { z } from 'zod'` with `import * as z from 'zod'` across core, auth routes, plugins, docs, and scripts; added a Biome rule to enforce this import style. - No API or runtime behavior changes. <sup>Written for commit 309204a7a8966ad0e6d0827268cab5f91649243a. Summary will update automatically on new commits.</sup> <!-- 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-04-15 21:35:26 -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#23271