Skip to content

Commit

Permalink
fix(build): sort pageToHashMap to ensure stable assets
Browse files Browse the repository at this point in the history
closes #4016
  • Loading branch information
brc-dd committed Jul 4, 2024
1 parent f3ee906 commit e302328
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/node/build/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function bundle(
serverResult: Rollup.RollupOutput
pageToHashMap: Record<string, string>
}> {
const pageToHashMap = Object.create(null)
const pageToHashMap = Object.create(null) as Record<string, string>
const clientJSMap = Object.create(null)

// define custom rollup input
Expand Down Expand Up @@ -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<string, string>
Object.keys(pageToHashMap)
.sort()
.forEach((key) => {
sortedPageToHashMap[key] = pageToHashMap[key]
})

return { clientResult, serverResult, pageToHashMap: sortedPageToHashMap }
}

const cache = new Map<string, boolean>()
Expand Down

0 comments on commit e302328

Please sign in to comment.