Skip to content

chore: upgrade astro to v7 and playwright to 1.61.1 - #169

Merged
xiaoyijun merged 6 commits into
masterfrom
xiaoyijun-chore-upgrade-astro-7
Jul 6, 2026
Merged

chore: upgrade astro to v7 and playwright to 1.61.1#169
xiaoyijun merged 6 commits into
masterfrom
xiaoyijun-chore-upgrade-astro-7

Conversation

@xiaoyijun

@xiaoyijun xiaoyijun commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Upgrade Astro from 5.16.5 to 7.0.6 (across two majors) along with related tooling, and fix the build stability issues surfaced by the upgrade.

Dependency upgrades

  • astro 5.16.5 → 7.0.6, @astrojs/mdx 4.3.13 → 7.0.2, @astrojs/markdown-remark 6.3.10 → 7.2.1, @astrojs/sitemap 3.6.0 → 3.7.3, @astrojs/check 0.9.6 → 0.9.9
  • vitest / @vitest/coverage-v8 3.2.4 → 4.1.9 (required for Vite 8)
  • playwright 1.48.2 → 1.61.1, dropping the playwright-core patch since the insecure curl -k usage was fixed upstream
  • Removed the obsolete vite pnpm override; added peerDependencyRules for astro-i18n-aut / @astrolib/seo (their hooks and APIs work fine on Astro 7, they just haven't updated peer ranges)

Astro 7 adaptations

  • Astro 7 renders Markdown with its native Sätteri pipeline by default; we keep the unified (remark/rehype) pipeline via markdown.processor: unified({...}) since rehype-mermaid, remark-custom-header-id, and the footnote label option depend on it
  • Set compressHTML: true to keep the pre-v7 HTML-aware whitespace behavior (the new 'jsx' default strips spaces between inline elements)
  • Import z from astro/zod instead of the deprecated astro:content export

Build stability fixes

  • Gate Mermaid rendering behind a global concurrency limit (2). Vite 8 compiles MDX files in parallel and rehype-mermaid opens a browser tab per file; without a cap, ~600 diagram-bearing files open hundreds of tabs at once and exhaust system memory. Peak browser process count is now ~13 for a full build.
  • Share one browser context across cover screenshots and retry on failure. browser.newPage() created an isolated context per cover, re-downloading Google Fonts assets for every one of ~1070 covers, which eventually hit rate limiting and timed out the build. A shared context reuses the HTTP cache; full build now completes in ~3.5 minutes.

New: GitHub-style callouts

> [!Note] blockquotes were rendered as literal text (also on production). A small local rehype plugin now renders them as styled callouts, using the bracketed keyword as the title so localized markers ([!注意], [!Hinweis], [!Nota], …) work without a keyword whitelist. Styled for both light and dark modes.

Verification

  • astro check 0 errors; all unit tests pass
  • Full 980-page build verified: i18n routes for all 13 locales, /en/* redirect stubs, sitemap (897 URLs, default locale unprefixed), 872 covers, Mermaid light/dark SVGs, Shiki dual themes, custom heading anchors, footnotes
  • Built page body text is byte-identical to the production site (checked en and zh pages after normalizing Astro scope hashes)

Supersedes #150, #158, #164, #166, #168.

Testing

Tested locally; unit tests added for the callout rehype plugin.

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades Astro to v7 (plus Playwright/Vitest) and adapts the site build pipeline to remain stable under the new toolchain, including improved Markdown rendering behavior and cover generation reliability.

Changes:

  • Upgraded key dependencies (Astro 7, Vitest 4, Playwright 1.61.1) and removed the obsolete Playwright-core patch / Vite override.
  • Updated Astro Markdown config to keep the unified remark/rehype pipeline, added throttling for Mermaid rendering, and introduced GitHub-style callout rendering via a local rehype plugin.
  • Improved cover generation stability by sharing a Playwright browser context (cache reuse) and adding retry logic.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/rehype-callouts.mjs New rehype plugin to convert GitHub-style callout blockquotes into structured callout markup.
src/utils/locale.test.ts Updates a Vitest assertion style for compatibility with newer Vitest.
src/utils/cover.ts Switches cover rendering to use a shared BrowserContext and ensures pages are closed via finally.
src/pages/[slug].astro Adds styles for rendered callouts (light/dark).
src/pages/[lang]/[...slug]/cover.png.ts Adds retry logic and reuses a shared Playwright context during static path generation.
src/content.config.ts Updates Zod import to astro/zod per Astro 7 changes.
patches/playwright-core@1.48.2.patch Removes the no-longer-needed Playwright-core patch.
package.json Dependency upgrades and pnpm config updates (peer rules, removed patched deps).
astro.config.mjs Migrates Markdown processing to unified pipeline, adds Mermaid concurrency gating, enables compressHTML, and wires in callouts plugin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/rehype-callouts.mjs
Comment thread src/pages/[lang]/[...slug]/cover.png.ts Outdated
@xiaoyijun
xiaoyijun temporarily deployed to cloudflare-pages July 5, 2026 01:24 — with GitHub Actions Inactive
@xiaoyijun
xiaoyijun requested a review from Copilot July 5, 2026 01:24
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 5, 2026

Copy link
Copy Markdown

Deploying auth-wiki with  Cloudflare Pages  Cloudflare Pages

Latest commit: 07b8d09
Status: ✅  Deploy successful!
Preview URL: https://e61aeb7f.auth-wiki.pages.dev
Branch Preview URL: https://xiaoyijun-chore-upgrade-astr.auth-wiki.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/pages/[lang]/[...slug]/cover.png.ts
Comment thread src/utils/rehype-callouts.mjs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/utils/rehype-callouts.test.mjs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

@xiaoyijun
xiaoyijun merged commit f59ba0a into master Jul 6, 2026
4 checks passed
@xiaoyijun
xiaoyijun deleted the xiaoyijun-chore-upgrade-astro-7 branch July 6, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants