Skip to content

v0.15.0

Choose a tag to compare

@mertcanaltin mertcanaltin released this 12 Nov 18:32
· 62 commits to main since this release
ea78653

One change, for projects that call compile() from a script with the zod or from option.

Changed

  • Where there are many validators, compile() writes them as plans for one small interpreter instead of as checks written out one by one, when that makes the smaller bundle. It weighs all the files it writes together, as the plugin does for an application inside a bundler, and chooses plans when they save more than the interpreter costs. Seven flat event schemas in one entry, bundled with esbuild and no plugin: 2.8 KB gzipped as plans (12 KB before compression) against 10.5 KB as written checks (139 KB). The exports, their answers and their errors are the same.
  • A page that imports one validator from a set written as plans carries the interpreter too. On the same schemas, one file each: a 10-field schema 1,254 bytes gzipped as a plan against 884 as written checks, a 43-field one 1,438 against 3,240, a 60-field one 1,512 against 3,771.
  • A plan is slower to run than written checks. On an event of 44 optional fields (Node 25, Apple M4 Pro) a valid document takes about 1.0 µs against 0.6, and a rejected one with its errors read 1.4 µs against 0.1.
  • table: false keeps written checks, table: true takes plans whatever the sizes. The result of compile() carries table, the choice made.

Not covered

  • A schema the table backend does not take stays written checks.
  • The sizes are from esbuild; other bundlers were not measured for this change.