next.js
7e0fc3b2 - Turbopack: refactor segment config parsing (#83297)

Commit
118 days ago
Turbopack: refactor segment config parsing (#83297) Closes PACK-5382 Previously, Turbopack validated every single module for route segment config, leading to false positives (on non-page files) and worse build performance. There were also three separate implementations of this logic. Now, all of these cases are fatal errors, not just warnings. Examples for errors ``` ./bench/basic-app/app/export/inherit/page.tsx:1:28 Next.js can't recognize the exported `preferredRegion` field in route. It needs to be a static string or array of static strings. > 1 | export { default, runtime, preferredRegion } from '../basic/foo' | ^^^^^^^^^^^^^^^ The exported configuration object in a source file needs to have a very specific format from which some properties can be statically parsed at compiled-time. https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config ``` This error message is slightly different now: ``` browser log: ./test/integration/app-dir-export/app/another/[slug]/page.js:6:8 Next.js can't recognize the exported `generateStaticParams` field in route. App pages cannot use both "use client" and export function "generateStaticParams()". 4 | 5 | > 6 | export function generateStaticParams() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 7 | return [{ slug: 'first' }, { slug: 'second' }] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 8 | } | ^^ 9 | 10 | export default async function Page(props) { 11 | const params = await props.params The exported configuration object in a source file needs to have a very specific format from which some properties can be statically parsed at compiled-time. Import traces: Client Component Browser: ./test/integration/app-dir-export/app/another/[slug]/page.js [Client Component Browser] ./test/integration/app-dir-export/app/another/[slug]/page.js [Server Component] Client Component SSR: ./test/integration/app-dir-export/app/another/[slug]/page.js [Client Component SSR] ./test/integration/app-dir-export/app/another/[slug]/page.js [Server Component] https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config ```
Author
Parents
Loading