mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## Summary Reworks Turbopack deferred entries in production build so deferred routes are processed last in the same project lifecycle, with `onBeforeDeferredEntries` executed between the non-deferred and deferred phases. ## What changed - Moved deferred build phasing into Rust in `project_write_all_entrypoints_to_disk`: - non-deferred phase - `onBeforeDeferredEntries` - deferred phase - Kept callback invocation on the Rust side via the existing node-worker callback plumbing. - Narrowed invalidation after `onBeforeDeferredEntries` to deferred app source subtrees instead of invalidating the whole project filesystem cache. - Added `DiskFileSystem::invalidate_path_and_children_with_reason(...)` in `turbo-tasks-fs`. - Derived deferred invalidation dirs from deferred routes’ `original_name` values. - Retained a full-invalidation fallback only when app-dir path resolution is unavailable. - Deferred route selection still includes both app pages and app route handlers. ## Validation - `cargo check -p next-napi-bindings -p turbo-tasks-fs` - `pnpm test-start-turbo test/e2e/deferred-entries/deferred-entries.test.ts` (21/21 passing) - Validated against [workflows repo](https://github.com/vercel/workflow/pull/1058) and v0
13 lines
364 B
TypeScript
13 lines
364 B
TypeScript
import type { NextRequest } from 'next/server'
|
|
import { NextResponse } from 'next/server'
|
|
|
|
export function middleware(request: NextRequest) {
|
|
const response = NextResponse.next()
|
|
response.headers.set('x-deferred-entries-middleware', 'true')
|
|
response.headers.set(
|
|
'x-deferred-entries-middleware-path',
|
|
request.nextUrl.pathname
|
|
)
|
|
return response
|
|
}
|