Skip to content

perf(ratewise): 幣別頁 SEO 文案移出首屏 app chunk(#647) - #677

Merged
s123104 merged 1 commit into
experiment/ratewise-product-2026h2from
fix/647-seo-metadata-split
Jul 7, 2026
Merged

perf(ratewise): 幣別頁 SEO 文案移出首屏 app chunk(#647)#677
s123104 merged 1 commit into
experiment/ratewise-product-2026h2from
fix/647-seo-metadata-split

Conversation

@s123104

@s123104 s123104 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closes #647

摘要

  • 首屏初始 JS(brotli)267.0KB → 251.1KB(−15.9KB);app chunk 106.2KB → 90.3KB、raw −59.2KB
  • 34 幣別頁 SEO 文案(currency-landing.ts 30KB+currency-personas.ts 53KB source)自首屏 app chunk 移出,改為隨幣別/內容頁 lazy chunk 載入。
  • 135KB 預算依實測重裁為 255KB ratchet(證據見下),恢復 opt-in bundle 預算測試可執行性;此值請 PM 覆核

根因與拆分策略

進入路徑:首屏靜態鏈四模組(routes.tsxSEOHelmet.tsxAppLayout.tsxHomepageSEOSection.tsx)從 barrel config/seo-metadata import 首頁需要的 HOMEPAGE_SEOSITE_SEO/builders;barrel 的 export * from './currency-landing' 使 currency-landing+personas 進入 entry 靜態圖,被 rolldown 併入 app chunk(以 personas 專屬字串在 chunk 內證實)。

採用「首屏輕量模組」策略:四個首屏模組改直接 import seo-metadata/core;barrel 留給 lazy 頁面與測試(維持單一 import 路徑不動 34 頁)。幣別文案自然落入 34 頁共享 lazy chunk(seo-metadata-*.js,59.7KB raw),manifest 證實僅被 lazy pages import。新增 seo-metadata-first-screen-imports.test.ts 守門防 barrel 回歸。

未採用方案:

  • manualChunks 隔離:仍在初始靜態圖內,預算與下載量皆無改善(下策)。
  • core.ts 再拆(FAQ/About/Guide 等頁文案 ~45KB source 仍留首屏):會破壞 seo-lastmod-policy.ts 的 regex 區段錨點與 generate-markdown-mirrors.mjs 的來源擷取,且檔案搬移使 sitemap lastmod 漂移(假新鮮度信號),違反 SSG 零變化紅線——列為後續 debt 候選,需連動 lastmod policy 一起設計。

Chunk 組成前後表(brotli bytes,manifest 靜態 import 圖)

chunk base after Δ
app 106,171 90,264 −15,907
vendor-react 52,322 52,322 0
vendor-motion 37,174 37,174 0
vendor-router-runtime 22,272 22,272 0
vendor-commons 20,248 20,248 0
vendor-i18n 16,075 16,075 0
vendor-icons 5,205 5,205 0
其他 7 個小 chunk 7,552 7,552 0
TOTAL 267,019 251,112 −15,907

新增 lazy chunk:seo-metadata-*.js(59,686 raw),僅由 34 幣別頁與內容頁(About/FAQ/Guide 等 lazy route)import。

預算重裁證據(135KB → 255KB,請 PM 覆核)

  • vendor 靜態基底即 ~155KB brotli(react 52.3+motion 37.2+router 22.3+commons 20.2+i18n 16.1+icons 5.2+其他 1.6)——即使 app chunk 歸零也無法達成 135KB。
  • 135KB 訂定後陸續併入 converter-v2、card-rate、theme studio 等功能,且 perf(ratewise): 行動端 Lighthouse mobile 效能 78→86,達成 #639 ≥85 門檻 #646 將 vendor-react 計入靜態圖(載入時序不變),基準已漂移至 267KB。
  • 建議值 255KB=本次實測 251.1KB+~1.5% 餘裕,作為防再漂移 ratchet;後續每階瘦身(見下)落地時應同步下修。
  • 後續增益候選(本票不做):vendor-motion 移出首屏靜態圖(−37KB)、core.ts 頁面文案連動 lastmod policy 拆分(估 −10~15KB)。

LH mobile 前後對照(vite preview @4173、3 次取中位數)

perf FCP LCP TBT CLS
base(9d2538e6,3 runs:87/92/87) 87 2558ms 3479ms 0ms 0.003
after(3 runs:82/89/89) 89 2416ms 3329ms 0ms 0.003

perf 不回退(#646 門檻 ≥85 之上);單機量測差異在雜訊範圍內,主增益體現在首屏下載字節而非本機 LH 分數。LH JSON:/tmp/lh-base-*.json/tmp/lh-after-*.json

紅線驗證

  • SSG 輸出零變化:固定 RATEWISE_BUILD_TIME A/B 建置,254 頁 index.html 在 asset hash 與 __VITE_REACT_SSG_HASH__ 正規化後 0 diff(head/JSON-LD/內文全部一致)。
  • Hydration 無新 mismatchfix(ratewise): 修復 persisted v2 冷載觸發 React #418 hydration mismatch #664 契約):Playwright 實測首頁與 /usd-twd/ 直開、首頁→幣別頁 SPA 導航,console error=0(僅 localhost preview 已知 manifest scope 警告 ×2)。
  • SEO 守門全綠seo-ssotseo-copy-guard 含於全套 vitest 9226 passed | 2 skipped
  • bundle 預算測試test:perf:bundle 2 passed(modulepreload 斷言+255KB 預算)。
  • typecheck/lint(變更檔)/pre-commit/pre-push 全過。

變更檔案

  • routes.tsxSEOHelmet.tsxAppLayout.tsxHomepageSEOSection.tsx:barrel → seo-metadata/core 直接 import
  • config/seo-metadata/index.ts:barrel 契約註解更新
  • performance/__tests__/seo-metadata-first-screen-imports.test.ts:新增首屏 import 守門
  • performance/__tests__/homepage-modulepreload.test.ts:預算 135KB → 255KB(附重裁理由註解)
  • changeset(patch)+ 002 記錄(reward +1 → 累計 +189)

Made with Cursor

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@s123104

s123104 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

PM 覆核:255KB ratchet 預算核可——135KB 在 vendor 靜態基底(~155KB)下不可達,實測+1.5% 棘輪+下修路徑(vendor-motion −37KB 候選)屬證據驅動的正確重裁。core.ts 細拆的 lastmod regex 錨點風險認可為後續 debt。待審查通過後收棒。

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

- 首屏靜態鏈四模組(routes/SEOHelmet/AppLayout/HomepageSEOSection)改直接
  import seo-metadata/core,barrel 留給 lazy 頁面維持單一 import 路徑
- currency-landing 與 personas 落入 34 幣別頁共享 lazy chunk(59.7KB raw),
  初始 JS brotli 267.0KB → 251.1KB、app chunk 106.2KB → 90.3KB(-15.9KB)
- 守門三層:靜態掃描禁首屏模組 runtime import barrel(含 @app/ratewise alias
  形態)、manifest 閉包禁 seo-metadata/currency-landing/personas chunk 進
  entry、brotli 預算 ratchet 兜底 inline 回歸形態
- bundle 預算依實測重裁 135KB → 255KB ratchet(vendor 靜態基底 147KB+,
  135KB 已不現實,PM 覆核佐證見 PR)
- SSG 254 頁輸出 hash 正規化後零 diff;LH mobile 前後中位數 87 vs 89 無回退

測試:pnpm --filter @app/ratewise exec vitest run 9226 綠;typecheck 過;
test:perf:bundle 過(含紅測驗證:barrel 回歸時靜態掃描與預算斷言雙雙轉紅);
SSG A/B 對照零 diff;LH mobile 3 次中位數對照

Co-authored-by: Cursor <cursoragent@cursor.com>
@s123104
s123104 force-pushed the fix/647-seo-metadata-split branch from c46d9f1 to 8ff09f3 Compare July 7, 2026 15:14
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@s123104
s123104 merged commit 1d373bb into experiment/ratewise-product-2026h2 Jul 7, 2026
11 checks passed
@s123104
s123104 deleted the fix/647-seo-metadata-split branch July 7, 2026 15: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