From a5dca628c003554bd43311b82559c86ddf456f40 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 22 Dec 2023 20:24:49 -0700 Subject: [PATCH] fix: replaced array with object --- packages/next/src/build/collect-build-traces.ts | 4 ++-- packages/next/src/build/index.ts | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/next/src/build/collect-build-traces.ts b/packages/next/src/build/collect-build-traces.ts index a6439752defe2..d05fc05732bfc 100644 --- a/packages/next/src/build/collect-build-traces.ts +++ b/packages/next/src/build/collect-build-traces.ts @@ -78,7 +78,7 @@ export async function collectBuildTraces({ staticPages: string[] hasSsrAmpPages: boolean outputFileTracingRoot: string - edgeRoutes: readonly string[] | undefined + edgeRoutes: Readonly> | undefined nextBuildSpan?: Span config: NextConfigComplete buildTraceContext?: BuildTraceContext @@ -642,7 +642,7 @@ export async function collectBuildTraces({ } // Edge routes have no trace files. - if (edgeRoutes && edgeRoutes.includes(route)) { + if (edgeRoutes && route in edgeRoutes) { return } diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index ec14ebfb139c1..7e0077db10b39 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -1946,15 +1946,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 = Array.from( - pageInfos.entries() - ).reduce((acc, [route, { runtime }]) => { - if (runtime === 'edge') { - acc.push(route) - } - - return acc - }, []) + const edgeRoutes: Record = {} + pageInfos.forEach((pageInfo, route) => { + if (pageInfo.runtime !== 'edge') return + edgeRoutes[route] = true + }) buildTracesPromise = collectBuildTraces({ dir,