Skip to content

Conversation

@matthewp
Copy link
Contributor

@matthewp matthewp commented Dec 3, 2025

Changes

  • A lot of use of .prefault() and changing z.object(z.number()) to z.object(z.string(), z.number())

Testing

  • Existing tests pass
  • Most significant changes here are because error messages are a little different in Zod 4.

Docs

Consolidate Zod v3 to v4 upgrade with comprehensive changes:

- Remove dual Zod version support, standardize on v4
- Simplify type systems and remove experimental.zod4 flag
- Update dependencies: js-yaml, magic-string, magicast to latest versions
- Replace kleur with piccolore for CLI colors
- Refactor content layer, actions, and config to use unified Zod handling
- Simplify JSON schema generation and type generation
- Remove z3/z4 branching logic throughout codebase
- Update error handling to work with unified Zod implementation

BREAKING CHANGE: Zod v3 support removed, project now requires Zod v4+
- Remove all z3 imports and replace with z4/zod
- Remove z3-specific functions (formDataToZ3Object, handleZ3FormDataGetAll/Get, unwrapBaseZ3ObjectSchema, createZ3Image)
- Remove dual-version type unions, simplify to z4-only types
- Remove z3ErrorMap function, keep only z4ErrorMap
- Remove checkZodSchemaCompatibility calls (no longer needed)
- Simplify vite-plugin-experimental-zod4/utils.ts to no-op
- Update package.json to require zod ^4.0.0
- Update test files and exports to reference z4 versions
@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: 93acc31

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

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

@github-actions github-actions bot added pkg: example Related to an example package (scope) pkg: astro Related to the core `astro` package (scope) docs pr labels Dec 3, 2025
@github-actions github-actions bot added pkg: svelte Related to Svelte (scope) pkg: integration Related to any renderer integration (scope) labels Dec 4, 2025
@florian-lefebvre florian-lefebvre added this to the v6.0.0 milestone Dec 5, 2025
@florian-lefebvre
Copy link
Member

I'll check it out tomorrow morning

@github-actions github-actions bot removed the pkg: svelte Related to Svelte (scope) label Dec 10, 2025
Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM! The changeset will probably need to be updated after the linked docs PR is approved

@github-actions github-actions bot added the pkg: svelte Related to Svelte (scope) label Dec 10, 2025
@matthewp
Copy link
Contributor Author

@florian-lefebvre I still don't understand why 82f1de6 is necessary. can you explain?

@florian-lefebvre
Copy link
Member

In my zod 3/4 PR I would replace '@@REFERENCE@@' dynamically based on the zod version, for example to export const reference: import('astro/content/config').Z4Reference.

Now that we only support v4, this codegen logic has been removed so this flag was never replaced. Instead I "inlined" Z4Reference. This diff shows it's just about updating it from zod 3 to zod 4 types:

image

@matthewp
Copy link
Contributor Author

@florian-lefebvre why are types not coming from the implementation of reference?

@florian-lefebvre
Copy link
Member

florian-lefebvre commented Dec 10, 2025

Because in this case, reference() types rely on codegen stuff. Specifically the DataEntryMap

@florian-lefebvre
Copy link
Member

Let me know if you want me to handle the fonts breaking change, I made these changes very recently so I can probably untangle it quickly

@matthewp
Copy link
Contributor Author

@florian-lefebvre yes, I would appreciate it if you could do that. Thank you!

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for docs, and the docs PR is also good to go! Nice job, Matthew! 🎉

@matthewp matthewp merged commit 0ff51df into next Dec 12, 2025
23 checks passed
@matthewp matthewp deleted the zod4-m branch December 12, 2025 16:01
ematipico pushed a commit that referenced this pull request Dec 12, 2025
* feat: upgrade to Zod v4

Consolidate Zod v3 to v4 upgrade with comprehensive changes:

- Remove dual Zod version support, standardize on v4
- Simplify type systems and remove experimental.zod4 flag
- Update dependencies: js-yaml, magic-string, magicast to latest versions
- Replace kleur with piccolore for CLI colors
- Refactor content layer, actions, and config to use unified Zod handling
- Simplify JSON schema generation and type generation
- Remove z3/z4 branching logic throughout codebase
- Update error handling to work with unified Zod implementation

BREAKING CHANGE: Zod v3 support removed, project now requires Zod v4+

* Remove Zod v3 support, keep only v4

- Remove all z3 imports and replace with z4/zod
- Remove z3-specific functions (formDataToZ3Object, handleZ3FormDataGetAll/Get, unwrapBaseZ3ObjectSchema, createZ3Image)
- Remove dual-version type unions, simplify to z4-only types
- Remove z3ErrorMap function, keep only z4ErrorMap
- Remove checkZodSchemaCompatibility calls (no longer needed)
- Simplify vite-plugin-experimental-zod4/utils.ts to no-op
- Update package.json to require zod ^4.0.0
- Update test files and exports to reference z4 versions

* Finish upgrade

* skip these tests for now

* skip this one too

* correct mark the received item

* fix config-validate tests

* merge: resolve conflicts between zod4-m and next

* fix remaining build error

* remove references to zod4 thing

* fixes

* prevent the crash

* switch to the native zod to json schema

* oops

* fix content layer tests

* fix error map tests

* fix actions test

* fix intellisense tsts

* fix schema test

* fix: types

* Update Svelte to exactly 5.43.8 in package and fixtures

* fix svelte tests

* fix more e2e

* fix cloudflare tests

* fix defineMiddleware issue

* remove unused reference

* fix examples types

* pr comment stuff

* changeset

* remove experiemental flag

* add some debugging here

* remove debugging stuff

* Update packages/astro/src/actions/vite-plugin-actions.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* fix

* fix: import

* use zod/v4 imports in core

* remove createDefineAction

* remove unnecessary type alias

* remove unused z4reference

* rename stuff

* unskip tests

* rename back to createImage

* nit

* revert markdown change

* put errorMap name back

* address feedback on rss

* fix: exports

* Update packages/astro-rss/src/index.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro-rss/src/schema.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro-rss/src/util.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/assets/fonts/config.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/assets/fonts/types.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/content/loaders/types.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/content/config.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/core/config/schemas/relative.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/test/units/config/config-validate.test.js

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/test/units/actions/form-data-to-object.test.js

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/core/config/schemas/refined.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/content/content-layer.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/content/types-generator.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Update packages/astro/src/content/utils.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Use $ZodError

* Update packages/astro/src/core/csp/config.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* fix the build

* fix e2e test

* replace z4 with z

* increase vercel test timeout

* pr comments

* export ImageFunction

* use prefault

* Validate experimental features special

* bring back old locales

* fix test

* db needs to be a patch too

* fix chainability of image

* update zod imports

* Discard changes to packages/integrations/svelte/package.json

* Discard changes to packages/integrations/svelte/test/fixtures/async-rendering/package.json

* refresh lockfile

* chore: changeset

* fix: reference()

* skip broken svelte test

* Update .changeset/dance-ornate-keen.md

Co-authored-by: Sarah Rainsberger <[email protected]>

* fix config vlaidate test

---------

Co-authored-by: Florian Lefebvre <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope) pkg: integration Related to any renderer integration (scope) pkg: svelte Related to Svelte (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Zod 4

6 participants