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

Turbopack build: Ensure build manifest routes are sorted #67583

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
7 changes: 5 additions & 2 deletions packages/next/src/server/dev/turbopack/manifest-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <script> tag when onMouseEnter (even with invalid ref)",
"Prefetching Links in viewport production mode should inject script on hover with prefetching disabled",
"Prefetching Links in viewport production mode should inject script on hover with prefetching disabled and fetch data",
"Prefetching Links in viewport production mode should not duplicate prefetches",
"Prefetching Links in viewport production mode should not prefetch already loaded scripts",
"Prefetching Links in viewport production mode should not re-prefetch for an already prefetched page",
"Prefetching Links in viewport production mode should prefetch data files",
"Prefetching Links in viewport production mode should prefetch data files when mismatched",
Expand All @@ -13567,6 +13563,10 @@
"Prefetching Links in viewport production mode should prefetch with link in viewport when href changes",
"Prefetching Links in viewport production mode should prefetch with non-bot UA"
],
"failed": [
"Prefetching Links in viewport production mode should not prefetch already loaded scripts",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to look into these still, not blocking this PR.

"Prefetching Links in viewport production mode should not duplicate prefetches"
],
"pending": [],
"flakey": [],
"runtimeError": false
Expand Down
Loading