Skip to content

Commit

Permalink
exclude default routes from isPageStatic check
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Jan 25, 2024
1 parent 68dd495 commit 12c9040
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 12c9040

Please sign in to comment.