Skip to content

Commit

Permalink
pageType & pageBundleType
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Mar 6, 2023
1 parent 7f9926b commit fa75351
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/next/src/server/dev/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ function convertDynamicParamTypeToSyntax(

export function getEntryKey(
compilerType: CompilerNameValues,
pageType: 'app' | 'pages' | 'root',
pageBundleType: 'app' | 'pages' | 'root',
page: string
) {
return `${compilerType}@${pageType}@${page}`
return `${compilerType}@${pageBundleType}@${page}`
}

function getPageType(pageBundlePath: string) {
function getPageBundleType(pageBundlePath: string) {
return pageBundlePath.startsWith('pages/')
? 'pages'
: pageBundlePath.startsWith('app/')
Expand Down Expand Up @@ -503,16 +503,18 @@ export function onDemandEntryHandler({
const pagePaths: string[] = []
for (const entrypoint of entrypoints.values()) {
const page = getRouteFromEntrypoint(entrypoint.name!, root)
const pageType = getPageType(entrypoint.name!)

if (page) {
pagePaths.push(getEntryKey(type, pageType, page))
const pageBundleType = entrypoint.name?.startsWith('app/')
? 'app'
: 'pages'
pagePaths.push(getEntryKey(type, pageBundleType, page))
} else if (
(root && entrypoint.name === 'root') ||
isMiddlewareFilename(entrypoint.name) ||
isInstrumentationHookFilename(entrypoint.name)
) {
pagePaths.push(getEntryKey(type, pageType, `/${entrypoint.name}`))
pagePaths.push(getEntryKey(type, 'root', `/${entrypoint.name}`))
}
}
return pagePaths
Expand Down Expand Up @@ -697,6 +699,7 @@ export function onDemandEntryHandler({
!!appDir && pagePathData.absolutePagePath.startsWith(appDir)

const pageType = isInsideAppDir ? 'app' : 'pages'
const pageBundleType = getPageBundleType(pagePathData.bundlePath)
const addEntry = (
compilerType: CompilerNameValues
): {
Expand Down Expand Up @@ -764,7 +767,7 @@ export function onDemandEntryHandler({
await runDependingOnPageType({
page: pagePathData.page,
pageRuntime: staticInfo.runtime,
pageType,
pageType: pageBundleType,
onClient: () => {
// Skip adding the client entry for app / Server Components.
if (isServerComponent || isInsideAppDir) {
Expand Down

0 comments on commit fa75351

Please sign in to comment.