chore(studio): shim next/server in Vite compat layer

Two App Router routes (incident-banner, incident-status) and a few
type-only uses elsewhere import from 'next/server'. The Vite
nextCompat guard was 500ing on the build. Shim exposes
NextResponse.json (the only value surface used) and a type alias
NextRequest = Request.
This commit is contained in:
Alaister Young committed 2026-04-21 19:14:15 +08:00
1 parent c58d02e29b
commit 2428cfd3b5
2 files changed
+14

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
// Vite-side compat for `next/server`. Workspace source uses `NextResponse`
// (only `.json()`) in two App Router routes and `NextRequest` as a type-only
// import elsewhere. Extend this file if more surface is needed.
export const NextResponse = {
json: (data: unknown, init?: ResponseInit) => Response.json(data, init),
}
// NextRequest extends Request with Next-specific fields (nextUrl, cookies,
// ip, geo). None of our workspace source reads those fields at runtime —
// the only imports are type-only. Aliasing to Request keeps TypeScript
// happy without pulling in Next internals.
export type NextRequest = Request
+1
View File
@@ -23,6 +23,7 @@ const nextShims: Record<string, string> = {
'next/navigation': path.join(compatRoot, 'navigation.ts'),
'next/router': path.join(compatRoot, 'router.ts'),
'next/script': path.join(compatRoot, 'script.tsx'),
'next/server': path.join(compatRoot, 'server.ts'),
}
// Combined compat + migration guard: