MCPcopy
hub / github.com/vitejs/vite / assertOutputHashContentChange

Function assertOutputHashContentChange

packages/vite/src/node/__tests__/build.spec.ts:1196–1213  ·  view source on GitHub ↗

* for each chunks in output1, if there's a chunk in output2 with the same fileName, * ensure that the chunk code is the same. if not, the chunk hash should have changed.

(
  output1: RolldownOutput,
  output2: RolldownOutput,
)

Source from the content-addressed store, hash-verified

1194 * ensure that the chunk code is the same. if not, the chunk hash should have changed.
1195 */
1196function assertOutputHashContentChange(
1197 output1: RolldownOutput,
1198 output2: RolldownOutput,
1199) {
1200 for (const chunk of output1.output) {
1201 if (chunk.type === 'chunk') {
1202 const chunk2 = output2.output.find(
1203 (c) => c.type === 'chunk' && c.fileName === chunk.fileName,
1204 ) as OutputChunk | undefined
1205 if (chunk2) {
1206 expect(
1207 chunk.code,
1208 `the ${chunk.fileName} chunk has the same hash but different contents between builds`,
1209 ).toEqual(chunk2.code)
1210 }
1211 }
1212 }
1213}
1214
1215function getOutputHashChanges(
1216 output1: RolldownOutput,

Callers 1

build.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected