Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: turbopack metadata routes normalizing #67159

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading