Thank you for your interest in contributing to zod-codepen! This document provides guidelines and instructions for contributing.
- Node.js ≥ 20
- pnpm ≥ 10.0.0
-
Fork the repository
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/zod-codepen.git cd zod-codepen -
Install dependencies:
pnpm install
-
Build all packages:
pnpm build
-
Run tests:
pnpm test
zod-codepen/
├── pkgs/
│ ├── core/ # Core serialization engine
│ ├── zod-v3/ # Zod v3 adapter
│ └── zod-v4/ # Zod v4 adapter
├── docs/ # VitePress documentation
└── package.json # Root workspace config
-
Create a feature branch:
git checkout -b feat/your-feature
-
Make your changes
-
Run tests to ensure nothing is broken:
pnpm test -
Run linting:
pnpm lint
- Run all tests:
pnpm test - Run v3 tests only:
pnpm test:v3 - Run v4 tests only:
pnpm test:v4 - Run tests in watch mode:
pnpm --filter @zod-codepen/zod-v3 test:watch
- Start docs dev server:
pnpm docs:dev - Build docs:
pnpm docs:build - Preview built docs:
pnpm docs:preview
We follow Conventional Commits:
feat:New featuresfix:Bug fixesdocs:Documentation changestest:Test additions or modificationsrefactor:Code refactoringchore:Maintenance tasks
Examples:
feat: add support for z.datetime() constraint
fix: handle null values in object serialization
docs: add examples for custom handlers
test: add tests for bigint constraints
- Update documentation if needed
- Add tests for new features
- Ensure all tests pass
- Update the README if needed
- Submit your PR with a clear description
Use the same format as commit messages:
feat: Add new featurefix: Fix bug in serializer
To add support for a new Zod schema type:
-
Add a handler in
pkgs/core/src/serializer.ts:handlers.set('newtype', (schema, ctx) => { const def = ctx.adapter.getDef(schema); // ... serialization logic return 'z.newType(...)'; });
-
Add tests in both
pkgs/zod-v3/test/andpkgs/zod-v4/test/ -
Update documentation in
docs/guide/supported-types.md
When reporting issues, please include:
- Node.js version
- Zod version
- zod-codepen version
- Minimal reproduction code
- Expected vs actual behavior
Feel free to open an issue for questions or discussions.
By contributing, you agree that your contributions will be licensed under the Mozilla Public License 2.0.