From ce90c636232177ece4b0854c0d311d1ab2704f12 Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Fri, 11 Feb 2022 14:25:15 -0800 Subject: [PATCH 1/2] test always using all pages --- packages/gatsby/src/utils/node-manifest.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/node-manifest.ts b/packages/gatsby/src/utils/node-manifest.ts index 1781f2ae4caee..7b911e84a10f9 100644 --- a/packages/gatsby/src/utils/node-manifest.ts +++ b/packages/gatsby/src/utils/node-manifest.ts @@ -61,7 +61,8 @@ async function findPageOwnedByNode({ // but for builds (preview inc builds or regular builds) we will have a full map // of all nodeId's to pages they're queried on and we can use that instead since it // will be a much smaller list of pages, resulting in better performance for large sites - const usingPagesMap: boolean = `development` === process.env.NODE_ENV + const usingPagesMap = true + // const usingPagesMap: boolean = `development` === process.env.NODE_ENV const pagePathSetOrMap = usingPagesMap ? // this is a Map of page path to page node From a086f549570b9ff5a67044c38f7a57528c8c897f Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Fri, 11 Feb 2022 14:43:21 -0800 Subject: [PATCH 2/2] dsg fix --- packages/gatsby/src/utils/node-manifest.ts | 27 +++------------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/packages/gatsby/src/utils/node-manifest.ts b/packages/gatsby/src/utils/node-manifest.ts index 7b911e84a10f9..6249a7eef055f 100644 --- a/packages/gatsby/src/utils/node-manifest.ts +++ b/packages/gatsby/src/utils/node-manifest.ts @@ -56,33 +56,18 @@ async function findPageOwnedByNode({ const { pages, nodes } = state const { byNode } = state.queries - // in development queries are run on demand so we wont have an accurate nodeId->pages map until those pages are visited in the browser. We want this mapping before the page is visited in the browser so we can route to the right page in the browser. - // So in development we can just use the Map of all pages (pagePath -> pageNode) - // but for builds (preview inc builds or regular builds) we will have a full map - // of all nodeId's to pages they're queried on and we can use that instead since it - // will be a much smaller list of pages, resulting in better performance for large sites - const usingPagesMap = true - // const usingPagesMap: boolean = `development` === process.env.NODE_ENV - - const pagePathSetOrMap = usingPagesMap - ? // this is a Map of page path to page node - pages - : // this is a Set of page paths - byNode?.get(nodeId) - // the default page path is the first page found in // node id to page query tracking - let pagePath = byNode?.get(nodeId)?.values()?.next()?.value let foundPageBy: FoundPageBy = pagePath ? `queryTracking` : `none` - if (pagePathSetOrMap) { + if (pages) { let ownerPagePath: string | undefined let foundOwnerNodeId = false // for each page this nodeId is queried in - for (const pathOrPageObject of pagePathSetOrMap.values()) { + for (const pageObject of pages.values()) { // if we haven't found a page with this nodeId // set as page.ownerNodeId then run this logic. // this condition is on foundOwnerNodeId instead of ownerPagePath @@ -94,13 +79,7 @@ async function findPageOwnedByNode({ break } - const path = ( - usingPagesMap - ? // in development we're using a Map, so the value here is a page object - (pathOrPageObject as IGatsbyPage).path - : // in builds we're using a Set so the page path is the value - pathOrPageObject - ) as string + const path = pageObject.path const fullPage: IGatsbyPage | undefined = pages.get(path)