perf(i18n): stop serializing the full catalogue on public pages
The root layout fed the entire ~254 KB message catalogue to NextIntlClientProvider, which serializes it into the RSC payload of every page. A public page only reads ~59 KB of it; the ~195 KB difference is staff tool copy that only /admin, /admin-next and /mod ever render. The root provider now installs the reduced catalogue and each staff route group re-installs the full one, since a nested NextIntlClientProvider replaces the parent message set rather than merging into it. pages.admin.actions stays public because the shared useServerAction hook runs on public pages too. Measured: 253 KB -> 59 KB of messages per public page (raw JSON). Guard tests cover all three halves: the root keeps using the reduced catalogue, every staff layout installs its own full provider, and no public tree reads a staff-only namespace.
This commit is contained in:
1 parent
d28dde459a
commit
bb3799f705
7 files changed
+136
-18
No files matched your search
@@ -41,6 +41,8 @@ const routeMocks = vi.hoisted(() => {
|
||||
}
|
||||
return translate;
|
||||
}),
|
||||
getLocale: vi.fn(async () => "en"),
|
||||
getMessages: vi.fn(async () => ({})),
|
||||
notFound: vi.fn((): never => {
|
||||
throw new Error("NEXT_NOT_FOUND");
|
||||
}),
|
||||
@@ -58,6 +60,8 @@ vi.mock("next/navigation", () => ({
|
||||
}));
|
||||
vi.mock("next-intl/server", () => ({
|
||||
getTranslations: routeMocks.getTranslations,
|
||||
getLocale: routeMocks.getLocale,
|
||||
getMessages: routeMocks.getMessages,
|
||||
}));
|
||||
vi.mock("@/features/housekeeping/foundation/server-capability-context", () => ({
|
||||
getHousekeepingCapabilityContext: routeMocks.getHousekeepingCapabilityContext,
|
||||
|
||||
Reference in new issue
Block a user