© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•4mo ago•
1 reply
Forcebe

Drizzle-zod schemas included in bundle

Hey all, I am working on a package that exports a ts-rest contract. The contract uses zod schemas to validate inputs. The schemas are created with
createSelectSchema
createSelectSchema
from
drizzle-zod
drizzle-zod
in my schema.ts file:
export const clients = pgTable(
  "clients",
  { 
    ...
  }
);

export const ClientSchema = createSelectSchema(clients);
export const clients = pgTable(
  "clients",
  { 
    ...
  }
);

export const ClientSchema = createSelectSchema(clients);

These schemas are then refined into the contract schemas with
ClientSchema.pick({ ... })
ClientSchema.pick({ ... })
, which are used in the contracts. The contracts are then bundled with
tsdown
tsdown
.

The issue I am facing is that when I run the bundler, full dirzzle schemas are generated in the
index.mjs
index.mjs
file instead of just zod schemas. Is there a way to prevent the bundler from including the entire schemas?
Intro
A seriously tiny type-safe wrapper around existing, battle-tested, established tech.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Share drizzle-zod schemas with the frontend
Drizzle TeamDTDrizzle Team / help
3y ago
Importing drizzle-zod Schemas on the Client
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle-Zod
Drizzle TeamDTDrizzle Team / help
9mo ago
How to use drizzle-zod generated schemas in Next.JS frontend?
Drizzle TeamDTDrizzle Team / help
3y ago