From 83531de53959b267771fae59a3989fb40dd1742a Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Wed, 1 Nov 2023 13:47:56 -0400 Subject: [PATCH] fix(core): ensure project order in graph is deterministic (#19968) (cherry picked from commit c83afeb260b1ac019d83ec1a4b37dcf9db526727) --- .../nx/src/project-graph/utils/normalize-project-nodes.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nx/src/project-graph/utils/normalize-project-nodes.ts b/packages/nx/src/project-graph/utils/normalize-project-nodes.ts index ff9eba7608591..ac48f5e8a709d 100644 --- a/packages/nx/src/project-graph/utils/normalize-project-nodes.ts +++ b/packages/nx/src/project-graph/utils/normalize-project-nodes.ts @@ -23,7 +23,10 @@ export async function normalizeProjectNodes( nxJson: NxJsonConfiguration ) { const toAdd = []; - const projects = Object.keys(ctx.projects); + // Sorting projects by name to make sure that the order of projects in the graph is deterministic. + // This is important to ensure that expanded properties referencing projects (e.g. implicit dependencies) + // are also deterministic, and thus don't cause the calculated project configuration hash to shift. + const projects = Object.keys(ctx.projects).sort(); // Used for expanding implicit dependencies (e.g. `@proj/*` or `tag:foo`) const partialProjectGraphNodes = projects.reduce((graph, project) => {