News for hackers. Stuff that matters.
Re:Zod 4 by jasonthorsness on Monday May 19, 2025 @12:14PM (#44031384)
But how is the below possible - doesn't it need to include most of the TypeScript compiler? Does it compile the type definitions to some kind of validation structure (like how a compiled regex works) and then use just that?

    - Zero external dependencies
    - Works in Node.js and all modern browsers
    - Tiny: 2kb core bundle (gzipped)
Re:Zod 4 by _tqr3 on Monday May 19, 2025 @12:25PM (#44031512)
The TypeScript compiler is only needed during development, the compiled JavaScript code contains no TypeScript-specific logic. Zod’s validation is entirely JavaScript-based, relying on simple checks (e.g., typeof, regexes, comparisons).

Also, the 2kb bundle just for the zod/v4-mini package, the full zod/v4 package is quite large.

Re:Zod 4 by hdjrudni on Tuesday May 20, 2025 @03:55AM (#44038942)
5.36kB is not "quite large". It's pretty reasonable, esp. if you're only running it on the server.
Re:Zod 4 by Aeyxen on Monday May 19, 2025 @12:39PM (#44031630)
I think Zod uses JIT compilation via `new Function`, rather than including the entire TypeScript compiler. This method allows for concise validation logic, executing only what’s necessary at runtime.