refactor: migrate to astro@6#28874
Merged
Merged
Conversation
Contributor
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
Contributor
|
Preview URL: https://7a07c16a.preview.developers.cloudflare.com |
kodster28
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate to Astro 6 (Beta)
This change is mostly focused around migrating to
zod@4since this project doesn't use the Cloudflare adapter.What Changed
1. Package Upgrades
astro5.13.76.0.5@astrojs/check0.9.40.9.8@astrojs/react4.2.55.0.0@astrojs/rss4.0.124.0.17@astrojs/sitemap3.5.13.7.1@astrojs/starlight0.37.60.38.1@astrojs/starlight-docsearch0.6.00.7.0@astrojs/starlight-tailwind4.0.15.0.0starlight-image-zoom0.13.00.14.1starlight-links-validator0.17.20.20.1starlight-package-managers0.11.00.12.0starlight-showcases0.3.00.3.2starlight-scroll-to-top0.4.00.4.0astro-breadcrumbs3.3.13.4.0eslint-plugin-astro1.3.11.6.02. Schema Import Migration:
astro:schema→astro/zodAstro 6 deprecates the
astro:schemavirtual module in favor ofastro/zod. All 18 schema files insrc/schemas/wereupdated:
3. Zod 4 API Migrations
Zod 4 introduces several breaking changes that required updates to our schema definitions:
a. Stricter
.record()type signaturesBefore (Zod 3):
z.record(valueSchema)— key type was implicitlystringAfter (Zod 4):
z.record(keySchema, valueSchema)— both key and value types must be explicitb.
.default({})→.prefault({})Zod 4 removes the ability to call
.default({})on objects that haven't been explicitly created via.object(). Thereplacement is
.prefault({}), which preserves the same runtime behavior while being type-safe.c.
.passthrough()→.looseObject()Zod 4 deprecates
.passthrough()in favor of.looseObject(), which is more explicit about allowing unknown keys.d.
.function().args(...).returns(...)→.function({ input: [...], output: ... })Zod 4 changes the function schema builder API to use an object syntax:
BaseSchemaProperties Component: Migrating from Zod Internals to JSON Schema
The
BaseSchemaProperties.astrocomponent renders documentation for our frontmatter schema fields (used in/style-guide/frontmatter/). It introspects Zod schemas to extract field names, types, descriptions, and allowedvalues. Much of the introspection tools are different or don't exist in
zod@4.Instead of introspection, which couples the page to zod's internal structure, JSON schema is used to build the page.
JSON schema is a first-class citizen in
zod@4.4. Frontmatter Schema: From Strict Unions to Flexible Strings
The original schema declaration for
pcx_content_typeanddifficultysimultaneously validated against a strict set ofallowed values and allowed all values. The contradiction was resolved by just allowing all strings, removing the
union validation.
This isn't related to
astro@6. This is always been a contradiction.zod@4migration was just the catalystsince the use of
.catchbreaks the JSON schema logic above.5. Red-herring shift to
:globalfor Scoped StylesThere was an Astro bug (withastro/astro#15907) related to scoped styles that cropped up due to the project's
tendency to attempt to apply styles across components, most commonly styling internal classes of Starlight. Before
I realized there was an Astro bug, I was attempting to solve these issues by using the recommended
is:global/:global(i.e. global styles). Once I found the bug (and the subsequent fix to the big in@astrojs/compiler@3.0.1), these global-related fixes weren't needed.But the reason why the bug affected this project in the first place is due to the lack of
:global. So I kept themin. However,
Footer.astro's version of the bug was kept around because I was using that as a test to make sure@astrojs/compiler@3.0.1truly fixed the styling issues. (It did.)Testing
npm run checkpasses (Astro + Worker type checking)npm run lintpassesnpm run format:core:checkpassesExample URLS to compare
Do not limit testing to these URLs.
/changelog/2026-02-15-workers-best-practices//workers/examples/read-post//workers/examples/turnstile-html-rewriter//images/tutorials/optimize-user-uploaded-image/