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
At the moment we're bundling Ajv with JSON Forms. While validation is a core concern of JSON Forms we are forcing our users to use our bundled Ajv or to include it twice. Therefore we should transform Ajv to a peer dependency and maybe make it optional in general.
Reacted by Jorge Rodríguez Pedrianes, Björn Clees, Benoît Burgener and Andrew Perry
We'd like to help with this, scoped so that it doesn't break adopters and can land in 3.x.
Our use case: we use @jsonforms/core directly, with our own Lit (web components) binding and renderers, under a strict CSP (no 'unsafe-eval') on websites and in Capacitor apps. In our tests with the Form Validator from #2644, we validate with an interpreter (@cfworker/json-schema) and never use Ajv. Even so, Ajv and ajv-formats are about 40 kB gzip of our form bundle (136.0 kB → 96.4 kB without them), because core imports them statically for its fallback createAjv(). #2648 deliberately keeps that import.
Proposal: an opt-in entry point, @jsonforms/core/core-only, for 3.x
@jsonforms/core is unchanged: same exports, Ajv still the default. Nothing changes for the bindings or renderer sets.
@jsonforms/core/core-only exports everything except createAjv, createAjvValidator and validate, and never loads Ajv. Validation needs a validator, an ajv instance, or validationMode: 'NoValidation'. Otherwise init throws an error explaining that.
How: Ajv moves into one module (util/validator.ts), which registers itself as the default when loaded. The reducer asks for the default instead of importing createAjv. Rollup builds both entry points with a shared chunk, so importing both doesn't duplicate core. There's no exports map, so deep imports keep working; the subpath resolves through a small core-only/package.json.
It's stacked on #2644 (and #2645/#2648), since without a Form Validator an Ajv-free core could only turn validation off. Making Ajv an optional peer dependency, as this issue originally proposed, would still be a natural 4.0 follow-up, and this entry point would make that step smaller.
We have a working branch with tests and can open a draft PR on top of #2644 if this direction suits you. Open questions:
The name: we went with core-only (core without a bundled validator). Happy to change it if you prefer another.
Throwing when no validator is configured, versus silently skipping validation. We chose to throw so that forms relying on required checks can't lose them unnoticed.
Generally speaking this sounds like a solid plan. Do you have specific urgency on this? If the AJV paths are actually unused today in your applications, you can also workaround the issue by bundling-magic, replacing ajv and ajv-formats with empty stubs.
Thanks, our form builder component that depends on it is currently carrying the extra payload, rather than use the fork that we shared with the commits that implement the update on top of the other contributions made by @gigibiffi84 that support it: collaboratory-int/jsonforms@master...feat/core-only-entry
Given the work contributed by @gigibiffi84 seems close to merge, I think it would be awesome to be able to significantly reduce the size of the bundle, as well as avoid the CSP issue that we currently work around by using @cfworker/json-schema instead of ajv. Happy to send a PR from collaboratory-int/jsonforms@master...feat/core-only-entry
14. Hi @andrewperry,
Generally speaking this sounds like a solid plan. Do you have specific urgency on this? If the AJV paths are actually unused today in your applications, you can also workaround the issue by bundling-magic, replacing ajv and ajv-formats with empty stubs.
Activity
andrewperry commentedon Oct 22, 2026
We'd like to help with this, scoped so that it doesn't break adopters and can land in 3.x.
Our use case: we use
@jsonforms/coredirectly, with our own Lit (web components) binding and renderers, under a strict CSP (no'unsafe-eval') on websites and in Capacitor apps. In our tests with the Form Validator from #2644, we validate with an interpreter (@cfworker/json-schema) and never use Ajv. Even so, Ajv and ajv-formats are about 40 kB gzip of our form bundle (136.0 kB → 96.4 kB without them), because core imports them statically for its fallbackcreateAjv(). #2648 deliberately keeps that import.Proposal: an opt-in entry point,
@jsonforms/core/core-only, for 3.x@jsonforms/coreis unchanged: same exports, Ajv still the default. Nothing changes for the bindings or renderer sets.@jsonforms/core/core-onlyexports everything exceptcreateAjv,createAjvValidatorandvalidate, and never loads Ajv. Validation needs avalidator, anajvinstance, orvalidationMode: 'NoValidation'. Otherwiseinitthrows an error explaining that.util/validator.ts), which registers itself as the default when loaded. The reducer asks for the default instead of importingcreateAjv. Rollup builds both entry points with a shared chunk, so importing both doesn't duplicate core. There's noexportsmap, so deep imports keep working; the subpath resolves through a smallcore-only/package.json.It's stacked on #2644 (and #2645/#2648), since without a Form Validator an Ajv-free core could only turn validation off. Making Ajv an optional peer dependency, as this issue originally proposed, would still be a natural 4.0 follow-up, and this entry point would make that step smaller.
We have a working branch with tests and can open a draft PR on top of #2644 if this direction suits you. Open questions:
core-only(core without a bundled validator). Happy to change it if you prefer another.requiredchecks can't lose them unnoticed.Branch: collaboratory-int/jsonforms@master...feat/core-only-entry (the last three commits are ours; the rest is the #2644 stack). Our commits alone: collaboratory-int/jsonforms@1cbe9bd...feat/core-only-entry
sdirix commentedon Oct 22, 2026
Hi @andrewperry,
Generally speaking this sounds like a solid plan. Do you have specific urgency on this? If the AJV paths are actually unused today in your applications, you can also workaround the issue by bundling-magic, replacing ajv and ajv-formats with empty stubs.
andrewperry commentedon Oct 26, 2026
Thanks, our form builder component that depends on it is currently carrying the extra payload, rather than use the fork that we shared with the commits that implement the update on top of the other contributions made by @gigibiffi84 that support it: collaboratory-int/jsonforms@master...feat/core-only-entry
Given the work contributed by @gigibiffi84 seems close to merge, I think it would be awesome to be able to significantly reduce the size of the bundle, as well as avoid the CSP issue that we currently work around by using @cfworker/json-schema instead of ajv. Happy to send a PR from collaboratory-int/jsonforms@master...feat/core-only-entry