Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const nextConfig: NextConfig = {
reactStrictMode: true,
reactCompiler: true,
serverExternalPackages: ["libnpmdiff", "npm-package-arg", "pacote"],
// Enable Cache Components (moved to root level in 16.1.1)
cacheComponents: true,
};

export default nextConfig;
4 changes: 4 additions & 0 deletions src/app/[...parts]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type Metadata } from "next";
import { redirect } from "next/navigation";
import { connection } from "next/server";
import { type JSX } from "react";
import { type ViewType } from "react-diff-view";
import { createSimplePackageSpec } from "^/lib/createSimplePackageSpec";
Expand Down Expand Up @@ -39,6 +40,9 @@ const DiffPage = async ({
params,
searchParams,
}: DiffPageProps): Promise<JSX.Element> => {
// Cache Components: Mark this route as dynamic since it uses params/searchParams
await connection();

const { parts } = await params;
const { diffFiles, ...optionsQuery } = await searchParams;

Expand Down
4 changes: 2 additions & 2 deletions src/app/about/api/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const metadata = {
description: "API documentation for npm-diff.app",
} satisfies Metadata;

// We need nodejs since we use Npm libs https://beta.nextjs.org/docs/api-reference/segment-config#runtime
export const runtime = "nodejs";
// MIGRATED from: export const runtime = "nodejs"
// → Removed (nodejs is the default, no need to specify with Cache Components)
const AboutApiPage = async () => {
const specsOrVersions = splitParts(EXAMPLE_QUERY);
const { canonicalSpecs: specs } = await destination(specsOrVersions);
Expand Down
5 changes: 4 additions & 1 deletion src/app/api/-/versions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { NextResponse } from "next/server";
import getVersionData from "^/lib/api/npm/getVersionData";
import { type Version, VERSIONS_PARAMETER_PACKAGE } from "./types";

export const runtime = "edge";
// MIGRATED from: export const runtime = "edge"
// → Route Segment Config is incompatible with Cache Components
// → Edge runtime support requires different approach with Cache Components
// → Switched to default nodejs runtime for Cache Components compatibility

export async function GET(request: Request) {
const start = Date.now();
Expand Down
32 changes: 19 additions & 13 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Metadata, type Viewport } from "next";
import { type ReactNode } from "react";
import { type ReactNode, Suspense } from "react";
import { ThemeProvider } from "^/components/ThemeProvider";
import Stack from "^/components/ui/Stack";
import { TooltipProvider } from "^/components/ui/Tooltip";
Expand Down Expand Up @@ -31,18 +31,24 @@ export default function RootLayout({ children }: { children: ReactNode }) {
<html lang="en" suppressHydrationWarning>
<head />
<body className="min-h-screen-s bg-background">
<ThemeProvider>
<TooltipProvider>
<Stack
justify="between"
className="min-h-screen-s relative overflow-auto px-4"
>
<Header className="bg-background" />
{children}
<Footer className="bg-background" />
</Stack>
</TooltipProvider>
</ThemeProvider>
{/* Cache Components: Wrap in Suspense to prevent blocking route errors */}
<Suspense fallback={<div className="min-h-screen-s" />}>
<ThemeProvider>
<TooltipProvider>
<Stack
justify="between"
className="min-h-screen-s relative overflow-auto px-4"
>
{/* Cache Components: Wrap Header in Suspense since it uses usePathname() for navigation state */}
<Suspense fallback={<div className="h-24" />}>
<Header className="bg-background" />
</Suspense>
{children}
<Footer className="bg-background" />
</Stack>
</TooltipProvider>
</ThemeProvider>
</Suspense>
</body>
</html>
);
Expand Down