next.js
a93c03b1 - fix(build): prevent route handler manifests from inheriting unrelated client components (#88419)

Commit
50 days ago
fix(build): prevent route handler manifests from inheriting unrelated client components (#88419) ## Summary Fixes #88316 Route handlers (API routes) were generating bloated `client-reference-manifest.js` files containing unrelated client components from pages when using Webpack. This was caused by the manifest merging logic in `flight-manifest-plugin.ts` which inherited manifests from all parent path segments. ### Changes - Modified `flight-manifest-plugin.ts` to detect route handlers (`/route$` pattern) - Route handlers now only get their own group's manifest, skipping parent manifest inheritance - Pages continue to inherit manifests from parent layouts as before ### Why this works Route handlers: - Don't render React components - Return `Response` objects, not JSX - Don't need client component references from parent layouts/pages Turbopack already handles this correctly by doing targeted module graph traversal per entry. This fix aligns Webpack's behavior. ## Test Plan Added test suite `test/production/app-dir/route-handler-manifest-size/`: - Verifies pure route handlers don't include unrelated page client components - Verifies pages still include their client components - Verifies route handlers with direct client imports don't get page components - Tests pass for both Webpack and Turbopack
Author
Parents
Loading