You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6f04836
Browse filesBrowse the repository at this point in the historyBrowse files
fix(v4): derive JSON Schema constraints by folding checks in the converter (#6554)
* fix(v4): derive JSON Schema constraints by folding checks in the converter
* fix(v4): keep integer conjunctions and mime narrowing order-independent in the fold
* refactor(v4): stop checks writing metadata into the bag now the converter folds them
* fix(v4): resolve lazy parts in template literals and keep derived getters assignable
* test(v4): pin that a derived metadata member recomputes after deletion
* refactor(v4): tidy the check fold
Collapse the eight hand-written derived-member accessor pairs in classic into one `util.derived` installer; share the fold's narrowing, divisor, pattern, mime and format helpers between the contributors and the bag reconciliation; type the aggregate's bounds generically so the numeric consumers stop casting; have `partPattern` return a pattern source so the template literal reuses `cleanRegex`; flatten the file processor's mime branches.
* fix(v4): keep derived members configurable, as the literal accessors they replace were
* refactor(v4): split the template literal part fold from the wrapper substitution
* refactor(v4): let checks declare a string's pattern on attach, and drop the template literal fold
The pattern a string or number exposes for template literals comes from its checks again, the way it did before the bag strip, but declared structurally: length checks narrow the bag's bounds (tightest wins, whatever the chain order), pattern-carrying checks set the bag's pattern (last wins), and an integer format sets the integer pattern. The string and number inits read those three keys and nothing else derives part patterns, so wrappers and unions compose them as they always did and the template literal is back to its plain loop. The JSON Schema converter still folds the defs.
`regexes.string` answers an empty range with a pattern that matches nothing instead of building an invalid quantifier. The mini ceilings go back to main's.
* Revert "refactor(v4): let checks declare a string's pattern on attach, and drop the template literal fold"
This reverts commit 4a5b175.
// Also carries the Standard Schema issue bag: a failing `~standard.validate` parses with a plain issue holder instead of constructing a ZodError. Measured 2974 / 3455 / 4540 locally plus 28 headroom.
48
48
// Also carries the lazy `safeParse` error: a getter and a setter on the failing result, and the async wrapper that keeps a sync throw a rejection. Measured 3021 / 3497 / 4581 locally plus 18 headroom.
49
49
// Also carries the symbol-key loop in `util.members`, which is what installs `$ZodProperties`'s `Symbol.iterator` on its prototype, and the memoizer's shared reference predicate. Measured 3036 / 3516 / 4611 locally plus 18 headroom.
50
-
"zod-mini-string": 3534,
50
+
// Lowered by the measured â105 when checks stopped writing metadata into the bag at attach time: the string length/format closures and the per-instance bounded regex left every string bundle, and the template literal now derives its own part patterns.
51
+
"zod-mini-string": 3429,
51
52
// Also carries the construction-time discriminator check, which writes a WeakMap entry from `$ZodObject`, so every bundle containing `z.object` pays for it whether or not it builds a discriminated union.
52
53
// Also carries the declared symbol keys from #6448: `normalizeDef` collects the shape's own symbols and the parse loop walks them. Almost none of that is the `Reflect.ownKeys` conversions â reverting all eight of them measures a byte larger.
53
54
// Also carries the memoizer seam from #6482: each container init reads `globalConfig.memoizer` and calls `attach`, which is what lets `zod/mini` opt into cycle support. Measured 4512 locally but 4533 on CI â the gzip stream differs across zlib builds â so the headroom rides on the CI number.
54
55
// Also carries the Standard Schema issue bag: a failing `~standard.validate` parses with a plain issue holder instead of constructing a ZodError. Measured 2974 / 3455 / 4540 locally plus 28 headroom.
55
56
// Also carries the lazy `safeParse` error: a getter and a setter on the failing result, and the async wrapper that keeps a sync throw a rejection. Measured 3021 / 3497 / 4581 locally plus 18 headroom.
56
57
// Also carries the symbol-key loop in `util.members`, which is what installs `$ZodProperties`'s `Symbol.iterator` on its prototype, and the memoizer's shared reference predicate. Measured 3036 / 3516 / 4611 locally plus 18 headroom.
57
58
// Also carries the guards `validate` parses under: an `aborted` check in each container loop, and two early exits in the generated object parser. Only a bundle containing a container pays â boolean is byte-identical to main and string measures three bytes smaller â so this ceiling rises by the measured +76 and the other two do not move. Measured 4696 locally plus 18 headroom.
58
-
"zod-mini-object": 4714,
59
+
// Lowered by the measured â69 for the same bag strip: the string and number inits no longer carry pattern derivation or attach-time metadata writes.
0 commit comments