From 0177545a6e55044ef572214330e94ba0b4108781 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sun, 7 Jul 2024 17:16:15 +0200 Subject: [PATCH 1/3] Turbopack build: Ensure Pages Router manifests are loaded with buildId (#67317) 1. The build manifest incorrectly held a hardcoded `/development/` which doesn't work in production where buildId is unique. 2. Implemented `__rewrites` in the build manifest, this was a TODO in the codebase. After fixing 1. it highlighted that tests related to it were incorrectly passing. Made sure those tests still pass by implementing the feature. 3. Implemented middleware matchers on the client-side, this was missing for production and was highlighted by fixing 1. as well. Had to take a bit different approach for Turbopack as in the webpack case we're parsing the entrypoint manually in Next.js which is not ideal. Planning to change this to be written into the `_buildManifest` but for now it's a separate file in the same way as we handle it for development. 4. Made sure that rewrites to an external url are not in the manifest, similar case, highlighted test wasn't passing by fixing 1. then fixed it. --- packages/next/src/build/index.ts | 26 +++---- .../webpack/plugins/build-manifest-plugin.ts | 14 +++- .../webpack/plugins/define-env-plugin.ts | 6 +- packages/next/src/client/page-loader.ts | 36 ++++++++- .../src/server/dev/hot-reloader-turbopack.ts | 14 ++-- .../next/src/server/dev/turbopack-utils.ts | 54 +++++++++----- .../server/dev/turbopack/manifest-loader.ts | 73 ++++++++++++++----- .../lib/router-utils/setup-dev-bundler.ts | 4 +- packages/next/src/shared/lib/constants.ts | 4 +- test/integration/app-dir-export/test/utils.ts | 6 ++ test/turbopack-build-tests-manifest.json | 28 +++---- 11 files changed, 181 insertions(+), 84 deletions(-) diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index 7598294ec95a3..19c2d388e8327 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -1353,7 +1353,7 @@ export default async function build( distDir, fetchCacheKeyPrefix: config.experimental.fetchCacheKeyPrefix, hasRewrites, - // TODO: Implement + // Implemented separately in Turbopack, doesn't have to be passed here. middlewareMatchers: undefined, }), buildId: NextBuildContext.buildId!, @@ -1404,13 +1404,6 @@ export default async function build( encryptionKey, }) - // TODO: implement this - const emptyRewritesObjToBeImplemented = { - beforeFiles: [], - afterFiles: [], - fallback: [], - } - const entrypointsResult = await entrypointsSubscription.next() if (entrypointsResult.done) { throw new Error('Turbopack did not return any entrypoints') @@ -1442,7 +1435,8 @@ export default async function build( currentEntryIssues, manifestLoader, nextConfig: config, - rewrites: emptyRewritesObjToBeImplemented, + devRewrites: undefined, + productionRewrites: customRoutes.rewrites, logErrors: false, }) @@ -1477,7 +1471,8 @@ export default async function build( currentEntryIssues, entrypoints: currentEntrypoints, manifestLoader, - rewrites: emptyRewritesObjToBeImplemented, + devRewrites: undefined, + productionRewrites: customRoutes.rewrites, logErrors: false, }) ) @@ -1493,7 +1488,8 @@ export default async function build( currentEntryIssues, entrypoints: currentEntrypoints, manifestLoader, - rewrites: emptyRewritesObjToBeImplemented, + devRewrites: undefined, + productionRewrites: customRoutes.rewrites, logErrors: false, }) ) @@ -1504,15 +1500,17 @@ export default async function build( currentEntryIssues, entrypoints: currentEntrypoints, manifestLoader, - rewrites: emptyRewritesObjToBeImplemented, + devRewrites: undefined, + productionRewrites: customRoutes.rewrites, logErrors: false, }) ) await Promise.all(promises) await manifestLoader.writeManifests({ - rewrites: emptyRewritesObjToBeImplemented, - pageEntrypoints: currentEntrypoints.page, + devRewrites: undefined, + productionRewrites: customRoutes.rewrites, + entrypoints: currentEntrypoints, }) const errors: { diff --git a/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts b/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts index 9be30ecee2499..5bdc80e627c74 100644 --- a/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts +++ b/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts @@ -77,9 +77,15 @@ export function normalizeRewritesForBuildManifest( rewrites: CustomRoutes['rewrites'] ): CustomRoutes['rewrites'] { return { - afterFiles: rewrites.afterFiles?.map((item) => normalizeRewrite(item)), - beforeFiles: rewrites.beforeFiles?.map((item) => normalizeRewrite(item)), - fallback: rewrites.fallback?.map((item) => normalizeRewrite(item)), + afterFiles: rewrites.afterFiles + ?.map(processRoute) + ?.map((item) => normalizeRewrite(item)), + beforeFiles: rewrites.beforeFiles + ?.map(processRoute) + ?.map((item) => normalizeRewrite(item)), + fallback: rewrites.fallback + ?.map(processRoute) + ?.map((item) => normalizeRewrite(item)), } } @@ -143,7 +149,7 @@ export const processRoute = (r: Rewrite) => { // omit external rewrite destinations since these aren't // handled client-side - if (!rewrite.destination.startsWith('/')) { + if (!rewrite?.destination?.startsWith('/')) { delete (rewrite as any).destination } return rewrite diff --git a/packages/next/src/build/webpack/plugins/define-env-plugin.ts b/packages/next/src/build/webpack/plugins/define-env-plugin.ts index 644593b95d34b..45d24b04b04b9 100644 --- a/packages/next/src/build/webpack/plugins/define-env-plugin.ts +++ b/packages/next/src/build/webpack/plugins/define-env-plugin.ts @@ -177,7 +177,11 @@ export function getDefineEnv({ 'process.env.__NEXT_AFTER': config.experimental.after ?? false, 'process.env.NEXT_DEPLOYMENT_ID': config.deploymentId || false, 'process.env.__NEXT_FETCH_CACHE_KEY_PREFIX': fetchCacheKeyPrefix ?? '', - 'process.env.__NEXT_MIDDLEWARE_MATCHERS': middlewareMatchers ?? [], + ...(isTurbopack + ? {} + : { + 'process.env.__NEXT_MIDDLEWARE_MATCHERS': middlewareMatchers ?? [], + }), 'process.env.__NEXT_MANUAL_CLIENT_BASE_PATH': config.experimental.manualClientBasePath ?? false, 'process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME': JSON.stringify( diff --git a/packages/next/src/client/page-loader.ts b/packages/next/src/client/page-loader.ts index 12817b7bd0a6e..89cba2a023ccb 100644 --- a/packages/next/src/client/page-loader.ts +++ b/packages/next/src/client/page-loader.ts @@ -11,7 +11,8 @@ import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing- import { createRouteLoader, getClientBuildManifest } from './route-loader' import { DEV_CLIENT_PAGES_MANIFEST, - DEV_MIDDLEWARE_MANIFEST, + DEV_CLIENT_MIDDLEWARE_MANIFEST, + TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST, } from '../shared/lib/constants' declare global { @@ -85,12 +86,41 @@ export default class PageLoader { } getMiddleware() { - if (process.env.NODE_ENV === 'production') { + // Webpack production + if ( + process.env.NODE_ENV === 'production' && + process.env.__NEXT_MIDDLEWARE_MATCHERS + ) { const middlewareMatchers = process.env.__NEXT_MIDDLEWARE_MATCHERS window.__MIDDLEWARE_MATCHERS = middlewareMatchers ? (middlewareMatchers as any as MiddlewareMatcher[]) : undefined return window.__MIDDLEWARE_MATCHERS + // Turbopack production + } else if (process.env.NODE_ENV === 'production') { + if (window.__MIDDLEWARE_MATCHERS) { + return window.__MIDDLEWARE_MATCHERS + } else { + if (!this.promisedMiddlewareMatchers) { + // TODO: Decide what should happen when fetching fails instead of asserting + // @ts-ignore + this.promisedMiddlewareMatchers = fetch( + `${this.assetPrefix}/_next/static/${this.buildId}/${TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST}`, + { credentials: 'same-origin' } + ) + .then((res) => res.json()) + .then((matchers: MiddlewareMatcher[]) => { + window.__MIDDLEWARE_MATCHERS = matchers + return matchers + }) + .catch((err) => { + console.log(`Failed to fetch _devMiddlewareManifest`, err) + }) + } + // TODO Remove this assertion as this could be undefined + return this.promisedMiddlewareMatchers! + } + // Development both Turbopack and Webpack } else { if (window.__DEV_MIDDLEWARE_MATCHERS) { return window.__DEV_MIDDLEWARE_MATCHERS @@ -99,7 +129,7 @@ export default class PageLoader { // TODO: Decide what should happen when fetching fails instead of asserting // @ts-ignore this.promisedMiddlewareMatchers = fetch( - `${this.assetPrefix}/_next/static/${this.buildId}/${DEV_MIDDLEWARE_MANIFEST}`, + `${this.assetPrefix}/_next/static/${this.buildId}/${DEV_CLIENT_MIDDLEWARE_MANIFEST}`, { credentials: 'same-origin' } ) .then((res) => res.json()) diff --git a/packages/next/src/server/dev/hot-reloader-turbopack.ts b/packages/next/src/server/dev/hot-reloader-turbopack.ts index 671f4a76def5c..00807c847a890 100644 --- a/packages/next/src/server/dev/hot-reloader-turbopack.ts +++ b/packages/next/src/server/dev/hot-reloader-turbopack.ts @@ -462,7 +462,8 @@ export async function createHotReloaderTurbopack( currentEntryIssues, manifestLoader, nextConfig: opts.nextConfig, - rewrites: opts.fsChecker.rewrites, + devRewrites: opts.fsChecker.rewrites, + productionRewrites: undefined, logErrors: true, dev: { @@ -800,7 +801,8 @@ export async function createHotReloaderTurbopack( currentEntryIssues, entrypoints: currentEntrypoints, manifestLoader, - rewrites: opts.fsChecker.rewrites, + devRewrites: opts.fsChecker.rewrites, + productionRewrites: undefined, logErrors: true, hooks: { @@ -861,7 +863,8 @@ export async function createHotReloaderTurbopack( entrypoints: currentEntrypoints, manifestLoader, readyIds, - rewrites: opts.fsChecker.rewrites, + devRewrites: opts.fsChecker.rewrites, + productionRewrites: undefined, logErrors: true, hooks: { @@ -887,8 +890,9 @@ export async function createHotReloaderTurbopack( // Write empty manifests await currentEntriesHandling await manifestLoader.writeManifests({ - rewrites: opts.fsChecker.rewrites, - pageEntrypoints: currentEntrypoints.page, + devRewrites: opts.fsChecker.rewrites, + productionRewrites: undefined, + entrypoints: currentEntrypoints, }) async function handleProjectUpdates() { diff --git a/packages/next/src/server/dev/turbopack-utils.ts b/packages/next/src/server/dev/turbopack-utils.ts index 3442d60a33a66..d6701c15bd610 100644 --- a/packages/next/src/server/dev/turbopack-utils.ts +++ b/packages/next/src/server/dev/turbopack-utils.ts @@ -34,6 +34,7 @@ import { import type ws from 'next/dist/compiled/ws' import isInternal from '../../shared/lib/is-internal' import { isMetadataRoute } from '../../lib/metadata/is-metadata-route' +import type { CustomRoutes } from '../../lib/load-custom-routes' export async function getTurbopackJsConfig( dir: string, @@ -328,7 +329,8 @@ export async function handleRouteType({ entrypoints, manifestLoader, readyIds, - rewrites, + devRewrites, + productionRewrites, hooks, logErrors, }: { @@ -340,7 +342,8 @@ export async function handleRouteType({ currentEntryIssues: EntryIssuesMap entrypoints: Entrypoints manifestLoader: TurbopackManifestLoader - rewrites: SetupOpts['fsChecker']['rewrites'] + devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined + productionRewrites: CustomRoutes['rewrites'] | undefined logErrors: boolean readyIds?: ReadyIds // dev @@ -402,8 +405,9 @@ export async function handleRouteType({ await manifestLoader.loadLoadableManifest(page, 'pages') await manifestLoader.writeManifests({ - rewrites, - pageEntrypoints: entrypoints.page, + devRewrites, + productionRewrites, + entrypoints, }) processIssues( @@ -460,8 +464,9 @@ export async function handleRouteType({ await manifestLoader.loadLoadableManifest(page, 'pages') await manifestLoader.writeManifests({ - rewrites, - pageEntrypoints: entrypoints.page, + devRewrites, + productionRewrites, + entrypoints, }) processIssues(currentEntryIssues, key, writtenEndpoint, true, logErrors) @@ -504,8 +509,9 @@ export async function handleRouteType({ await manifestLoader.loadLoadableManifest(page, 'app') await manifestLoader.loadFontManifest(page, 'app') await manifestLoader.writeManifests({ - rewrites, - pageEntrypoints: entrypoints.page, + devRewrites, + productionRewrites, + entrypoints, }) processIssues(currentEntryIssues, key, writtenEndpoint, dev, logErrors) @@ -529,8 +535,9 @@ export async function handleRouteType({ } await manifestLoader.writeManifests({ - rewrites, - pageEntrypoints: entrypoints.page, + devRewrites, + productionRewrites, + entrypoints, }) processIssues(currentEntryIssues, key, writtenEndpoint, true, logErrors) @@ -685,7 +692,8 @@ export async function handleEntrypoints({ currentEntryIssues, manifestLoader, nextConfig, - rewrites, + devRewrites, + productionRewrites, logErrors, dev, }: { @@ -696,7 +704,8 @@ export async function handleEntrypoints({ currentEntryIssues: EntryIssuesMap manifestLoader: TurbopackManifestLoader nextConfig: NextConfigComplete - rewrites: SetupOpts['fsChecker']['rewrites'] + devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined + productionRewrites: CustomRoutes['rewrites'] | undefined logErrors: boolean dev?: HandleEntrypointsDevOpts @@ -784,8 +793,9 @@ export async function handleEntrypoints({ 'instrumentation' ) await manifestLoader.writeManifests({ - rewrites: rewrites, - pageEntrypoints: currentEntrypoints.page, + devRewrites, + productionRewrites, + entrypoints: currentEntrypoints, }) if (dev) { @@ -842,8 +852,9 @@ export async function handleEntrypoints({ dev.serverFields.middleware ) await manifestLoader.writeManifests({ - rewrites: rewrites, - pageEntrypoints: currentEntrypoints.page, + devRewrites, + productionRewrites, + entrypoints: currentEntrypoints, }) finishBuilding?.() @@ -935,7 +946,8 @@ export async function handlePagesErrorRoute({ currentEntryIssues, entrypoints, manifestLoader, - rewrites, + devRewrites, + productionRewrites, logErrors, hooks, @@ -943,7 +955,8 @@ export async function handlePagesErrorRoute({ currentEntryIssues: EntryIssuesMap entrypoints: Entrypoints manifestLoader: TurbopackManifestLoader - rewrites: SetupOpts['fsChecker']['rewrites'] + devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined + productionRewrites: CustomRoutes['rewrites'] | undefined logErrors: boolean hooks?: HandleRouteTypeHooks // dev @@ -993,8 +1006,9 @@ export async function handlePagesErrorRoute({ await manifestLoader.loadFontManifest('_error') await manifestLoader.writeManifests({ - rewrites, - pageEntrypoints: entrypoints.page, + devRewrites, + productionRewrites, + entrypoints, }) } diff --git a/packages/next/src/server/dev/turbopack/manifest-loader.ts b/packages/next/src/server/dev/turbopack/manifest-loader.ts index 75ced061c6b59..29f294b5a7431 100644 --- a/packages/next/src/server/dev/turbopack/manifest-loader.ts +++ b/packages/next/src/server/dev/turbopack/manifest-loader.ts @@ -22,6 +22,7 @@ import { PAGES_MANIFEST, REACT_LOADABLE_MANIFEST, SERVER_REFERENCE_MANIFEST, + TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST, } from '../../../shared/lib/constants' import { join, posix } from 'path' import { readFile, writeFile } from 'fs/promises' @@ -35,9 +36,10 @@ import { srcEmptySsgManifest, processRoute, } from '../../../build/webpack/plugins/build-manifest-plugin' -import type { PageEntrypoints } from './types' +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' interface InstrumentationDefinition { files: string[] @@ -278,8 +280,8 @@ export class TurbopackManifestLoader { ampDevFiles: [], polyfillFiles: [], lowPriorityFiles: [ - 'static/development/_ssgManifest.js', - 'static/development/_buildManifest.js', + `static/${this.buildId}/_ssgManifest.js`, + `static/${this.buildId}/_buildManifest.js`, ], rootMainFiles: [], ampFirstPages: [], @@ -294,14 +296,15 @@ export class TurbopackManifestLoader { } private async writeBuildManifest( - pageEntrypoints: PageEntrypoints, - rewrites: SetupOpts['fsChecker']['rewrites'] + entrypoints: Entrypoints, + devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined, + productionRewrites: CustomRoutes['rewrites'] | undefined ): Promise { - const processedRewrites = { - ...rewrites, - beforeFiles: (rewrites?.beforeFiles ?? []).map(processRoute), - afterFiles: (rewrites?.afterFiles ?? []).map(processRoute), - fallback: (rewrites?.fallback ?? []).map(processRoute), + const rewrites = productionRewrites ?? { + ...devRewrites, + beforeFiles: (devRewrites?.beforeFiles ?? []).map(processRoute), + afterFiles: (devRewrites?.afterFiles ?? []).map(processRoute), + fallback: (devRewrites?.fallback ?? []).map(processRoute), } const buildManifest = this.mergeBuildManifests(this.buildManifests.values()) const buildManifestPath = join(this.distDir, BUILD_MANIFEST) @@ -328,7 +331,7 @@ export class TurbopackManifestLoader { ) const interceptionRewrites = JSON.stringify( - processedRewrites.beforeFiles.filter(isInterceptionRouteRewrite) + rewrites.beforeFiles.filter(isInterceptionRouteRewrite) ) await writeFileAtomic( @@ -338,15 +341,22 @@ export class TurbopackManifestLoader { )};` ) + const pagesKeys = [...entrypoints.page.keys()] + if (entrypoints.global.app) { + pagesKeys.push('/_app') + } + if (entrypoints.global.error) { + pagesKeys.push('/_error') + } const content: ClientBuildManifest = { - __rewrites: normalizeRewritesForBuildManifest(processedRewrites) as any, + __rewrites: normalizeRewritesForBuildManifest(rewrites) as any, ...Object.fromEntries( - [...pageEntrypoints.keys()].map((pathname) => [ + pagesKeys.map((pathname) => [ pathname, - `static/chunks/pages${pathname === '/' ? '/index' : pathname}.js`, + [`static/chunks/pages${pathname === '/' ? '/index' : pathname}.js`], ]) ), - sortedPages: [...pageEntrypoints.keys()], + sortedPages: pagesKeys, } const buildManifestJs = `self.__BUILD_MANIFEST = ${JSON.stringify( content @@ -361,6 +371,26 @@ export class TurbopackManifestLoader { ) } + private async writeClientMiddlewareManifest(): Promise { + const middlewareManifest = this.mergeMiddlewareManifests( + this.middlewareManifests.values() + ) + + const matchers = middlewareManifest?.middleware['/']?.matchers || [] + + const clientMiddlewareManifestPath = join( + this.distDir, + 'static', + this.buildId, + `${TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST}` + ) + deleteCache(clientMiddlewareManifestPath) + await writeFileAtomic( + clientMiddlewareManifestPath, + JSON.stringify(matchers, null, 2) + ) + } + private async writeFallbackBuildManifest(): Promise { const fallbackBuildManifest = this.mergeBuildManifests( [ @@ -601,20 +631,23 @@ export class TurbopackManifestLoader { } async writeManifests({ - rewrites, - pageEntrypoints, + devRewrites, + productionRewrites, + entrypoints, }: { - rewrites: SetupOpts['fsChecker']['rewrites'] - pageEntrypoints: PageEntrypoints + devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined + productionRewrites: CustomRoutes['rewrites'] | undefined + entrypoints: Entrypoints }) { await this.writeActionManifest() await this.writeAppBuildManifest() await this.writeAppPathsManifest() await this.writeAutomaticFontOptimizationManifest() - await this.writeBuildManifest(pageEntrypoints, rewrites) + await this.writeBuildManifest(entrypoints, devRewrites, productionRewrites) await this.writeFallbackBuildManifest() await this.writeLoadableManifest() await this.writeMiddlewareManifest() + await this.writeClientMiddlewareManifest() await this.writeNextFontManifest() await this.writePagesManifest() } diff --git a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts index 9f286ffc2bf1d..175ea8b60d5ce 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts @@ -49,7 +49,7 @@ import { CLIENT_STATIC_FILES_PATH, COMPILER_NAMES, DEV_CLIENT_PAGES_MANIFEST, - DEV_MIDDLEWARE_MANIFEST, + DEV_CLIENT_MIDDLEWARE_MANIFEST, PHASE_DEVELOPMENT_SERVER, } from '../../../shared/lib/constants' @@ -859,7 +859,7 @@ async function startWatcher(opts: SetupOpts) { const clientPagesManifestPath = `/_next/${CLIENT_STATIC_FILES_PATH}/development/${DEV_CLIENT_PAGES_MANIFEST}` opts.fsChecker.devVirtualFsItems.add(clientPagesManifestPath) - const devMiddlewareManifestPath = `/_next/${CLIENT_STATIC_FILES_PATH}/development/${DEV_MIDDLEWARE_MANIFEST}` + const devMiddlewareManifestPath = `/_next/${CLIENT_STATIC_FILES_PATH}/development/${DEV_CLIENT_MIDDLEWARE_MANIFEST}` opts.fsChecker.devVirtualFsItems.add(devMiddlewareManifestPath) async function requestHandler(req: IncomingMessage, res: ServerResponse) { diff --git a/packages/next/src/shared/lib/constants.ts b/packages/next/src/shared/lib/constants.ts index b2b6d28e7903b..c8802582cd937 100644 --- a/packages/next/src/shared/lib/constants.ts +++ b/packages/next/src/shared/lib/constants.ts @@ -44,7 +44,9 @@ export const IMAGES_MANIFEST = 'images-manifest.json' export const SERVER_FILES_MANIFEST = 'required-server-files.json' export const DEV_CLIENT_PAGES_MANIFEST = '_devPagesManifest.json' export const MIDDLEWARE_MANIFEST = 'middleware-manifest.json' -export const DEV_MIDDLEWARE_MANIFEST = '_devMiddlewareManifest.json' +export const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST = + '_clientMiddlewareManifest.json' +export const DEV_CLIENT_MIDDLEWARE_MANIFEST = '_devMiddlewareManifest.json' export const REACT_LOADABLE_MANIFEST = 'react-loadable-manifest.json' export const AUTOMATIC_FONT_OPTIMIZATION_MANIFEST = 'font-manifest.json' export const SERVER_DIRECTORY = 'server' diff --git a/test/integration/app-dir-export/test/utils.ts b/test/integration/app-dir-export/test/utils.ts index 2433863d3ebed..6bfe624ac1bd0 100644 --- a/test/integration/app-dir-export/test/utils.ts +++ b/test/integration/app-dir-export/test/utils.ts @@ -34,6 +34,9 @@ export const expectedWhenTrailingSlashTrue = [ // Turbopack and plain next.js have different hash output for the file name expect.stringMatching(/_next\/static\/media\/test\.[0-9a-f]+\.png/), '_next/static/test-build-id/_buildManifest.js', + ...(process.env.TURBOPACK + ? ['_next/static/test-build-id/_clientMiddlewareManifest.json'] + : []), '_next/static/test-build-id/_ssgManifest.js', 'another/first/index.html', 'another/first/index.txt', @@ -57,6 +60,9 @@ const expectedWhenTrailingSlashFalse = [ '404.html', expect.stringMatching(/_next\/static\/media\/test\.[0-9a-f]+\.png/), '_next/static/test-build-id/_buildManifest.js', + ...(process.env.TURBOPACK + ? ['_next/static/test-build-id/_clientMiddlewareManifest.json'] + : []), '_next/static/test-build-id/_ssgManifest.js', 'another.html', 'another.txt', diff --git a/test/turbopack-build-tests-manifest.json b/test/turbopack-build-tests-manifest.json index 0f49ccf836ce6..a11e9b84934c6 100644 --- a/test/turbopack-build-tests-manifest.json +++ b/test/turbopack-build-tests-manifest.json @@ -1398,7 +1398,8 @@ "runtimeError": false }, "test/e2e/app-dir/css-order/css-order.test.ts": { - "passed": [ + "passed": [], + "failed": [ "css-order turbo should load correct styles navigating back again interleaved-a -> interleaved-b -> interleaved-a -> interleaved-b", "css-order turbo should load correct styles navigating back again pages-first -> pages-second -> pages-first -> pages-second", "css-order turbo should load correct styles navigating back again pages-first -> pages-third -> pages-first -> pages-third", @@ -1471,9 +1472,7 @@ "css-order turbo should load correct styles on reversed-b", "css-order turbo should load correct styles on second", "css-order turbo should load correct styles on second-client", - "css-order turbo should load correct styles on third" - ], - "failed": [ + "css-order turbo should load correct styles on third", "css-order turbo should load correct styles navigating back again first -> first-client -> first -> first-client", "css-order turbo should load correct styles navigating back again first -> second -> first -> second", "css-order turbo should load correct styles navigating back again first -> second-client -> first -> second-client", @@ -7241,14 +7240,14 @@ "CSS Module client-side navigation dev should be able to client-side navigate from blue to red", "CSS Module client-side navigation dev should be able to client-side navigate from none to blue", "CSS Module client-side navigation dev should be able to client-side navigate from none to red", - "CSS Module client-side navigation dev should be able to client-side navigate from red to blue", - "CSS Module client-side navigation production mode should time out and hard navigate for stalled CSS request" + "CSS Module client-side navigation dev should be able to client-side navigate from red to blue" ], "failed": [ "CSS Module client-side navigation production mode should be able to client-side navigate from blue to red", "CSS Module client-side navigation production mode should be able to client-side navigate from none to blue", "CSS Module client-side navigation production mode should be able to client-side navigate from none to red", - "CSS Module client-side navigation production mode should be able to client-side navigate from red to blue" + "CSS Module client-side navigation production mode should be able to client-side navigate from red to blue", + "CSS Module client-side navigation production mode should time out and hard navigate for stalled CSS request" ], "pending": [], "flakey": [], @@ -7518,8 +7517,6 @@ "passed": [ "CSS Support CSS page transition inject