Skip to content

Commit

Permalink
chore: turbopack metadata routes normalizing (#67159)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Jun 24, 2024
1 parent f03fed0 commit d8a60e3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/next/src/lib/metadata/is-metadata-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export function isStaticMetadataRouteFile(appDirRelativePath: string) {
return isMetadataRouteFile(appDirRelativePath, [], true)
}

// @deprecated
export function isStaticMetadataRoute(page: string) {
return (
page === '/robots' ||
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/dev/hot-reloader-turbopack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import {
type TopLevelIssuesMap,
isWellKnownError,
printNonFatalIssue,
normalizeAppMetadataRoutePage,
normalizedPageToTurbopackStructureRoute,
} from './turbopack-utils'
import {
propagateServerField,
Expand Down Expand Up @@ -808,7 +808,7 @@ export async function createHotReloaderTurbopack(
await currentEntriesHandling

const isInsideAppDir = routeDef.bundlePath.startsWith('app/')
const normalizedAppPage = normalizeAppMetadataRoutePage(
const normalizedAppPage = normalizedPageToTurbopackStructureRoute(
page,
extname(routeDef.filename)
)
Expand Down
10 changes: 6 additions & 4 deletions packages/next/src/server/dev/turbopack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,7 @@ export async function handleRouteType({

const type = writtenEndpoint?.type

await manifestLoader.loadAppPathsManifest(
normalizeAppMetadataRoutePage(page, false)
)
await manifestLoader.loadAppPathsManifest(page)

if (type === 'edge') {
await manifestLoader.loadMiddlewareManifest(page, 'app')
Expand Down Expand Up @@ -1000,7 +998,11 @@ export async function handlePagesErrorRoute({
})
}

export function normalizeAppMetadataRoutePage(
// Since turbopack will create app pages/route entries based on the structure,
// which means the entry keys are based on file names.
// But for special metadata conventions we'll change the page/pathname to a different path.
// So we need this helper to map the new path back to original turbopack entry key.
export function normalizedPageToTurbopackStructureRoute(
route: string,
ext: string | false
): string {
Expand Down
11 changes: 0 additions & 11 deletions packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,6 @@ async function startWatcher(opts: SetupOpts) {
pageName,
!!(staticInfo.generateSitemaps || staticInfo.generateImageMetadata)
)

// pageName = pageName.slice(0, -'/route'.length)
// if (pageName.endsWith('/sitemap')) {

// if (staticInfo.generateSitemaps) {
// pageName = `${pageName}/[__metadata_id__]`
// } else {
// pageName = `${pageName}.xml`
// }
// }
// pageName = `${pageName}/route`
}

if (
Expand Down

0 comments on commit d8a60e3

Please sign in to comment.