Repository navigation
fix(ssr): the server bundled @scaffald/ui from dist, the client from src — detail pages hydrated against the wrong icons - #790
Merged
Conversation
…web forks match the client Fixes #786. Co-Authored-By: Claude Fable 5.1 <[email protected]>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #786. Two mismatches, one root cause each.
1. The server bundled
@scaffald/uifromdist/; the client bundled it fromsrc/. The package'sexportsoffersource(TypeScript) andimport(a tsup bundle). Every client and native bundle pickssourcethroughmetro.config.js's condition list, so Metro applies the platform forks insrc/—BreadcrumbIcons.web.tsx, the Checkbox/Radio/Stepper/Accordion icon.webfiles,useSidebarState.web.ts. The web server bundle does not:@expo/cli'swithMetroMultiPlatformreplaces the condition list with['node']for the server environment, which leaves onlyimport, so the server rendered fromdist/— a bundle with no platform forks, i.e. the native files. The breadcrumb's Home icon was thereforelucide-react-nativeon the server andlucide-reacton the client; they draw different SVG (two paths vs a path and a polyline), so React threw the server tree away on every load of the two pages that show a breadcrumb./jobshides its breadcrumb, which is why it was clean.The fix pins
@scaffald/ui(and its subpaths) to thesourcetarget in the resolver, before the condition list gets a say, so every bundle uses identical files. Verified in the exported server bundle:packages/ui/distreferences went from 3 to 0 andpackages/ui/srcfrom 0 to 488, matching the client.2.
/jobs/<slug>built its JSON-LDurlfromwindow.location.getCanonicalUrl()returnsundefinedon the server (no window) and the origin on the client, so the<script type="application/ld+json">text had aurlfield on the client only. Now built fromSITE_ORIGIN, asgenerateMetadataand the profile route already do. The helper keeps its one legitimate caller (a share link built on press) and now says on the tin that it is client-only.How it was found
React's diff only prints in a development build, and the dev server was no use: it answers SSR requests for these routes with a "Bundling…" placeholder, so the dev server never showed the failure.
expo export --dev --no-minifygives a real server render with React's dev messages, and its diff named the<Home>icon'sclassNameand path data outright. The trace of that is in #786.Also in this PR
scripts/audit/hydration-pages.mjs: loads each public page three times at phone (iPhone UA), tablet (iPad UA) and desktop, and counts hydration failures — including the minified codes#418/#423/#425. A production build says onlyMinified React error #418, and the word-based filter insmoke-hydration.mjsread that as clean; that matcher now catches the codes too. Run it against anexpo serveof an export, not only the dev server — the two resolve modules differently, and this bug only existed in the export.Verification
expo export, minified) served withexpo serve:hydration-pages.mjsreports 15/15 clean (/,/jobs,/jobs/<slug>,/users/<slug>,/terms× phone/tablet/desktop, three loads each). Onmain's build the two detail pages failed every load at every width.--dev --no-minifyexport, where React's message would carry the diff if any remained.scaffald-apptypecheck green, biome clean,pnpm prepushgreen. The Metro resolver change is exercised by every bundle the export produces.Not changed
The nine
.web.*forks inpackages/ui/srcstay as they are — with the server now onsrc/, they resolve the same way everywhere. Whether the package should keep shipping a fork-lessdist/at all is aScaffald/uiquestion; nothing in this repo consumes it any more.🤖 Generated with Claude Code