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/silver-lions-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/start-plugin-core': patch
---

Sort server function manifest entries by ID before emitting the resolver module. The `serverFnsById` map is populated in source-file scan order, which varies across machines and incremental builds, producing non-deterministic key ordering in the emitted `__tanstack-start-server-fn-resolver-*.mjs` artifact. Stable alphabetic sorting ensures reproducible builds, consistent content hashes, and clean `git diff` on committed artifacts.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ interface GenerateServerFnResolverModuleOptions {
function getResolverManifestEntries(
serverFnsById: Record<string, ServerFn>,
): Array<ResolverManifestEntry> {
return Object.entries(serverFnsById).map(([id, fn]) => ({
id,
functionName: fn.functionName,
extractedFilename: fn.extractedFilename,
isClientReferenced: fn.isClientReferenced ?? true,
}))
return (
Object.entries(serverFnsById)
// Sort entries by ID so that the generated manifest has a stable, deterministic order.
// Non-deterministic ordering causes the compiled hash of the same source file to change
// between builds, breaking content-addressed caching and reproducible deployments.
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
.map(([id, fn]) => ({
id,
functionName: fn.functionName,
extractedFilename: fn.extractedFilename,
isClientReferenced: fn.isClientReferenced ?? true,
}))
)
}

function getClientReferencedCheck(
Expand Down