-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
When zod
v3 is used in a CommonJS codebase that uses esbuild
, rollup
or webpack
to package and minify code, the bundle size contribution of zod
is ~68K which is pretty good. When v4 or v4-mini is used, the bundle size contribution increases more than 4x with the same project setup.
I've done some experiments with different bundlers and different versions of zod
and here are some results:
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 |
This is a fairly major increase for anyone using this fairly common project setup (not just for front-end bundles — anyone using something like AWS Lambda will get slower cold starts due to the increased bundle size).
Note
ESM + v4-mini
sizes fixed base on paulbrimicombe/zod-bundle-sizes#1
Metadata
Metadata
Assignees
Labels
No labels