Skip to content

Commit

Permalink
fix: replaced array with set, enabled worker threads
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Dec 23, 2023
1 parent 926c5ec commit 6f223dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function collectBuildTraces({
staticPages: string[]
hasSsrAmpPages: boolean
outputFileTracingRoot: string
edgeRoutes: readonly string[] | undefined
edgeRoutes: ReadonlySet<string> | undefined
nextBuildSpan?: Span
config: NextConfigComplete
buildTraceContext?: BuildTraceContext
Expand Down Expand Up @@ -642,7 +642,7 @@ export async function collectBuildTraces({
}

// Edge routes have no trace files.
if (edgeRoutes && edgeRoutes.includes(route)) {
if (edgeRoutes && edgeRoutes.has(route)) {
return
}

Expand Down
15 changes: 6 additions & 9 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ export default async function build(
{
numWorkers: 1,
exposedMethods: ['collectBuildTraces'],
enableWorkerThreads: true,
}
) as Worker & typeof import('./collect-build-traces')

Expand Down Expand Up @@ -1946,15 +1947,11 @@ export default async function build(
if (!isGenerateMode && config.outputFileTracing && !buildTracesPromise) {
// Get all the edge routes from the pageInfos. If the runtime is set as
// edge, then we know it's an edge route.
const edgeRoutes: ReadonlyArray<string> = Array.from(
pageInfos.entries()
).reduce<string[]>((acc, [route, { runtime }]) => {
if (runtime === 'edge') {
acc.push(route)
}

return acc
}, [])
const edgeRoutes = new Set<string>()
pageInfos.forEach((pageInfo, route) => {
if (pageInfo.runtime !== 'edge') return
edgeRoutes.add(route)
})

buildTracesPromise = collectBuildTraces({
dir,
Expand Down

0 comments on commit 6f223dd

Please sign in to comment.