refactor: replace valibot with minimal inline StandardSchemaV1 schemas#5
Merged
refactor: replace valibot with minimal inline StandardSchemaV1 schemas#5
Conversation
size-limit report 📦
|
e40e22f to
52292a2
Compare
Removes valibot as a runtime dependency; implements custom schema/propSchema helpers for coercion and ref validation. Moves valibot to devDependencies for test-only use.
52292a2 to
36fe616
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Removes valibot as a runtime/bundled dependency by replacing it with minimal inline schema
helpers that implement the StandardSchemaV1 protocol directly.
Problem Statement
valibot was a runtime dependency bundled into the library output, adding unnecessary weight. The
library only used a small subset of valibot's API (type coercion and basic validation) and the
StandardSchemaV1 protocol it already depends on is sufficient to implement those directly — no
third-party schema library is needed at runtime.
Solution Approach
builders.tswith three small helpers:schema()— creates a raw StandardSchemaV1-conforming objectpropSchema()— wraps coercion logic with fallback resolution and nullable short-circuit,eliminating the repeated pattern across all prop builders
fail()— constructs a StandardSchemaV1 issue result, deduplicating the error path acrossnumber,oneOf, andrefSchemavalidatorsdevDependenciesso it remains available for tests, where it serves as anexample of a user-provided StandardSchemaV1-compatible schema passed to
propBuilders.json()Breaking Changes
None.
Testing
All existing tests pass.