Commit 5703cb9e authored by Luke Sandberg's avatar Luke Sandberg

Delete app-build-manifest creation code and files

Remove the webpack AppBuildManifestPlugin, turbopack AppBuildManifest
generation, and all related code since client reference manifests now
provide the accurate source of truth for First Load JS calculations.

This eliminates redundant manifest generation and improves build performance.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 8579379b
...@@ -23,8 +23,8 @@ use next_core::{ ...@@ -23,8 +23,8 @@ use next_core::{
next_dynamic::NextDynamicTransition, next_dynamic::NextDynamicTransition,
next_edge::route_regex::get_named_middleware_regex, next_edge::route_regex::get_named_middleware_regex,
next_manifests::{ next_manifests::{
AppBuildManifest, AppPathsManifest, BuildManifest, ClientReferenceManifest, AppPathsManifest, BuildManifest, ClientReferenceManifest, EdgeFunctionDefinition,
EdgeFunctionDefinition, MiddlewareMatcher, MiddlewaresManifestV2, PagesManifest, Regions, MiddlewareMatcher, MiddlewaresManifestV2, PagesManifest, Regions,
client_reference_manifest::ClientReferenceManifestOptions, client_reference_manifest::ClientReferenceManifestOptions,
}, },
next_server::{ next_server::{
...@@ -41,7 +41,7 @@ use tracing::Instrument; ...@@ -41,7 +41,7 @@ use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
Completion, FxIndexSet, NonLocalValue, ResolvedVc, TryJoinIterExt, ValueToString, Vc, Completion, FxIndexSet, NonLocalValue, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
fxindexmap, fxindexset, trace::TraceRawVcs, fxindexset, trace::TraceRawVcs,
}; };
use turbo_tasks_env::{CustomProcessEnv, ProcessEnv}; use turbo_tasks_env::{CustomProcessEnv, ProcessEnv};
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
...@@ -98,7 +98,6 @@ pub struct AppProject { ...@@ -98,7 +98,6 @@ pub struct AppProject {
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct OptionAppProject(Option<ResolvedVc<AppProject>>); pub struct OptionAppProject(Option<ResolvedVc<AppProject>>);
impl AppProject {}
impl AppProject { impl AppProject {
pub fn client_transition_name() -> RcStr { pub fn client_transition_name() -> RcStr {
rcstr!("next-ecmascript-client-reference") rcstr!("next-ecmascript-client-reference")
...@@ -1170,7 +1169,7 @@ impl AppEndpoint { ...@@ -1170,7 +1169,7 @@ impl AppEndpoint {
enum EmitManifests { enum EmitManifests {
/// Don't emit any manifests (needed for the RSC endpoints) /// Don't emit any manifests (needed for the RSC endpoints)
None, None,
/// Emit the manifest for basic Next.js functionality (e.g. app-build-manifest.json) /// Emit the manifest for basic Next.js functionality (e.g. build-manifest.json)
Minimal, Minimal,
/// All manifests: `Minimal` plus next-font, next-dynamic, ... /// All manifests: `Minimal` plus next-font, next-dynamic, ...
Full, Full,
...@@ -1311,30 +1310,6 @@ impl AppEndpoint { ...@@ -1311,30 +1310,6 @@ impl AppEndpoint {
let manifest_path_prefix = &app_entry.original_name; let manifest_path_prefix = &app_entry.original_name;
if emit_manifests != EmitManifests::None {
let app_build_manifest = AppBuildManifest {
pages: fxindexmap!(
app_entry.original_name.clone() => ResolvedVc::cell(entry_client_chunks
.iter()
.chain(client_shared_chunks.iter())
.copied()
.collect())
),
};
let app_build_manifest_output = app_build_manifest
.build_output(
node_root.join(&format!(
"server/app{manifest_path_prefix}/app-build-manifest.json",
))?,
client_relative_path.clone(),
)
.await?
.to_resolved()
.await?;
server_assets.insert(app_build_manifest_output);
}
// polyfill-nomodule.js is a pre-compiled asset distributed as part of next, // polyfill-nomodule.js is a pre-compiled asset distributed as part of next,
// load it as a RawModule. // load it as a RawModule.
let next_package = get_next_package(project.project_path().owned().await?) let next_package = get_next_package(project.project_path().owned().await?)
......
...@@ -439,79 +439,6 @@ pub struct FontManifestEntry { ...@@ -439,79 +439,6 @@ pub struct FontManifestEntry {
pub content: RcStr, pub content: RcStr,
} }
#[derive(Default, Debug)]
pub struct AppBuildManifest {
pub pages: FxIndexMap<RcStr, ResolvedVc<OutputAssets>>,
}
impl AppBuildManifest {
pub async fn build_output(
self,
output_path: FileSystemPath,
client_relative_path: FileSystemPath,
) -> Result<Vc<Box<dyn OutputAsset>>> {
let client_relative_path_ref = client_relative_path.clone();
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SerializedAppBuildManifest {
pub pages: FxIndexMap<RcStr, Vec<RcStr>>,
}
let pages: Vec<(RcStr, Vec<RcStr>)> = self
.pages
.iter()
.map(|(k, chunks)| {
let client_relative_path_ref = client_relative_path_ref.clone();
async move {
Ok((
k.clone(),
chunks
.await?
.iter()
.copied()
.map(|chunk| {
let client_relative_path_ref = client_relative_path_ref.clone();
async move {
let chunk_path = chunk.path().await?;
Ok(client_relative_path_ref
.get_path_to(&chunk_path)
.context(
"client chunk entry path must be inside the client \
root",
)?
.into())
}
})
.try_join()
.await?,
))
}
})
.try_join()
.await?;
let manifest = SerializedAppBuildManifest {
pages: FxIndexMap::from_iter(pages.into_iter()),
};
let references = self.pages.values().try_join().await?;
let references = references
.into_iter()
.flat_map(|c| c.into_iter().copied())
.collect();
Ok(Vc::upcast(VirtualOutputAsset::new_with_references(
output_path,
AssetContent::file(File::from(serde_json::to_string_pretty(&manifest)?).into()),
Vc::cell(references),
)))
}
}
// TODO(alexkirsz) Unify with the one for dev. // TODO(alexkirsz) Unify with the one for dev.
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
......
...@@ -109,7 +109,6 @@ export async function handleRouteType({ ...@@ -109,7 +109,6 @@ export async function handleRouteType({
manifestLoader.deleteMiddlewareManifest(key) manifestLoader.deleteMiddlewareManifest(key)
} }
await manifestLoader.loadAppBuildManifest(page)
await manifestLoader.loadBuildManifest(page, 'app') await manifestLoader.loadBuildManifest(page, 'app')
await manifestLoader.loadAppPathsManifest(page) await manifestLoader.loadAppPathsManifest(page)
await manifestLoader.loadActionManifest(page) await manifestLoader.loadActionManifest(page)
......
import type { AppBuildManifest } from './webpack/plugins/app-build-manifest-plugin'
import type { PagesManifest } from './webpack/plugins/pages-manifest-plugin' import type { PagesManifest } from './webpack/plugins/pages-manifest-plugin'
import type { ExportPathMap, NextConfigComplete } from '../server/config-shared' import type { ExportPathMap, NextConfigComplete } from '../server/config-shared'
import type { MiddlewareManifest } from './webpack/plugins/middleware-plugin' import type { MiddlewareManifest } from './webpack/plugins/middleware-plugin'
...@@ -68,7 +67,6 @@ import { ...@@ -68,7 +67,6 @@ import {
MIDDLEWARE_MANIFEST, MIDDLEWARE_MANIFEST,
APP_PATHS_MANIFEST, APP_PATHS_MANIFEST,
APP_PATH_ROUTES_MANIFEST, APP_PATH_ROUTES_MANIFEST,
APP_BUILD_MANIFEST,
RSC_MODULE_TYPES, RSC_MODULE_TYPES,
NEXT_FONT_MANIFEST, NEXT_FONT_MANIFEST,
SUBRESOURCE_INTEGRITY_MANIFEST, SUBRESOURCE_INTEGRITY_MANIFEST,
...@@ -1840,7 +1838,6 @@ export default async function build( ...@@ -1840,7 +1838,6 @@ export default async function build(
const postCompileSpinner = createSpinner('Collecting page data') const postCompileSpinner = createSpinner('Collecting page data')
const buildManifestPath = path.join(distDir, BUILD_MANIFEST) const buildManifestPath = path.join(distDir, BUILD_MANIFEST)
const appBuildManifestPath = path.join(distDir, APP_BUILD_MANIFEST)
let staticAppPagesCount = 0 let staticAppPagesCount = 0
let serverAppPagesCount = 0 let serverAppPagesCount = 0
...@@ -1861,9 +1858,6 @@ export default async function build( ...@@ -1861,9 +1858,6 @@ export default async function build(
const pageInfos: PageInfos = new Map<string, PageInfo>() const pageInfos: PageInfos = new Map<string, PageInfo>()
let pagesManifest = await readManifest<PagesManifest>(pagesManifestPath) let pagesManifest = await readManifest<PagesManifest>(pagesManifestPath)
const buildManifest = await readManifest<BuildManifest>(buildManifestPath) const buildManifest = await readManifest<BuildManifest>(buildManifestPath)
const appBuildManifest = appDir
? await readManifest<AppBuildManifest>(appBuildManifestPath)
: undefined
const appPathRoutes: Record<string, string> = {} const appPathRoutes: Record<string, string> = {}
...@@ -1981,7 +1975,7 @@ export default async function build( ...@@ -1981,7 +1975,7 @@ export default async function build(
let hasSsrAmpPages = false let hasSsrAmpPages = false
const computedManifestData = await computeFromManifest( const computedManifestData = await computeFromManifest(
{ build: buildManifest, app: appBuildManifest }, { build: buildManifest },
distDir, distDir,
config.experimental.gzipSize config.experimental.gzipSize
) )
...@@ -2048,7 +2042,6 @@ export default async function build( ...@@ -2048,7 +2042,6 @@ export default async function build(
actualPage, actualPage,
distDir, distDir,
buildManifest, buildManifest,
appBuildManifest,
config.experimental.gzipSize, config.experimental.gzipSize,
computedManifestData computedManifestData
) )
...@@ -2547,7 +2540,6 @@ export default async function build( ...@@ -2547,7 +2540,6 @@ export default async function build(
: []), : []),
path.join(SERVER_DIRECTORY, APP_PATHS_MANIFEST), path.join(SERVER_DIRECTORY, APP_PATHS_MANIFEST),
path.join(APP_PATH_ROUTES_MANIFEST), path.join(APP_PATH_ROUTES_MANIFEST),
APP_BUILD_MANIFEST,
path.join( path.join(
SERVER_DIRECTORY, SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST + '.js' SERVER_REFERENCE_MANIFEST + '.js'
...@@ -4160,7 +4152,6 @@ export default async function build( ...@@ -4160,7 +4152,6 @@ export default async function build(
pagesDir, pagesDir,
useStaticPages404, useStaticPages404,
pageExtensions: config.pageExtensions, pageExtensions: config.pageExtensions,
appBuildManifest,
buildManifest, buildManifest,
middlewareManifest, middlewareManifest,
gzipSize: config.experimental.gzipSize, gzipSize: config.experimental.gzipSize,
......
import type { NextConfigComplete } from '../server/config-shared' import type { NextConfigComplete } from '../server/config-shared'
import type { ExperimentalPPRConfig } from '../server/lib/experimental/ppr' import type { ExperimentalPPRConfig } from '../server/lib/experimental/ppr'
import type { AppBuildManifest } from './webpack/plugins/app-build-manifest-plugin'
import { computeAppBuildManifestFromClientReferences } from './client-reference-manifest-utils' import { computeAppBuildManifestFromClientReferences } from './client-reference-manifest-utils'
import type { AssetBinding } from './webpack/loaders/get-module-build-info' import type { AssetBinding } from './webpack/loaders/get-module-build-info'
import type { PageConfig, ServerRuntime } from '../types' import type { PageConfig, ServerRuntime } from '../types'
...@@ -155,7 +154,6 @@ type ComputeFilesManifestResult = { ...@@ -155,7 +154,6 @@ type ComputeFilesManifestResult = {
} }
let cachedBuildManifest: BuildManifest | undefined let cachedBuildManifest: BuildManifest | undefined
let cachedAppBuildManifest: AppBuildManifest | undefined
let lastCompute: ComputeFilesManifestResult | undefined let lastCompute: ComputeFilesManifestResult | undefined
let lastComputePageInfo: boolean | undefined let lastComputePageInfo: boolean | undefined
...@@ -163,7 +161,6 @@ let lastComputePageInfo: boolean | undefined ...@@ -163,7 +161,6 @@ let lastComputePageInfo: boolean | undefined
export async function computeFromManifest( export async function computeFromManifest(
manifests: { manifests: {
build: BuildManifest build: BuildManifest
app?: AppBuildManifest
}, },
distPath: string, distPath: string,
gzipSize: boolean = true, gzipSize: boolean = true,
...@@ -171,8 +168,7 @@ export async function computeFromManifest( ...@@ -171,8 +168,7 @@ export async function computeFromManifest(
): Promise<ComputeFilesManifestResult> { ): Promise<ComputeFilesManifestResult> {
if ( if (
Object.is(cachedBuildManifest, manifests.build) && Object.is(cachedBuildManifest, manifests.build) &&
lastComputePageInfo === !!pageInfos && lastComputePageInfo === !!pageInfos
Object.is(cachedAppBuildManifest, manifests.app)
) { ) {
return lastCompute! return lastCompute!
} }
...@@ -308,7 +304,6 @@ export async function computeFromManifest( ...@@ -308,7 +304,6 @@ export async function computeFromManifest(
} }
cachedBuildManifest = manifests.build cachedBuildManifest = manifests.build
cachedAppBuildManifest = manifests.app
lastComputePageInfo = !!pageInfos lastComputePageInfo = !!pageInfos
return lastCompute! return lastCompute!
} }
...@@ -406,7 +401,6 @@ export async function printTreeView( ...@@ -406,7 +401,6 @@ export async function printTreeView(
pagesDir, pagesDir,
pageExtensions, pageExtensions,
buildManifest, buildManifest,
appBuildManifest,
middlewareManifest, middlewareManifest,
useStaticPages404, useStaticPages404,
gzipSize = true, gzipSize = true,
...@@ -416,7 +410,6 @@ export async function printTreeView( ...@@ -416,7 +410,6 @@ export async function printTreeView(
pagesDir?: string pagesDir?: string
pageExtensions: PageExtensions pageExtensions: PageExtensions
buildManifest: BuildManifest buildManifest: BuildManifest
appBuildManifest?: AppBuildManifest
middlewareManifest: MiddlewareManifest middlewareManifest: MiddlewareManifest
useStaticPages404: boolean useStaticPages404: boolean
gzipSize?: boolean gzipSize?: boolean
...@@ -468,7 +461,7 @@ export async function printTreeView( ...@@ -468,7 +461,7 @@ export async function printTreeView(
const messages: [string, string, string, string, string][] = [] const messages: [string, string, string, string, string][] = []
const stats = await computeFromManifest( const stats = await computeFromManifest(
{ build: buildManifest, app: appBuildManifest }, { build: buildManifest },
distPath, distPath,
gzipSize, gzipSize,
pageInfos pageInfos
...@@ -928,16 +921,17 @@ export async function getJsPageSizeInKb( ...@@ -928,16 +921,17 @@ export async function getJsPageSizeInKb(
page: string, page: string,
distPath: string, distPath: string,
buildManifest: BuildManifest, buildManifest: BuildManifest,
appBuildManifest?: AppBuildManifest,
gzipSize: boolean = true, gzipSize: boolean = true,
cachedStats?: ComputeFilesManifestResult cachedStats?: ComputeFilesManifestResult
): Promise<[number, number]> { ): Promise<[number, number]> {
const pageManifest = routerType === 'pages' ? buildManifest : appBuildManifest // For app router, get manifest from client reference manifests
if (!pageManifest) { // For pages router, use the build manifest
throw new Error('expected appBuildManifest with an "app" pageType') const pageManifest =
} routerType === 'pages'
? buildManifest
: computeAppBuildManifestFromClientReferences(distPath)
// Normalize appBuildManifest keys // Normalize app manifest keys
if (routerType === 'app') { if (routerType === 'app') {
pageManifest.pages = Object.entries(pageManifest.pages).reduce( pageManifest.pages = Object.entries(pageManifest.pages).reduce(
(acc: Record<string, string[]>, [key, value]) => { (acc: Record<string, string[]>, [key, value]) => {
...@@ -952,11 +946,7 @@ export async function getJsPageSizeInKb( ...@@ -952,11 +946,7 @@ export async function getJsPageSizeInKb(
// If stats was not provided, then compute it again. // If stats was not provided, then compute it again.
const stats = const stats =
cachedStats ?? cachedStats ??
(await computeFromManifest( (await computeFromManifest({ build: buildManifest }, distPath, gzipSize))
{ build: buildManifest, app: appBuildManifest },
distPath,
gzipSize
))
const pageData = stats.router[routerType] const pageData = stats.router[routerType]
if (!pageData) { if (!pageData) {
......
...@@ -63,7 +63,6 @@ import loadJsConfig, { ...@@ -63,7 +63,6 @@ import loadJsConfig, {
type ResolvedBaseUrl, type ResolvedBaseUrl,
} from './load-jsconfig' } from './load-jsconfig'
import { loadBindings } from './swc' import { loadBindings } from './swc'
import { AppBuildManifestPlugin } from './webpack/plugins/app-build-manifest-plugin'
import { SubresourceIntegrityPlugin } from './webpack/plugins/subresource-integrity-plugin' import { SubresourceIntegrityPlugin } from './webpack/plugins/subresource-integrity-plugin'
import { NextFontManifestPlugin } from './webpack/plugins/next-font-manifest-plugin' import { NextFontManifestPlugin } from './webpack/plugins/next-font-manifest-plugin'
import { getSupportedBrowsers } from './utils' import { getSupportedBrowsers } from './utils'
...@@ -2128,7 +2127,6 @@ export default async function getBaseWebpackConfig( ...@@ -2128,7 +2127,6 @@ export default async function getBaseWebpackConfig(
minimized: true, minimized: true,
}, },
}), }),
hasAppDir && isClient && new AppBuildManifestPlugin(),
hasAppDir && hasAppDir &&
(isClient (isClient
? new ClientReferenceManifestPlugin({ ? new ClientReferenceManifestPlugin({
......
import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import {
APP_BUILD_MANIFEST,
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
SYSTEM_ENTRYPOINTS,
} from '../../../shared/lib/constants'
import { getEntrypointFiles } from './build-manifest-plugin'
import getAppRouteFromEntrypoint from '../../../server/get-app-route-from-entrypoint'
import { isAppPageRoute } from '../../../lib/is-app-page-route'
import { isAppRouteRoute } from '../../../lib/is-app-route-route'
export type AppBuildManifest = {
pages: Record<string, string[]>
}
const PLUGIN_NAME = 'AppBuildManifestPlugin'
export class AppBuildManifestPlugin {
public apply(compiler: any) {
compiler.hooks.make.tap(PLUGIN_NAME, (compilation: any) => {
compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
},
() => this.createAsset(compilation)
)
})
}
private createAsset(compilation: webpack.Compilation) {
const manifest: AppBuildManifest = {
pages: {},
}
const mainFiles = new Set(
getEntrypointFiles(
compilation.entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_MAIN_APP)
)
)
// First pass: collect all entrypoints and group them by route
const allEntrypoints = new Map<string, any>()
const routeToEntrypoints = new Map<string, Set<string>>()
for (const entrypoint of compilation.entrypoints.values()) {
if (!entrypoint.name || SYSTEM_ENTRYPOINTS.has(entrypoint.name)) {
continue
}
const pagePath = getAppRouteFromEntrypoint(entrypoint.name)
if (!pagePath) {
continue
}
allEntrypoints.set(entrypoint.name, entrypoint)
// Check if this is an actual route (page or route handler)
const isRoute = isAppPageRoute(pagePath) || isAppRouteRoute(pagePath)
if (isRoute) {
// This is a route - it gets its own manifest entry
if (!routeToEntrypoints.has(pagePath)) {
routeToEntrypoints.set(pagePath, new Set())
}
routeToEntrypoints.get(pagePath)!.add(entrypoint.name)
// Find all segments that contribute to this route
this.collectContributingSegments(
pagePath,
entrypoint.name,
allEntrypoints,
routeToEntrypoints
)
}
}
// Second pass: generate manifest entries for each route
for (const [routePath, entrypointNames] of routeToEntrypoints.entries()) {
const allFiles = new Set([...mainFiles])
for (const entrypointName of entrypointNames) {
const entrypoint = allEntrypoints.get(entrypointName)
if (entrypoint) {
const filesForEntry = getEntrypointFiles(entrypoint)
for (const file of filesForEntry) {
allFiles.add(file)
}
}
}
manifest.pages[routePath] = Array.from(allFiles)
}
// Sort the keys to match turbopack behavior
const sortedPages: Record<string, string[]> = {}
Object.keys(manifest.pages)
.sort()
.forEach((key) => {
sortedPages[key] = manifest.pages[key]
})
manifest.pages = sortedPages
const json = JSON.stringify(manifest, null, 2)
compilation.emitAsset(
APP_BUILD_MANIFEST,
new sources.RawSource(json) as unknown as webpack.sources.RawSource
)
}
private collectContributingSegments(
routePath: string,
routeEntrypoint: string,
allEntrypoints: Map<string, any>,
routeToEntrypoints: Map<string, Set<string>>
) {
// Extract the route directory path (remove the /page or /route suffix)
const routePrefix = routeEntrypoint.replace(/\/(page|route)$/, '')
const routeParts = routePrefix
.replace(/^app\//, '')
.split('/')
.filter(Boolean)
// Look for all segments that could contribute to this route
for (const [entrypointName] of allEntrypoints.entries()) {
if (entrypointName === routeEntrypoint) continue
// Skip if it's already another route
const otherPagePath = getAppRouteFromEntrypoint(entrypointName)
if (
otherPagePath &&
(isAppPageRoute(otherPagePath) || isAppRouteRoute(otherPagePath))
) {
continue
}
if (this.isSegmentContributingToRoute(entrypointName, routeParts)) {
routeToEntrypoints.get(routePath)!.add(entrypointName)
}
}
}
private isSegmentContributingToRoute(
segmentEntrypoint: string,
routeParts: string[]
): boolean {
// Remove 'app/' prefix and split into parts
const segmentPath = segmentEntrypoint.replace(/^app\//, '')
const segmentParts = segmentPath.split('/').filter(Boolean)
if (segmentParts.length === 0) return false
const lastSegment = segmentParts[segmentParts.length - 1]
// Check if this is a special file that contributes to routes
const specialFiles = [
'layout',
'loading',
'error',
'not-found',
'global-error',
'template',
'default',
]
const isSpecialFile = specialFiles.includes(lastSegment)
// Check if this is a parallel route slot default (@slot/default)
const isParallelRouteDefault =
segmentParts.some((part) => part.startsWith('@')) &&
lastSegment === 'default'
if (!isSpecialFile && !isParallelRouteDefault) {
return false
}
// Get the directory path of the segment (without the file name)
const segmentDir = segmentParts.slice(0, -1)
// For parallel routes, we need special handling
if (segmentParts.some((part) => part.startsWith('@'))) {
// This is within a parallel route - it contributes if it's in the route path or a parent
const normalizedSegmentDir = segmentDir.filter(
(part) => !part.startsWith('@')
)
return (
normalizedSegmentDir.length <= routeParts.length &&
normalizedSegmentDir.every((part, i) => routeParts[i] === part)
)
}
// Regular special files contribute if they are at the same level or parent level of the route
return (
segmentDir.length <= routeParts.length &&
segmentDir.every((part, i) => routeParts[i] === part)
)
}
}
...@@ -387,7 +387,6 @@ export async function handleRouteType({ ...@@ -387,7 +387,6 @@ export async function handleRouteType({
manifestLoader.deleteMiddlewareManifest(key) manifestLoader.deleteMiddlewareManifest(key)
} }
await manifestLoader.loadAppBuildManifest(page)
await manifestLoader.loadBuildManifest(page, 'app') await manifestLoader.loadBuildManifest(page, 'app')
await manifestLoader.loadAppPathsManifest(page) await manifestLoader.loadAppPathsManifest(page)
await manifestLoader.loadActionManifest(page) await manifestLoader.loadActionManifest(page)
......
...@@ -78,7 +78,6 @@ export const WEBPACK_STATS = 'webpack-stats.json' ...@@ -78,7 +78,6 @@ export const WEBPACK_STATS = 'webpack-stats.json'
export const APP_PATHS_MANIFEST = 'app-paths-manifest.json' export const APP_PATHS_MANIFEST = 'app-paths-manifest.json'
export const APP_PATH_ROUTES_MANIFEST = 'app-path-routes-manifest.json' export const APP_PATH_ROUTES_MANIFEST = 'app-path-routes-manifest.json'
export const BUILD_MANIFEST = 'build-manifest.json' export const BUILD_MANIFEST = 'build-manifest.json'
export const APP_BUILD_MANIFEST = 'app-build-manifest.json'
export const FUNCTIONS_CONFIG_MANIFEST = 'functions-config-manifest.json' export const FUNCTIONS_CONFIG_MANIFEST = 'functions-config-manifest.json'
export const SUBRESOURCE_INTEGRITY_MANIFEST = 'subresource-integrity-manifest' export const SUBRESOURCE_INTEGRITY_MANIFEST = 'subresource-integrity-manifest'
export const NEXT_FONT_MANIFEST = 'next-font-manifest' export const NEXT_FONT_MANIFEST = 'next-font-manifest'
......
...@@ -10,13 +10,11 @@ import type { ...@@ -10,13 +10,11 @@ import type {
StatsCompilation as WebpackStats, StatsCompilation as WebpackStats,
} from 'webpack' } from 'webpack'
import type { BuildManifest } from '../../../server/get-page-files' import type { BuildManifest } from '../../../server/get-page-files'
import type { AppBuildManifest } from '../../../build/webpack/plugins/app-build-manifest-plugin'
import type { PagesManifest } from '../../../build/webpack/plugins/pages-manifest-plugin' import type { PagesManifest } from '../../../build/webpack/plugins/pages-manifest-plugin'
import type { ActionManifest } from '../../../build/webpack/plugins/flight-client-entry-plugin' import type { ActionManifest } from '../../../build/webpack/plugins/flight-client-entry-plugin'
import type { NextFontManifest } from '../../../build/webpack/plugins/next-font-manifest-plugin' import type { NextFontManifest } from '../../../build/webpack/plugins/next-font-manifest-plugin'
import type { REACT_LOADABLE_MANIFEST } from '../constants' import type { REACT_LOADABLE_MANIFEST } from '../constants'
import { import {
APP_BUILD_MANIFEST,
APP_PATHS_MANIFEST, APP_PATHS_MANIFEST,
BUILD_MANIFEST, BUILD_MANIFEST,
INTERCEPTION_ROUTE_REWRITE_MANIFEST, INTERCEPTION_ROUTE_REWRITE_MANIFEST,
...@@ -68,7 +66,6 @@ type TurbopackMiddlewareManifest = MiddlewareManifest & { ...@@ -68,7 +66,6 @@ type TurbopackMiddlewareManifest = MiddlewareManifest & {
type ManifestName = type ManifestName =
| typeof MIDDLEWARE_MANIFEST | typeof MIDDLEWARE_MANIFEST
| typeof BUILD_MANIFEST | typeof BUILD_MANIFEST
| typeof APP_BUILD_MANIFEST
| typeof PAGES_MANIFEST | typeof PAGES_MANIFEST
| typeof WEBPACK_STATS | typeof WEBPACK_STATS
| typeof APP_PATHS_MANIFEST | typeof APP_PATHS_MANIFEST
...@@ -134,7 +131,6 @@ async function readPartialManifest<T>( ...@@ -134,7 +131,6 @@ async function readPartialManifest<T>(
export class TurbopackManifestLoader { export class TurbopackManifestLoader {
private actionManifests: Map<EntryKey, ActionManifest> = new Map() private actionManifests: Map<EntryKey, ActionManifest> = new Map()
private appBuildManifests: Map<EntryKey, AppBuildManifest> = new Map()
private appPathsManifests: Map<EntryKey, PagesManifest> = new Map() private appPathsManifests: Map<EntryKey, PagesManifest> = new Map()
private buildManifests: Map<EntryKey, BuildManifest> = new Map() private buildManifests: Map<EntryKey, BuildManifest> = new Map()
private clientBuildManifests: Map<EntryKey, ClientBuildManifest> = new Map() private clientBuildManifests: Map<EntryKey, ClientBuildManifest> = new Map()
...@@ -164,7 +160,6 @@ export class TurbopackManifestLoader { ...@@ -164,7 +160,6 @@ export class TurbopackManifestLoader {
delete(key: EntryKey) { delete(key: EntryKey) {
this.actionManifests.delete(key) this.actionManifests.delete(key)
this.appBuildManifests.delete(key)
this.appPathsManifests.delete(key) this.appPathsManifests.delete(key)
this.buildManifests.delete(key) this.buildManifests.delete(key)
this.clientBuildManifests.delete(key) this.clientBuildManifests.delete(key)
...@@ -252,41 +247,6 @@ export class TurbopackManifestLoader { ...@@ -252,41 +247,6 @@ export class TurbopackManifestLoader {
) )
} }
async loadAppBuildManifest(pageName: string): Promise<void> {
this.appBuildManifests.set(
getEntryKey('app', 'server', pageName),
await readPartialManifest(
this.distDir,
APP_BUILD_MANIFEST,
pageName,
'app'
)
)
}
private mergeAppBuildManifests(manifests: Iterable<AppBuildManifest>) {
const manifest: AppBuildManifest = {
pages: {},
}
for (const m of manifests) {
Object.assign(manifest.pages, m.pages)
}
manifest.pages = sortObjectByKey(manifest.pages)
return manifest
}
private async writeAppBuildManifest(): Promise<void> {
const appBuildManifest = this.mergeAppBuildManifests(
this.appBuildManifests.values()
)
const appBuildManifestPath = join(this.distDir, APP_BUILD_MANIFEST)
deleteCache(appBuildManifestPath)
await writeFileAtomic(
appBuildManifestPath,
JSON.stringify(appBuildManifest, null, 2)
)
}
async loadAppPathsManifest(pageName: string): Promise<void> { async loadAppPathsManifest(pageName: string): Promise<void> {
this.appPathsManifests.set( this.appPathsManifests.set(
getEntryKey('app', 'server', pageName), getEntryKey('app', 'server', pageName),
...@@ -795,7 +755,6 @@ export class TurbopackManifestLoader { ...@@ -795,7 +755,6 @@ export class TurbopackManifestLoader {
entrypoints: Entrypoints entrypoints: Entrypoints
}) { }) {
await this.writeActionManifest() await this.writeActionManifest()
await this.writeAppBuildManifest()
await this.writeAppPathsManifest() await this.writeAppPathsManifest()
await this.writeBuildManifest(entrypoints, devRewrites, productionRewrites) await this.writeBuildManifest(entrypoints, devRewrites, productionRewrites)
await this.writeFallbackBuildManifest() await this.writeFallbackBuildManifest()
...@@ -810,7 +769,7 @@ export class TurbopackManifestLoader { ...@@ -810,7 +769,7 @@ export class TurbopackManifestLoader {
} }
} }
function sortObjectByKey(obj: Record<string, any>) { function sortObjectByKey<V>(obj: Record<string, V>) {
return Object.keys(obj) return Object.keys(obj)
.sort() .sort()
.reduce( .reduce(
...@@ -818,6 +777,6 @@ function sortObjectByKey(obj: Record<string, any>) { ...@@ -818,6 +777,6 @@ function sortObjectByKey(obj: Record<string, any>) {
acc[key] = obj[key] acc[key] = obj[key]
return acc return acc
}, },
{} as Record<string, any> {} as Record<string, V>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment