Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Zod Mini - Tree shaking not removing locales #5561

@owo

Description

@owo

I tried migrating some validation code I have form Zod to Zod Mini in order to reduce my project's final bundle size.

I did get a 10KB drop when doing so but the bundle size is still large with a majority of the size coming from Zod's locales.

Below is the esbuild analysis:

Image

I am using Zod v4.2.1 with the following (among other) esbuild compiler options:

{
    bundle: true,
    format: "cjs",
    target: "es2018",
    treeShaking: true,
}

and the following tsconfig compiler options:

{
    "module": "nodenext",
    "target": "ES2018",
    "moduleResolution": "nodenext",
}

I'm using wildcard imports (as suggested in the documentation and other reported issues) and I even tried the following variants to no effect:

import * as zod from "zod/mini";
import * as zod from "zod/v4-mini";
import * as zod from "zod/v4/mini";

Are there any other options I should be setting or actions I should take to get the locales removed from the bundle?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions