diff --git a/packages/next/src/server/dev/turbopack/manifest-loader.ts b/packages/next/src/server/dev/turbopack/manifest-loader.ts index 29f294b5a7431..64af684d85ed5 100644 --- a/packages/next/src/server/dev/turbopack/manifest-loader.ts +++ b/packages/next/src/server/dev/turbopack/manifest-loader.ts @@ -40,6 +40,7 @@ import type { Entrypoints } from './types' import getAssetPathFromRoute from '../../../shared/lib/router/utils/get-asset-path-from-route' import { getEntryKey, type EntryKey } from './entry-key' import type { CustomRoutes } from '../../../lib/load-custom-routes' +import { getSortedRoutes } from '../../../shared/lib/router/utils' interface InstrumentationDefinition { files: string[] @@ -348,15 +349,17 @@ export class TurbopackManifestLoader { if (entrypoints.global.error) { pagesKeys.push('/_error') } + + const sortedPageKeys = getSortedRoutes(pagesKeys) const content: ClientBuildManifest = { __rewrites: normalizeRewritesForBuildManifest(rewrites) as any, ...Object.fromEntries( - pagesKeys.map((pathname) => [ + sortedPageKeys.map((pathname) => [ pathname, [`static/chunks/pages${pathname === '/' ? '/index' : pathname}.js`], ]) ), - sortedPages: pagesKeys, + sortedPages: sortedPageKeys, } const buildManifestJs = `self.__BUILD_MANIFEST = ${JSON.stringify( content diff --git a/test/turbopack-build-tests-manifest.json b/test/turbopack-build-tests-manifest.json index 02e5e973259ee..3658459b118bf 100644 --- a/test/turbopack-build-tests-manifest.json +++ b/test/turbopack-build-tests-manifest.json @@ -13547,15 +13547,11 @@ "Prefetching Links in viewport production mode should handle timed out prefetch correctly", "Prefetching Links in viewport production mode should not have unhandledRejection when failing to prefetch on link", "Prefetching Links in viewport production mode should not prefetch when prefetch is explicitly set to false", - "Prefetching Links in viewport production mode should not prefetch with bot UA" - ], - "failed": [ + "Prefetching Links in viewport production mode should not prefetch with bot UA", "Prefetching Links in viewport production mode should de-dupe inflight SSG requests", "Prefetching Links in viewport production mode should inject a