Back to articles
Zod vs Typia vs AJV — I Built a Build Plugin That Makes Zod 60x Faster With Zero Code Changes

Zod vs Typia vs AJV — I Built a Build Plugin That Makes Zod 60x Faster With Zero Code Changes

via Dev.to JavaScriptTetsuya Wakita

When I first released Zod AOT, it required wrapping every schema with compile() : import { compile } from " zod-aot " ; const UserSchema = compile ( z . object ({ name : z . string (). min ( 1 ), email : z . email (), }) ); The #1 feedback was: "I don't want to change my code." Fair. So I removed that requirement. Zod AOT now has an autoDiscover mode — a Vite plugin that finds your Zod schemas at build time, compiles them into optimized validators, and replaces them in-place. Your schema files stay pure Zod. No imports from zod-aot. No wrappers. Just this: // vite.config.ts import zodAot from " zod-aot/vite " ; export default defineConfig ({ plugins : [ zodAot ({ autoDiscover : true })], }); That's it. Every exported Zod schema in your project gets AOT-compiled at build time. I also added Typia and AJV to the benchmarks, built a two-phase "Fast Path" validator, and shipped a diagnostic CLI. Here's what changed. autoDiscover: How It Works The challenge is detecting Zod schemas without a

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
7 views

Related Articles