Skip to content

v0.40.1

Choose a tag to compare

@astrapi69 astrapi69 released this 12 Oct 15:37
· 10 commits to main since this release
9c74ecc

No schema change, no API change, no behaviour change: the structural
validators are precompiled at build time, so the core entry no longer ships
the ajv compiler (core 90.3 -> 65.8 kB gzip). Validation results are
byte-identical, measured over the eleven content repositories.

The structural validators are precompiled; the core no longer ships the ajv compiler (engine#261)

validateLesson and validateManifest used to compile the two schemas with
ajv on their first call, so every consumer's bundle carried the ajv compiler,
about 40 percent of the core entry. The validators are now generated at build
time with ajv's standalone code generation
(scripts/generate-schema-validators.mjs writes
src/schema-validators.generated.ts; make sync-types regenerates it and
make sync-types-check fails on drift), with the same options as before
(allErrors, strict: false). Only one ajv run-time helper ships.

Nothing a consumer sees changes. src/schema-validators.test.ts compares the
precompiled validators with the run-time compiler, error object for error
object, over the fixtures and every single-node mutation of them (more than a
thousand inputs, more than five hundred invalid). Over the eleven content
repositories, the old and the new build return byte-identical
validateLesson/validateManifest results for 42,517 inputs (every lesson and
manifest on origin/main, plus up to 60 mutations of each; 32,892 of them
invalid).

Measured with the bundle gate (gzip): core 90.3 -> 65.8 kB, /qti 55.4 ->
31.5 kB; an entry importing only validateLesson 46.0 -> 23.3 kB. The budgets
go down to the measurement plus about 10 kB (core 92 -> 76 kB, qti 60 -> 42
kB), and the gate now refuses the ajv compiler (ajv/dist/compile,
ajv/dist/vocabularies, fast-uri) in both entries.