Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/deterministic-client-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

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.
9 changes: 6 additions & 3 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading