Skip to content

Upgrade json-schema-library to v10 - #176

Open
samlown wants to merge 3 commits into
jsonnext:mainfrom
invopop:upstream-pr/json-schema-library-v10
Open

samlown wants to merge 3 commits into
jsonnext:mainfrom
invopop:upstream-pr/json-schema-library-v10

Conversation

@samlown

@samlown samlown commented Oct 27, 2026 •

Copy link
Copy Markdown

Upgrades json-schema-library from v9 to v10 and fixes a performance problem that v10 introduces.

This is the first of three PRs from the Invopop fork, which publishes these changes as @invopop/codemirror-json-schema. The other two build on this one.

Upgrade (2d84674)

  • Completion, hover and validation use the v10 compileSchema API instead of Draft07.
  • v10 keeps keywords next to $ref, so a $ref combined with a oneOf of consts now offers those values as completions (new test).
  • Hover shows the type of each oneOf option, for example #/definitions/fancyObject (object), and object completions report object as their detail. The tests are updated to match.

Linear if/then/else validation (5da40bd)

v10 validates if against a copy of the validation path ([...path]). That path holds every node visited so far and is never trimmed, so each if costs time proportional to everything validated before it, and validation becomes quadratic in document size. v11 (11.6.16) behaves the same.

Schemas that pick a definition by testing a discriminator with if/then are hit hardest. Linting a document with ~30 such conditions per node:

Document Before After
95 KB 1.9 s 0.46 s
380 KB 33 s 1.5 s
1.9 MB crashes the tab 7.2 s

src/utils/compile-schema.ts wraps compileSchema with the default drafts, but replaces the if validator. It validates if against the shared path and then truncates the path back to its previous length, which discards the same entries without the copy. $dynamicRef and $recursiveRef inside if still see the full dynamic scope, and a test checks this. Another test fails on the unpatched library: 8× the nodes took 76× the time. A third checks that properties evaluated by then/else still count for unevaluatedProperties. I'll also report the problem to json-schema-library, so the wrapper can be removed once it's fixed there.

Notes

  • The lockfile is regenerated with pnpm 9 to keep the diff small.
  • Each commit has a changeset.
  • pnpm test (138 tests), pnpm tsc and pnpm build pass.

🤖 Generated with Claude Code

samlown and others added 2 commits October 27, 2026 14:36
Move completion, hover and validation to the v10 compileSchema API.
v10 keeps sibling keywords next to $ref, so a $ref combined with a
oneOf of consts now offers those values as completions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
json-schema-library validates "if" against a copy of the validation
path so the nodes it evaluates aren't recorded. The path holds every
node visited so far and is never trimmed, so each "if" costs time
proportional to everything validated before it and validation is
quadratic in document size. Schemas that select definitions with
if/then took ~30s on a 380KB document and crashed the tab at 2MB.
v10 and v11 are both affected.

Compile schemas with drafts whose "if" validator uses the shared path
and truncates it afterwards, which discards the same entries without
the copy and keeps the dynamic scope for $dynamicRef and $recursiveRef.
All features now compile through utils/compile-schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for codemirror-json-schema ready!

Name Link
🔨 Latest commit 3505836
🔍 Latest deploy log https://app.netlify.com/projects/codemirror-json-schema/deploys/6ae0bbf7d71d0aab4b82cf68
😎 Deploy Preview https://deploy-preview-176--codemirror-json-schema.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3505836

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
codemirror-json-schema Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

json-schema-library v10 validators return errors only, and its
unevaluatedProperties re-runs "if" to find the evaluated branch, so the
wrapper's results match the library's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant