From 786e6b18c91a8d693a9c6dd9b8f1e8d867e6ae52 Mon Sep 17 00:00:00 2001 From: ocavue Date: Thu, 16 Apr 2026 15:19:26 +1000 Subject: [PATCH 1/3] fix: stabilize client build output filenames across runs --- .changeset/deterministic-client-build.md | 5 +++++ packages/astro/src/core/build/static-build.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changeset/deterministic-client-build.md diff --git a/.changeset/deterministic-client-build.md b/.changeset/deterministic-client-build.md new file mode 100644 index 000000000000..215fee0af873 --- /dev/null +++ b/.changeset/deterministic-client-build.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes non-deterministic client build output by sorting entry points before passing them to Rollup. Previously, consecutive builds of the same source code could produce different output filenames, breaking CDN caching. diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index a95321d2322e..97112de36244 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -371,9 +371,12 @@ async function buildEnvironments(opts: StaticBuildOptions, internals: BuildInter // So using the noop plugin here which will give us an input that just gets thrown away. internals.clientInput.add(NOOP_MODULE_ID); } - builder.environments.client.config.build.rollupOptions.input = Array.from( - internals.clientInput, - ); + // Sort the client input to ensure deterministic Rollup entry point ordering. + // `internals.clientInput` is a Set whose iteration order depends on async module resolution + // timing during prerendering. Without sorting, consecutive builds of the same + // source code can produce different output filenames, breaking CDN caching. + const sortedClientInput = Array.from(internals.clientInput).sort(); + builder.environments.client.config.build.rollupOptions.input = sortedClientInput; settings.timer.start('Client build'); await builder.build(builder.environments.client); settings.timer.end('Client build'); From d1c5bac947d0903cba6ca266072c68bf9969d13c Mon Sep 17 00:00:00 2001 From: ocavue Date: Thu, 16 Apr 2026 16:28:32 +1000 Subject: [PATCH 2/3] update changeset --- .changeset/deterministic-client-build.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/deterministic-client-build.md b/.changeset/deterministic-client-build.md index 215fee0af873..316e9d94f42f 100644 --- a/.changeset/deterministic-client-build.md +++ b/.changeset/deterministic-client-build.md @@ -2,4 +2,4 @@ 'astro': patch --- -Fixes non-deterministic client build output by sorting entry points before passing them to Rollup. Previously, consecutive builds of the same source code could produce different output filenames, breaking CDN caching. +Sort client build entry points for consistent Rollup chunk ordering. This prevents unnecessary output filename changes between builds. From 7fce82bea0e6174bffe8b6c0072fa627ea936274 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 16 Apr 2026 13:26:43 +0100 Subject: [PATCH 3/3] Update .changeset/deterministic-client-build.md --- .changeset/deterministic-client-build.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/deterministic-client-build.md b/.changeset/deterministic-client-build.md index 316e9d94f42f..8ab67911befe 100644 --- a/.changeset/deterministic-client-build.md +++ b/.changeset/deterministic-client-build.md @@ -2,4 +2,4 @@ 'astro': patch --- -Sort client build entry points for consistent Rollup chunk ordering. This prevents unnecessary output filename changes between builds. +Fixes a bug where emitted assets during a client build would contain always fresh, new hashes in their name. Now the build should be more stable.