Merge claude/performance-2026-12-36a376: fewer queries per render, no 'use client' on the /client barrels, budgets, the doctor's performance and growth groups
Conflicts kept both sides: the doctor status (twoFactorConfirm with growth and media), its key test, e2e:built (the 2FA enrolment spec and the performance budgets), the reference index (regenerated). Reference skill copies synced (iapl-performance added, iapl-audit and iapl-reference updated). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -241,12 +241,18 @@ export function createContentHelpers({
|
||||
})
|
||||
|
||||
/** What does this URL point at? Routing only — no listing data. */
|
||||
const resolveRoute = cache(
|
||||
// React cache() compares arguments by identity: the page passes the params' array, metadata and JSON-LD pass
|
||||
// `segments ?? []` — a new array each time — so every caller missed and the homepage (no segments) was read in
|
||||
// full four times per render. The segments travel as a string key instead (measured: docs/performance.md).
|
||||
const resolveRoute = (locale: string, segments: string[] | undefined, page: number): Promise<null | ResolvedRoute> =>
|
||||
resolveRouteCached(locale, JSON.stringify(segments ?? []), page)
|
||||
const resolveRouteCached = cache(
|
||||
async (
|
||||
locale: string,
|
||||
segments: string[] | undefined,
|
||||
segmentsKey: string,
|
||||
page: number,
|
||||
): Promise<null | ResolvedRoute> => {
|
||||
const segments = JSON.parse(segmentsKey) as string[]
|
||||
const payload = await getCachedPayload()
|
||||
const settings = (await getSettings(locale)) as Record<string, unknown>
|
||||
return resolveRouteRaw({
|
||||
@@ -275,10 +281,17 @@ export function createContentHelpers({
|
||||
* }
|
||||
*/
|
||||
let pageMetadata: ReturnType<typeof createPageMetadata> | undefined
|
||||
const generatePageMetadata = async (
|
||||
// One build per request and URL: the page's generateMetadata, its render (alternate links) and getPageJsonLd all
|
||||
// ask for it — uncached that was three times the homepage and document reads in every locale (measured: 43 → fewer
|
||||
// MongoDB queries per render, docs/performance.md). The segments travel as a string so separate arrays still match.
|
||||
const pageMetadataCached = cache(async (locale: string, segmentsKey: null | string, page: number): Promise<PageMetadata> =>
|
||||
buildPageMetadata(locale, segmentsKey === null ? undefined : (JSON.parse(segmentsKey) as string[]), page))
|
||||
const generatePageMetadata = (locale: string, segments: string[] | undefined, page = 1): Promise<PageMetadata> =>
|
||||
pageMetadataCached(locale, segments === undefined ? null : JSON.stringify(segments), page)
|
||||
const buildPageMetadata = async (
|
||||
locale: string,
|
||||
segments: string[] | undefined,
|
||||
page = 1,
|
||||
page: number,
|
||||
): Promise<PageMetadata> => {
|
||||
if (!i18n) {
|
||||
throw new Error('[iapl] createContentHelpers: pass `i18n` to use generatePageMetadata.')
|
||||
|
||||
@@ -174,6 +174,11 @@ export type NotFoundPageOptions =
|
||||
* carries the whole 404 page in every locale.
|
||||
*/
|
||||
load: (locale: string) => Promise<ReactNode>
|
||||
/**
|
||||
* What the lazy 404 shows until its content arrives (default nothing). A block as tall as the site's 404
|
||||
* content keeps the footer from moving when the content comes in (no layout shift, docs/performance.md).
|
||||
*/
|
||||
placeholder?: ReactNode
|
||||
}
|
||||
| ({ load?: undefined } & NotFoundViewOptions)
|
||||
|
||||
@@ -230,7 +235,7 @@ export function createNotFoundPage(helpers: NotFoundHelpers, options: NotFoundPa
|
||||
const locales = await localesOf(helpers)
|
||||
const defaultLocale = helpers.i18n?.defaultLocale ?? locales[0]
|
||||
if (options.load) {
|
||||
return <NotFoundLoader defaultLocale={defaultLocale} load={options.load} locales={locales} />
|
||||
return <NotFoundLoader defaultLocale={defaultLocale} load={options.load} locales={locales} placeholder={options.placeholder} />
|
||||
}
|
||||
const eager = options
|
||||
const views = Object.fromEntries(
|
||||
|
||||
Reference in New Issue
Block a user