How wakita181009/zod-aot works
Zod AOT compiles existing Zod schemas into optimized validators, principally during a bundler transform; the CLI offers generation, watch, and schema-diagnostic workflows. The core pipeline extracts schema structure and generates fast/slow validation code, with fallback support for unsupported features. Plugin adapters cover the documented bundlers. Some subsystems are represented by their exact source directories because their implementation files were not excerpted; relationships are included only where the index, excerpts, or README support them.
Main entry points: transform.ts Schema transform · generate.ts Code generation command · index.ts Validator codegen · pipeline.ts Compile pipeline
Components 23
Build integrations
- Bundler adapters
packages/zod-aot/src/unplugin - Schema transform
packages/zod-aot/src/unplugin/transform.ts - Shared runtime module
packages/zod-aot/src/unplugin/virtual.ts
Schema compiler
- Schema discovery
packages/zod-aot/src/discovery.ts - Compile API
packages/zod-aot/src/index.ts - Compile pipeline
packages/zod-aot/src/core/pipeline.ts - Schema extraction
packages/zod-aot/src/core/extract - Validator codegen
packages/zod-aot/src/core/codegen/index.ts - Codegen context
packages/zod-aot/src/core/codegen/context.ts - Schema generators
packages/zod-aot/src/core/codegen/schemas - Fast and slow paths
packages/zod-aot/src/core/codegen/fast-path.ts - Regex helpers
packages/zod-aot/src/core/codegen/well-known-regex.ts
CLI workflows
- CLI commands
packages/zod-aot/src/cli/index.ts - Code generation command
packages/zod-aot/src/cli/commands/generate.ts - Watch command
packages/zod-aot/src/cli/commands/watch.ts - Output emitter
packages/zod-aot/src/cli/emitter.ts - Schema diagnostics
packages/zod-aot/src/cli/commands/check.ts
Validation runtime
- Compiled validator
packages/zod-aot/src/core/iife.ts - Zod fallback
packages/zod-aot/src/core/extract/fallback.ts
Other components
- Developer
- Bundler
- Zod schemas
- Application
Connections 23
- Developer → Zod schemas: defines
README.md - Bundler → Bundler adapters: loads plugin
README.md - Bundler adapters → Schema transform: registers transform
packages/zod-aot/src/unplugin/index.ts - Schema transform → Schema discovery: discovers schemas
README.md - Schema transform → Compile pipeline: compiles schemas
README.md - Compile pipeline → Schema extraction: extracts schema
packages/zod-aot/src/core/pipeline.ts - Compile pipeline → Validator codegen: generates validator
packages/zod-aot/src/core/pipeline.ts - Validator codegen → Codegen context: uses context
packages/zod-aot/src/core/codegen/index.ts - Validator codegen → Fast and slow paths: selects paths
packages/zod-aot/src/core/codegen/index.ts - Codegen context → Regex helpers: looks up regex
packages/zod-aot/src/core/codegen/context.ts - Schema transform → Shared runtime module: imports helpers
packages/zod-aot/src/unplugin/index.ts - Schema transform → Zod schemas: rewrites exports
README.md - CLI commands → Code generation command: dispatches
packages/zod-aot/src/cli/index.ts - CLI commands → Watch command: dispatches
packages/zod-aot/src/cli/index.ts - CLI commands → Schema diagnostics: dispatches
packages/zod-aot/src/cli/index.ts - Code generation command → Schema discovery: discovers schemas
README.md - Code generation command → Compile pipeline: compiles schemas
README.md - Code generation command → Output emitter: writes output
packages/zod-aot/src/cli/commands/generate.ts - Watch command → Code generation command: regenerates
packages/zod-aot/src/cli/commands/watch.ts - Schema diagnostics → Zod schemas: analyzes schemas
README.md - Validator codegen → Compiled validator: emits wrapper
- Compiled validator → Zod fallback: delegates unsupported
- Application → Compiled validator: validates data
README.md