From e302328a4ce3242cbfb7112e856840b7346aa16a Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 4 Jul 2024 21:23:17 +0530 Subject: [PATCH] fix(build): sort pageToHashMap to ensure stable assets closes #4016 --- src/node/build/bundle.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index 6eee911d..bb9c4a72 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -43,7 +43,7 @@ export async function bundle( serverResult: Rollup.RollupOutput pageToHashMap: Record }> { - const pageToHashMap = Object.create(null) + const pageToHashMap = Object.create(null) as Record const clientJSMap = Object.create(null) // define custom rollup input @@ -202,7 +202,15 @@ export async function bundle( } } - return { clientResult, serverResult, pageToHashMap } + // sort pageToHashMap to ensure stable output + const sortedPageToHashMap = Object.create(null) as Record + Object.keys(pageToHashMap) + .sort() + .forEach((key) => { + sortedPageToHashMap[key] = pageToHashMap[key] + }) + + return { clientResult, serverResult, pageToHashMap: sortedPageToHashMap } } const cache = new Map()