Repository navigation
fix: allow tree shaking unused Zod locales in browser bundles - #843
Merged
idosal merged 1 commit intoNov 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes aimed at reducing unused Zod locale bundle overhead.
No open issues 🎉
What changed in this PR
This PR addresses unused Zod locale bundle overhead reported in #665 and #649 by making SDK imports easier for consumer bundlers to tree-shake, without changing validation, JIT configuration, or locale selection.
Changes:
- Import Zod’s
configdirectly inApp. - Use namespace imports in generated schemas and preserve them during regeneration.
- Add browser-bundle regression tests for App, AppBridge, and React that verify only the English locale contributes output bytes.
| File | Description |
|---|---|
src/generated/schema.ts |
Uses a Zod namespace import to enable tree shaking. |
src/bundle.test.ts |
Tests retained locales after Bun and esbuild bundling. |
src/app.ts |
Calls directly imported config while preserving JIT settings. |
scripts/generate-schemas.ts |
Generates and documents the tree-shakeable import form. |
Review effort: Balanced
idosal
approved these changes
Nov 25, 2026
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.
Summary
configdirectly inAppinstead of accessing the exportedzobject.import * as z from "zod/v4"so consumer bundlers can prune unused exports, including locales.No dependency, validation, JIT configuration, or locale-selection behavior changes. Consumers can still explicitly import and configure other locales.
Relates to #665 and #649.
Bundle measurements
Built from upstream main
cf599cc4using MCP core/client 2.0.0, Zod 4.6.6, and esbuild 0.25.12. Browser ESM, ES2020, minified, no code splitting; gzip level 9. Measurements use the regular SDK entries, not*-with-deps.Each probe retains 1 English locale module instead of 64 locale modules. The App probe instantiates
Appand callsconnect(); the AppBridge and React probes retainAppBridgeanduseApp, respectively.Validation
npm run buildnpm test— 454 passed, 3 skippednpm run prettiernpm exec typedoc -- --treatValidationWarningsAsErrors --emit none