Skip to content

fix(dev): split DemoSection.astro per-framework to avoid plugin-react v6 $RefreshSig$ regression#169

Merged
masuP9 merged 1 commit into
mainfrom
verify/option1-impl
May 11, 2026
Merged

fix(dev): split DemoSection.astro per-framework to avoid plugin-react v6 $RefreshSig$ regression#169
masuP9 merged 1 commit into
mainfrom
verify/option1-impl

Conversation

@masuP9
Copy link
Copy Markdown
Owner

@masuP9 masuP9 commented May 11, 2026

Summary

  • Astro 7 alpha への upgrade (165e32b) で @vitejs/plugin-react が v5 (Babel) → v6 (Oxc) になった結果、Vue SFC <script setup lang=\"ts\"> の仮想 ID にも React Fast Refresh の \$RefreshSig\$ が誤注入され、dev 限定で 33/128 pattern×framework ページが HTTP 500 を返していた regression を修正
  • 各パターンの DemoSection.astro を framework 別 4 ファイル (DemoSection.{react,vue,svelte,web-component}.astro) に分割。pages 側 dispatcher は新形式を優先し、未移行 pattern は legacy ファイルにフォールバック
  • 影響を受けていた 9 pattern (alert / checkbox / combobox / disclosure / menu-button / menubar / slider / slider-multithumb / toolbar) を移行、残り 23 pattern は legacy のまま (元から問題なし)

なぜ CI が見逃したか

playwright.config.ts:43 のコメント通り CI は npm run preview で動くため Fast Refresh は走らない。npm run test:e2e (local) で初めて再現する症状で、165e32b 以降 local E2E を回した形跡がなく見逃されていた。

検証

項目 結果
npm run dev 全 128 ページ probe 119/128 が 200 (修正前は 95/128)
npm run lint 0 errors
npm run build success (553 pages)
Astro 6 + Vite 7 + plugin-react v5 (fadd058) での比較検証 全 128 ページが 200、\$RefreshSig\$ 出現 0 件 → regression の起点を確定

残課題

このパッチで 9 ページ (移行 pattern の Vue ページ全て) は依然 500。Vue ページ自身が Vue SFC を評価する必要があり、構造変更では救えない。別 issue で追跡 (本 PR にリンク予定)。

Test plan

  • npm run dev/patterns/alert/react/ を含む移行 pattern の React/Svelte/Astro ページが 200 を返す
  • /patterns/button/react/ 等、未移行 pattern が legacy fallback で動く
  • npm run build && npm run preview が成功
  • CI green (preview ベースなので元々通っていた)

🤖 Generated with Claude Code

… v6 $RefreshSig$ regression

Astro 7 alpha upgrade (165e32b) bumped @vitejs/plugin-react from v5
(Babel-based) to v6 (Oxc-based). v6's default include regex
`/\.[tj]sx?$/` matches Vue SFC `<script setup lang="ts">` virtual ids
(e.g. `Foo.vue?vue&type=script&setup=true&lang.ts`) once
`makeIdFiltersToMatchWithQuery` rewrites the trailing `$` to allow
queries. Vite then injects React Fast Refresh signature calls
(`$RefreshSig$`) into the transformed Vue script blocks. The SSR
module-runner evaluates those blocks during dev, hits an undefined
`$RefreshSig$`, and returns HTTP 500.

CI did not detect this because `playwright.config.ts:43` runs E2E against
`npm run preview` where Fast Refresh is disabled; only `npm run test:e2e`
on a developer machine hits the dev pipeline.

Structural workaround:
- Split `DemoSection.astro` into per-framework files
  `DemoSection.{react,vue,svelte,web-component}.astro` so each page
  evaluates only the framework it actually renders.
- Update `pages/{,ja/}patterns/[pattern]/[framework]/index.astro` to
  prefer the new framework-specific file via four lazy
  `import.meta.glob` calls, falling back to the legacy unified
  `DemoSection.astro` for unaffected patterns.
- Migrate the 9 patterns that triggered the regression: alert,
  checkbox, combobox, disclosure, menu-button, menubar, slider,
  slider-multithumb, toolbar.
- Leave the other 23 patterns on the legacy file; they work fine via
  the dispatcher's fallback path.

After this change:
- 119/128 pattern×framework pages return 200 in dev (up from 95/128).
- The remaining 9 BAD pages are the Vue page of each migrated pattern.
  Their Vue runtime must evaluate the broken Vue SFC, so structural
  change cannot help. Tracked in a separate issue for upstream fix.

Verified:
- `npm run lint`: 0 errors.
- `npm run build`: success (553 pages).
- Dev probe across all 128 pattern×framework combinations.

CLAUDE.md updated to describe the transitional state where some patterns
use the framework-specific files and others remain on legacy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@masuP9
Copy link
Copy Markdown
Owner Author

masuP9 commented May 11, 2026

Tracking remaining 9 Vue pages bug in #170 (upstream regression待ち)

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying apg-patterns-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 112851a
Status: ✅  Deploy successful!
Preview URL: https://7c03f539.apg-patterns-examples.pages.dev
Branch Preview URL: https://verify-option1-impl.apg-patterns-examples.pages.dev

View logs

@masuP9 masuP9 merged commit d697e9f into main May 11, 2026
17 checks passed
@masuP9 masuP9 deleted the verify/option1-impl branch May 11, 2026 09:33
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