Unverified Commit feb594bd authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: use same hash for immutable-static-hashes.json (#92157)

parent 6a204593
...@@ -142,7 +142,7 @@ impl Asset for AssetHashesManifestAsset { ...@@ -142,7 +142,7 @@ impl Asset for AssetHashesManifestAsset {
.map(async |(asset, path)| { .map(async |(asset, path)| {
Ok(( Ok((
path, path,
asset.content_hash(HashAlgorithm::Xxh3Hash128Hex).await?, asset.content_hash(HashAlgorithm::Xxh3Hash128Base38).await?,
)) ))
}) })
.try_join() .try_join()
......
import fs from 'fs/promises'
/** @type {import('next').NextAdapter } */
export default {
name: 'deployment-id-handling',
async onBuildComplete(ctx) {
await fs.writeFile('build-complete.json', JSON.stringify(ctx, null, 2))
},
}
...@@ -9,4 +9,6 @@ module.exports = { ...@@ -9,4 +9,6 @@ module.exports = {
? `imm-${process.env.IMMUTABLE_ASSET_TOKEN}` ? `imm-${process.env.IMMUTABLE_ASSET_TOKEN}`
: undefined, : undefined,
}, },
adapterPath:
process.env.NEXT_ADAPTER_PATH ?? require.resolve('./my-adapter.mjs'),
} }
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { NextAdapter } from 'next'
import { retry } from 'next-test-utils' import { retry } from 'next-test-utils'
import { join } from 'node:path' import { join } from 'node:path'
...@@ -182,6 +183,29 @@ describe.each([ ...@@ -182,6 +183,29 @@ describe.each([
(headers) => headers['x-deployment-id'] === deploymentId (headers) => headers['x-deployment-id'] === deploymentId
) )
}) })
if (envKey === 'IMMUTABLE_ASSET_TOKEN') {
it('should emit hashes to adapter', async () => {
const { outputs }: Parameters<NextAdapter['onBuildComplete']>[0] =
await next.readJSON('build-complete.json')
const immutableAssets = outputs.staticFiles.filter(
(a) =>
a.pathname.startsWith('/_next/static/') &&
!(
a.pathname.endsWith('/_buildManifest.js') ||
a.pathname.endsWith('/_clientMiddlewareManifest.js') ||
a.pathname.endsWith('/_ssgManifest.js')
)
)
expect(immutableAssets).not.toBeEmpty()
expect(immutableAssets).toSatisfyAll(
(f) =>
// Should be same hash as in the filename, for better build performance
f.immutableHash && f.pathname.includes(f.immutableHash.slice(0, 13))
)
})
}
} }
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment