Zod to Valibot Size Reduction #557
-
Hey there We recently migrated our project from zod to valibot (yay 🥳). My project is a very small CLI git helper so valibot seemed ideal, as zod was representing 50% of the projects total size. My question is, am I doing something wrong with valibot? We only noticed a 6kB decrease in size
Maybe it's the way these online bundle analyzer just look at package.json? Is there a more accurate way for me to determine size? Alternatively, am I doing something wrong here? (List of imports): https://github.com/Everduin94/better-commits/blob/main/src/vali-state.ts#L1-L13 I appreciate any feedback or input, thanks! :) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Valibot should add less then 2 kB to your bundle. Check it here. After compressing it with the other code in your package, the actual size that Valibot adds is even smaller. Furthermore, after we merge #502, it will be even smaller by about 20%. |
Beta Was this translation helpful? Give feedback.
-
I think your problem is that you are building your library for CommonJS only. I recommend to build your project for ESM as well and use it as the default. Check out the build step and import configuration of Valibot. Reach out if you need help. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
I think your problem is that you are building your library for CommonJS only. I recommend to build your project for ESM as well and use it as the default. Check out the build step and import configuration of Valibot. Reach out if you need help.