Force [hash] in Bun chunk naming so older Bun versions don't collide

Cloudflare Pages ships an older Bun than the one used locally. That
version emits shared CSS chunks via the default 'chunk-[hash]' naming
template, but the [hash] token isn't always populated when the chunk
is shared across multiple HTML entrypoints — every sub-page that
imports sub-pages.css ends up wanting the same './chunk-' filename
and the build aborts with 'Multiple files share the same output path'.

Pin the chunk and asset naming explicitly so [hash] is always present
regardless of Bun version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-04-08 14:17:38 -07:00
co-authored by Claude Opus 4.6
parent adcca35b03
commit 8f05b9bfa5
+10
View File
@@ -298,6 +298,16 @@ async function buildStaticSite(extraEntrypoints = []) {
outdir: outdir,
minify: true,
sourcemap: 'linked',
// Older Bun versions (e.g. the one Cloudflare Pages ships) emit shared
// CSS/JS chunks without a content hash in the filename, which collides
// when multiple HTML entries import the same CSS partial. Force the
// chunk + asset naming to always include [hash] so the build is
// reproducible across Bun versions.
naming: {
entry: '[dir]/[name].[ext]',
chunk: '[name]-[hash].[ext]',
asset: '[name]-[hash].[ext]',
},
});
if (!result.success) {