Skip to content

v0.14.0

Choose a tag to compare

@mertcanaltin mertcanaltin released this 12 Nov 15:05
· 64 commits to main since this release
02019ff

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

Changed

  • compile() writes each <module>.validators.mjs already compiled: every export is its schema written out as checks, and the file imports only the helpers those checks use, never the validator runtime. Written as new Validator(schema), the file was small only in a build that ran the plugin; imported by a build that did not, each validator brought the runtime compiler into the bundle, and nothing in the build output said so. On a page that uses one validator, bundled with esbuild and no plugin: 3.9 KB gzipped compiled against 142.8 KB as new Validator (ata-validator 1.63.1). The exports, their answers and their errors are the same; a server can import the same file.
  • compiled: false keeps the new Validator(schema) form, for a project whose bundler runs the plugin and should make the choices it makes for a whole application (shared errors, table plans). Inside a bundler the plugin writes that form as before and compiles it in the same build.

Not covered

  • The compiled file imports helpers from ata-validator/kernels, so a server that imports it unbundled still needs ata-validator installed.
  • A file with a validator the build cannot compile is written in the previous form, with a warning that says why.