@zod-codepen/vite-plugin
v1.0.1
Published
Vite plugin to decouple Zod schemas from heavy dependencies
Downloads
5
Maintainers
Readme
[!TIP] @zod-codepen/vite-plugin provides seamless Vite integration for Zod schema serialization. Automatically transform and optimize your schemas at build time. Visit our documentation site for complete setup guide and examples.
Installation
npm install -D @zod-codepen/vite-pluginQuick Start
// vite.config.ts
import { defineConfig } from 'vite';
import zodCodepen from '@zod-codepen/vite-plugin';
export default defineConfig({
plugins: [
zodCodepen({
// Options
})
]
});Features
- 🚀 Build-time optimization - Transform schemas during build
- 🔧 Hot Module Replacement - Instant updates during development
- 📦 Tree-shaking friendly - Optimized bundle size
- 🎯 TypeScript support - Full type safety
- ⚡ Zero runtime overhead - All transformations at build time
Configuration
interface ZodCodepenOptions {
// Include patterns for transformation
include?: string | string[];
// Exclude patterns
exclude?: string | string[];
// Output format
format?: 'esm' | 'cjs';
// Enable source maps
sourcemap?: boolean;
}Example Usage
// schemas.ts
import { z } from 'zod';
export const UserSchema = z.object({
name: z.string(),
email: z.string().email(),
age: z.number().int().positive()
});
// With the plugin, this schema can be automatically serialized
// and optimized during build timeDocumentation
For detailed configuration options and advanced usage:
Requirements
- Node.js ≥ 20
- Vite ≥ 5.0.0
- Zod ^3.0.0 or ^4.0.0
License
MPL-2.0 © CornWorld
