Description
When @b9g/zen is bundled, it pulls in ~598KB of Zod locale files (50+ languages) that are never used.
@b9g/zen 598.4 KB 79 14.4%
The 79 files are almost entirely Zod locales:
// node_modules/@b9g/zen/node_modules/zod/v4/locales/ar.js
// node_modules/@b9g/zen/node_modules/zod/v4/locales/az.js
// node_modules/@b9g/zen/node_modules/zod/v4/locales/be.js
// ... (50+ locale files)
Root Cause
This is a known Zod issue where export * as locales from "../locales/index.js" prevents tree-shaking:
The issue affects esbuild, webpack, and turbopack. There's currently no workaround except using Rollup.
Suggested Workarounds
Until Zod fixes this upstream:
- Wait for Zod to fix the tree-shaking issue
- Consider using
zod/mini if it has better tree-shaking characteristics
- Consider a lighter validation library for simple use cases
Impact
For applications that don't use @b9g/zen database features, this adds ~600KB of unused code to the bundle.
Description
When
@b9g/zenis bundled, it pulls in ~598KB of Zod locale files (50+ languages) that are never used.The 79 files are almost entirely Zod locales:
Root Cause
This is a known Zod issue where
export * as locales from "../locales/index.js"prevents tree-shaking:The issue affects esbuild, webpack, and turbopack. There's currently no workaround except using Rollup.
Suggested Workarounds
Until Zod fixes this upstream:
zod/miniif it has better tree-shaking characteristicsImpact
For applications that don't use
@b9g/zendatabase features, this adds ~600KB of unused code to the bundle.