Repository navigation
fix(pages): collect CSS from dynamicImports to prevent FOUC - #26
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09cbd85c0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
09cbd85 to
f07a61a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f07a61a88d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f07a61a to
d93fb73
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d93fb738c5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
The previous collectDynamicCss walked all dynamicImports from the pages client entry, which included every page and layout in the app. This defeated CSS code splitting — rendering /about would emit stylesheet links for /users, /dashboard, and every other page. Replace with collectRouteCss: a two-phase walk that collects CSS from (1) the entry's static imports (shared/global CSS) and (2) only the active page's chunk and its layout chain's chunks. A build-time PAGE_CSS_KEYS mapping provides the manifest keys for each componentId. getPagesAssetTags and getIslandsAssetTags now accept componentId so they can look up the correct keys. The protocol layer threads componentId through the getAssetTags callback in both handlePageGet and handlePageMutation. pagesDirRelative is normalized to POSIX separators so manifest key lookups work correctly on Windows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d93fb73 to
5bf78ec
Compare
) * ci: add schema-compat job to catch backward-incompatible migrations During deploy, drizzle-kit migrate runs before the new API worker goes live. The schema-compat CI job catches breaking migrations by applying the PR's migrations to real PostgreSQL 17, then running the prod branch's tests against the new schema. Test helpers now fork on DATABASE_URL: real pg.Pool when set, PGlite when unset (existing behavior preserved). Integration tests run sequentially (fileParallelism: false) when using real PG to avoid data races on the shared database. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: clean untracked PR files after prod checkout git clean -fd after the phase 2 checkout removes files that exist in the PR branch but not in prod, preventing spurious test failures from orphaned test files picked up by vitest globs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>


collectPagesManifestFiles only traversed chunk.imports, missing CSS
from dynamically imported modules like layouts. Since layouts are
listed under dynamicImports in the Vite manifest, their CSS was never
injected as in , causing a flash of
unstyled content on every page load.
Now traverses both imports and dynamicImports so layout CSS is
included in the initial HTML response.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Note
Medium Risk
Medium risk because it changes server-rendered asset tag generation and response short-circuiting for pages, which can affect styling and HTTP behavior across all routes if manifest keys or component IDs are wrong.
Overview
Fixes missing/incorrect CSS injection for Pages SSR by changing asset-tag generation to be route-aware: the compiler now precomputes
PAGE_CSS_KEYS(page + resolved layout chain) and uses a newcollectRouteCss()helper to pull CSS for the activecomponentIdfrom the Vite manifest.This threads
componentIdthroughgetPagesAssetTags/getIslandsAssetTagsand their callers, addspagesDirRelativeto ensure manifest key lookup matches Vite’s paths, and updates GET handling to return early for anyResponsewithstatus >= 300(not just redirects).Written by Cursor Bugbot for commit 5bf78ec. This will update automatically on new commits. Configure here.