Skip to content
Discussion options

You must be logged in to vote

Hi @shivan-eyespace! I'm Dosu and I’m helping the zod team.

There is a practical difference between star imports (import * as z from "zod") and named imports (import { z, ZodError } from "zod") when using Zod. Star imports are generally recommended because they work better with tree-shaking in most bundlers (like Webpack, esbuild, and Next.js), resulting in smaller bundle sizes. Named imports can lead to bundlers including the entire Zod object, making tree-shaking less effective and potentially increasing your bundle size see discussion.

Some bundlers—especially Next.js with Turbopack—can also throw runtime errors (such as ReferenceError: Cannot access 'ZodEnum' before initialization) w…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shivan-eyespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant