Skip to content

Commit

Permalink
fix: Incorrect build size outputs for app dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mPaella committed Jun 4, 2023
1 parent 18d112f commit eb6f5ff
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { IncrementalCache } from '../server/lib/incremental-cache'
import { patchFetch } from '../server/lib/patch-fetch'
import { nodeFs } from '../server/lib/node-fs-methods'
import * as ciEnvironment from '../telemetry/ci-info'
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'

export type ROUTER_TYPE = 'pages' | 'app'

Expand Down Expand Up @@ -773,6 +774,18 @@ export async function getJsPageSizeInKb(
throw new Error('expected appBuildManifest with an "app" pageType')
}

// Normalize appBuildManifest keys
if (routerType === 'app') {
pageManifest.pages = Object.entries(pageManifest.pages).reduce(
(acc: Record<string, string[]>, [key, value]) => {
const newKey = normalizeAppPath(key)
acc[newKey] = value as string[]
return acc
},
{}
)
}

// If stats was not provided, then compute it again.
const stats =
cachedStats ??
Expand All @@ -788,10 +801,11 @@ export async function getJsPageSizeInKb(
throw new Error('expected "app" manifest data with an "app" pageType')
}

const pagePath =
routerType === 'pages'
? denormalizePagePath(page)
: denormalizeAppPagePath(page)
// Denormalization is not needed for "app" dir, as we normalize the keys of appBuildManifest instead
let pagePath = page
if (routerType === 'pages') {
pagePath = denormalizePagePath(page)
}

const fnFilterJs = (entry: string) => entry.endsWith('.js')

Expand Down

0 comments on commit eb6f5ff

Please sign in to comment.