diff --git a/next.config.ts b/next.config.ts index 3f721aef..6c83c517 100644 --- a/next.config.ts +++ b/next.config.ts @@ -158,7 +158,15 @@ const nextConfig: NextConfig = { }, experimental: { - optimizePackageImports: ["lucide-react", "date-fns"], + // Barrel-heavy packages: without this every import pulls the whole + // module graph into the chunk that first touches it. + optimizePackageImports: [ + "lucide-react", + "motion", + "@dnd-kit/core", + "@dnd-kit/sortable", + "@tanstack/react-virtual", + ], useTypeScriptCli: true, hideLogsAfterAbort: true, }, diff --git a/scripts/performance-budgets.json b/scripts/performance-budgets.json index 96e95ebe..1d788bf6 100644 --- a/scripts/performance-budgets.json +++ b/scripts/performance-budgets.json @@ -2,6 +2,11 @@ "schemaVersion": 1, "mode": "enforce", "routes": [ + { + "route": "/", + "maxInitialRawBytes": 716800, + "maxInitialGzipBytes": 225280 + }, { "route": "/me", "maxInitialRawBytes": 716800, diff --git a/src/app/(site)/page.tsx b/src/app/(site)/page.tsx index 5b5bcc0f..609e614e 100644 --- a/src/app/(site)/page.tsx +++ b/src/app/(site)/page.tsx @@ -23,6 +23,7 @@ import { cached } from "@/lib/cache"; import { CameraWeb, db, User } from "@/lib/db"; import { formatDate } from "@/lib/format-date"; import { resolveHotelName } from "@/lib/hotel-name"; +import { withPublicPagePerformance } from "@/lib/public-page-performance"; import { captchaConfig } from "@/lib/services/captcha"; import { getNewsList } from "@/lib/services/news-list"; import { loadProfilePrivacyMap } from "@/lib/services/profile-privacy"; @@ -238,7 +239,7 @@ async function getHotelData() { }; } -export default async function Home() { +async function Home() { const session = await auth(); if (session?.user?.id) redirect("/me"); @@ -1148,3 +1149,5 @@ export default async function Home() { ); } + +export default withPublicPagePerformance("/", Home); diff --git a/src/lib/public-page-performance.ts b/src/lib/public-page-performance.ts index b3022451..5af96819 100644 --- a/src/lib/public-page-performance.ts +++ b/src/lib/public-page-performance.ts @@ -4,6 +4,7 @@ import { collectPerformance } from "./performance-diagnostics"; import { type PerformanceSample, recordPerformance } from "./performance-store"; type PublicRoute = + | "/" | "/me" | "/news" | "/news/[slug]"