@systemfsoftware/effect-schema-vite
v3.0.1
Published
Vite plugin that auto-discovers Effect Schema exports and injects codec law and generation law property tests via @systemfsoftware/effect-schema-law.
Maintainers
Readme
@systemfsoftware/effect-schema-vite
Vite plugin that automatically discovers exported Effect Schema declarations and injects codec law and generation law property tests using @systemfsoftware/effect-schema-law.
Install
pnpm add -D @systemfsoftware/effect-schema-vite @systemfsoftware/effect-schema-law effect vite vitestUsage
Add the plugin to your vitest.config.ts:
import { inlineSchemaTests } from '@systemfsoftware/effect-schema-vite'
import { defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [inlineSchemaTests()],
})The plugin scans exported schemas in src/ (configurable via dir) and writes a generated src/schema-laws.test.ts suite asserting round-trip identity and encode stability, plus the generation laws of every recursive schema: its generated nesting stays inside the ceiling the schema declares, deep values stay reachable, and every member of the cycle stays inhabited.
It also materializes those ceilings: a recursive schema that declares recursionBudget in stock Effect vocabulary gets the derivation hook that honors it, so registering this one plugin is enough for the declared laws to hold.
API
The public surface is generated from the source and versioned with the package: etc/effect-schema-vite.api.md.
Options
InlineSchemaTestsOptions:
dir(string, default"src"): Root source directory to scan for schema exports.
Apache-2.0. Part of systemfsoftware.
