Skip to content

Commit

Permalink
Re-add internal env for providing page paths (#70235)
Browse files Browse the repository at this point in the history
This re-adds internal env variables to allow providing page paths
directly for debugging purposes. This is NOT a public API and should not
be leveraged outside of internal Next.js debugging.

x-ref: #67134
x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1726519130567199)
  • Loading branch information
ijjk committed Sep 18, 2024
1 parent cc8b809 commit f3e3bcb
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,13 @@ export default async function build(
appDir
)

let pagesPaths =
!appDirOnly && pagesDir
const providedPagePaths: string[] = JSON.parse(
process.env.NEXT_PRIVATE_PAGE_PATHS || '[]'
)

let pagesPaths = Boolean(process.env.NEXT_PRIVATE_PAGE_PATHS)
? providedPagePaths
: !appDirOnly && pagesDir
? await nextBuildSpan.traceChild('collect-pages').traceAsyncFn(() =>
recursiveReadDir(pagesDir, {
pathnameFilter: validFileMatcher.isPageFile,
Expand Down Expand Up @@ -1008,18 +1013,24 @@ export default async function build(
}

if (appDir) {
let appPaths = await nextBuildSpan
.traceChild('collect-app-paths')
.traceAsyncFn(() =>
recursiveReadDir(appDir, {
pathnameFilter: (absolutePath) =>
validFileMatcher.isAppRouterPage(absolutePath) ||
// For now we only collect the root /not-found page in the app
// directory as the 404 fallback
validFileMatcher.isRootNotFound(absolutePath),
ignorePartFilter: (part) => part.startsWith('_'),
})
)
const providedAppPaths: string[] = JSON.parse(
process.env.NEXT_PRIVATE_APP_PATHS || '[]'
)

let appPaths = Boolean(process.env.NEXT_PRIVATE_APP_PATHS)
? providedAppPaths
: await nextBuildSpan
.traceChild('collect-app-paths')
.traceAsyncFn(() =>
recursiveReadDir(appDir, {
pathnameFilter: (absolutePath) =>
validFileMatcher.isAppRouterPage(absolutePath) ||
// For now we only collect the root /not-found page in the app
// directory as the 404 fallback
validFileMatcher.isRootNotFound(absolutePath),
ignorePartFilter: (part) => part.startsWith('_'),
})
)

if (appPaths && isFullFlyingShuttle) {
await nextBuildSpan
Expand Down

0 comments on commit f3e3bcb

Please sign in to comment.