Skip to content

refactor: simplify astro.config.mjs follow-up to Astro 7 upgrade#168

Merged
masuP9 merged 4 commits into
mainfrom
refactor/astro-settings
May 1, 2026
Merged

refactor: simplify astro.config.mjs follow-up to Astro 7 upgrade#168
masuP9 merged 4 commits into
mainfrom
refactor/astro-settings

Conversation

@masuP9
Copy link
Copy Markdown
Owner

@masuP9 masuP9 commented May 1, 2026

Summary

Follow-up to #167 (Astro 7.0.0-alpha.0 upgrade). Cleans up four items flagged during the post-upgrade review.

Plan worked out together with Codex.

Changes

  • .npmrc removed — replaced repo-wide legacy-peer-deps=true with a targeted package.json#overrides entry for @sveltejs/vite-plugin-svelte ^7.0.0. Restores npm peer-dep checking for unrelated packages.
  • siteConfig.local removed — only used to produce a localhost site URL for OGP metadata during dev; that responsibility moved to BaseLayout.astro via Astro.site. DeployTarget shrinks to 'github-pages' | 'cloudflare-pages'.
  • i18n.routing.prefixDefaultLocale: false removed — Astro's documented default is already false.
  • manualChunks function removed (with its parent vite.environments block) — was meant to split react/vue/svelte into vendor chunks, but vue was never actually matched (no vue-vendor.*.js in dist), so the splitting was half-broken. Vite 8 now produces per-runtime chunks (react.*.js, react-dom.*.js, client.svelte.*.js) automatically; total dist size stays at ~9.3MB.

Out of scope

  • vue({ devtools: false }) — needs dev-time HMR re-verification on Astro 7 + Vue 7 alpha. Will be handled in a separate PR.
  • Pre-existing hydration mismatch on /ja/... pages (PatternSearch.tsx calling getLocaleFromDocument() in a useState initializer) — unchanged here.

Test plan

  • npm ci works without .npmrc (verified locally)
  • npm ls @sveltejs/vite-plugin-svelte resolves to single v7.0.0
  • npm run build — 553 pages built (~47s)
  • npm run lint — 0 errors
  • npm run test:unit — all pass (75 + 6 files, 2768 tests)
  • Playwright preview walk: dialog/{vue,svelte}, checkbox/{react,astro}, tabs/svelte — 0 console errors
  • Cloudflare Pages preview build succeeds
  • GitHub Actions CI succeeds (build / lint / test-unit / test-e2e × 4 / validate-html)

🤖 Generated with Claude Code

masuP9 and others added 3 commits May 1, 2026 13:33
The repo-wide legacy-peer-deps=true switch was added during the Astro
7 alpha upgrade as a blanket workaround. The actual peer conflict is
narrow: @sveltejs/vite-plugin-svelte-inspector@5.0.2 still pins
vite-plugin-svelte ^6, which collides with the v7 we need for Vite 8.

Replace the global switch with a targeted overrides entry so npm's
peer-dep checking stays active for unrelated packages.

Verified: npm ci passes, npm ls @sveltejs/vite-plugin-svelte resolves
to a single v7.0.0, and build/test/preview all behave as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three follow-up cleanups identified after the Astro 7 upgrade landed:

- Drop the local entry from siteConfig and the matching DeployTarget
  variant. With this gone, deployTargetEnv falls back to github-pages
  directly. The only previous use of siteConfig.local was producing
  an http://localhost site URL during dev for OGP metadata, which is
  now handled by Astro.site in BaseLayout.
- Drop i18n.routing.prefixDefaultLocale: false. Astro's documented
  default is already false, so the explicit setting is redundant.
- Drop the manualChunks function and its parent vite.environments
  block. The function was meant to split react/vue/svelte into vendor
  chunks, but vue was never matched (no vue-vendor chunk in dist),
  so it only half-worked. Letting Vite 8's default chunking handle
  it produces clean per-runtime chunks (react.*.js, react-dom.*.js,
  client.svelte.*.js) and keeps total dist size flat at ~9.3MB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
siteConfig.local in astro.config.mjs no longer provides a localhost
site URL during dev, so import.meta.env.SITE is undefined there.
Insert Astro.site in the fallback chain so dev OGP metadata uses the
actual dev origin instead of jumping straight to the hardcoded prod
URL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 1, 2026

Deploying apg-patterns-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8a4b57b
Status: ✅  Deploy successful!
Preview URL: https://9dc5c04f.apg-patterns-examples.pages.dev
Branch Preview URL: https://refactor-astro-settings.apg-patterns-examples.pages.dev

View logs

Format check on CI flagged a long ternary that prettier wanted on a
single line. Picked up automatically by prettier --write.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@masuP9 masuP9 merged commit b61e48c into main May 1, 2026
17 checks passed
@masuP9 masuP9 deleted the refactor/astro-settings branch May 1, 2026 05:34
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