npm ci && npm run buildThis will:
- Install dependencies
- Bundle code using ESBuild, Rollup and Webpack
- Print the bundle sizes for the various scenarios to the console
| Zod version | Module system | ESBuild bundle size | Rollup bundle size | Webpack bundle size |
|---|---|---|---|---|
| v3 | CommonJS | 68K | 68K | 68K |
| v4 | CommonJS | 288K | 255K | 254K |
| v4-mini | CommonJS | 279K | 246K | 245K |
| v3 | ESM | 55K | 52K | 52K |
| v4 | ESM | 41K | 33K | 35K |
| v4-mini | ESM | 41K | 33K | 35K |
Note
Using ESBuild and ESM, the tree-shaking only seems to work if you import using import * as z from 'zod/v4-mini';.
Importing using import { z } from 'zod/v4-mini' results in much larger bundle sizes.