Skip to content

chore(deps): move to zod 4 and import the Zod 3 API from zod/v3 - #22

Closed
louis-bompart wants to merge 1 commit into
mainfrom
claude/zod-v3-imports
Closed

louis-bompart wants to merge 1 commit into
mainfrom
claude/zod-v3-imports

Conversation

@louis-bompart

Copy link
Copy Markdown
Collaborator

Description

This moves the repo onto the zod@4 package while keeping the Zod 3 API: every in-repo import … from 'zod' becomes import … from 'zod/v3', and every workspace depends on zod@^4.6.7, which ships the Zod 3 API at zod/v3. The code and the schemas don't change; only where they're imported from does.

Why

We want to move A2UI to Zod 4, starting with the basic catalog, without moving everything at once. That needs a single zod copy in the repo that offers both APIs.

A partial bump doesn't work. I tried bumping only @a2ui/web_core: it ends up with two copies of the Zod 3 types (3.25.76 and zod@4's zod/v3). Zod types are still part of web_core's public API, so tsc crashes (SIGABRT) or reports "Type instantiation is excessively deep" in every package that passes schemas to it. With a single copy, code can keep using zod/v3 and adopt Zod 4 from zod file by file.

What changed

  • Imports: 103 source files, plus the schema generators (generate-zod-schemas, the catalog generators), now import from zod/v3. Regenerating the generated schemas changes nothing else.
  • Dependencies: zod goes from ^3.25.76 to ^4.6.7 in web_core, Lit, Angular, React (dependency and peer), vegachart, mcp, tools/composer and samples/client/angular. The root resolutions pin moves to ^4.6.7, so third-party packages that accept Zod 4 share the same copy. Before, the pin forced them onto 3.25.76.
  • Community samples: samples/community is a separate Yarn project that uses the published @a2ui/* packages, so it stays as it is. The two MCP sample clients bundle the in-repo mcp catalog, so their vite alias lists and tsconfig paths gain zod/v3, as they already had zod.
  • Docs: 12 snippets in 9 READMEs and guides import from zod/v3.

Breaking change for consumers

Packages that take Zod schemas from their callers (web_core, the renderers, the catalogs) need those callers on the same zod@^4.6.7, importing from zod/v3. A caller still on Zod 3.25 gets a second copy of the types, and one writing import {z} from 'zod' with Zod 4 gets Zod 4 schemas, which these APIs don't accept yet. This is noted as BREAKING CHANGE in the changelogs of web_core, Lit, Angular, React, vegachart and mcp.

How it's tested

  • From a clean build, yarn workspaces foreach -A -p --topological-dev run build and … run test pass in every workspace except one step, listed below. That covers web_core (1061 tests plus conformance), Lit, React, Angular unit and integration, markdown-it, vegachart, mcp, the agent SDK, the editor, inspector and shell tools, the samples and the specification tests.
  • ESLint reports no errors in the touched packages.
  • Prettier passes on every changed file except 11 Angular files, which were already unformatted on main.
  • Not verified:
    • Angular test:closure-compiler, which needs Java 21. The machine I ran on has Java 8, so it fails before compiling.
    • samples/community, which isn't installed in this checkout.

Pre-launch Checklist

For this PR:

  • I have updated the relevant CHANGELOG.md file.
  • I updated/added relevant documentation.
  • My code changes (if any) have tests. (Mechanical; covered by the existing suites.)
  • If my branch is on a fork, I have verified that scripts/e2e_test.sh passes.

🤖 Generated with Claude Code

Every in-repo import of 'zod' now reads 'zod/v3', and every workspace
depends on zod@^4.6.7, which ships the Zod 3 API at that entry point.
The code keeps using the Zod 3 API, so schemas and behavior are
unchanged; this only moves the repo to one zod 4 copy, so that code can
start using Zod 4 from 'zod' alongside it.

- The schema generators write 'zod/v3', so regenerating changes nothing.
- The root resolution pins zod to ^4.6.7, so third-party packages that
  accept Zod 4 share the same copy.
- The MCP recipe and filesystem samples alias 'zod/v3' to their own copy,
  as they already did for 'zod', for the in-repo MCP catalog they bundle.
- Docs and READMEs import from 'zod/v3'.

Packages that take Zod schemas from their callers now need callers on
the same zod@^4.6.7 copy, importing from 'zod/v3': noted as a breaking
change in each published package's changelog.

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

Copy link
Copy Markdown
Collaborator Author

Superseded by the regrouped stack on upstream main: this change is now part of #46 (series #45 to #54). The branch is kept for reference.

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