Skip to content

Bundle includes 500KB+ of unused Zod locales #20

Description

@brainkim

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:

  1. Wait for Zod to fix the tree-shaking issue
  2. Consider using zod/mini if it has better tree-shaking characteristics
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions