Skip to content

Commit

Permalink
exclude default routes from isPageStatic check (#61173)
Browse files Browse the repository at this point in the history
### What & Why
Using parallel routes with edge runtime would cause a build error when
using a default segment, because edge runtime has special handling to
[read the client reference
manifests](https://github.com/vercel/next.js/blob/12c90405681cf4120e3fa7f3e10d9466f598f9bb/packages/next/src/build/utils.ts#L1543-L1555)
for these when determining if a page is static.

### How
In a similar fashion to how we exclude static checks on reserved pages,
I added similar handling for app pages.

Fixes #60917
Closes NEXT-2241
  • Loading branch information
ztanner authored Jan 26, 2024
1 parent 6bc0779 commit d4b520a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import {
isReservedPage,
isAppBuiltinNotFoundPage,
serializePageInfos,
isReservedAppPage,
} from './utils'
import type { PageInfo, PageInfos, AppConfig } from './utils'
import { writeBuildId } from './write-build-id'
Expand Down Expand Up @@ -1794,7 +1795,10 @@ export default async function build(
pageType === 'app' &&
staticInfo?.rsc !== RSC_MODULE_TYPES.client

if (pageType === 'app' || !isReservedPage(page)) {
if (
(pageType === 'app' && !isReservedAppPage(page)) ||
(pageType === 'pages' && !isReservedPage(page))
) {
try {
let edgeInfo: any

Expand Down
5 changes: 5 additions & 0 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import { interopDefault } from '../lib/interop-default'
import type { PageExtensions } from './page-extensions-type'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'
import { isDefaultRoute } from '../lib/is-default-route'

export type ROUTER_TYPE = 'pages' | 'app'

Expand Down Expand Up @@ -2123,6 +2124,10 @@ export function isReservedPage(page: string) {
return RESERVED_PAGE.test(page)
}

export function isReservedAppPage(page: string) {
return isDefaultRoute(page)
}

export function isAppBuiltinNotFoundPage(page: string) {
return /next[\\/]dist[\\/]client[\\/]components[\\/]not-found-error/.test(
page
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return 'default'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return '@slot'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const runtime = 'edge'

export default function Layout({
children,
slot,
}: {
children: React.ReactNode
slot: React.ReactNode
}) {
return (
<div>
<h1>Layout</h1>
{children}
{slot}
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <div>Hello World</div>
}

0 comments on commit d4b520a

Please sign in to comment.