From 0bea5b28e634efe4ce8c88ee60b78b23de2513ee Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Wed, 23 Oct 2024 21:25:02 -0400 Subject: [PATCH] fix(core): createTaskGraph should accept extraTargetDependencies (#28542) this pr is a follow up to https://github.com/nrwl/nx/pull/26033. for function `createTaskGraph`, it should not accept `defaultDependencyConfigs`, it should be `extraTargetDependencies`. ## Current Behavior this caused an issue where the task graph shows that 2 tasks depend on each other; however, when actually running, it does not. ## Expected Behavior ## Related Issue(s) Fixes https://github.com/nrwl/nx/issues/26929 --- packages/nx/src/command-line/graph/graph.ts | 29 +++++---------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/packages/nx/src/command-line/graph/graph.ts b/packages/nx/src/command-line/graph/graph.ts index 0adf86f871c9e..e355d7d137682 100644 --- a/packages/nx/src/command-line/graph/graph.ts +++ b/packages/nx/src/command-line/graph/graph.ts @@ -44,13 +44,9 @@ import { createProjectGraphAsync, handleProjectGraphError, } from '../../project-graph/project-graph'; -import { - createTaskGraph, - mapTargetDefaultsToDependencies, -} from '../../tasks-runner/create-task-graph'; +import { createTaskGraph } from '../../tasks-runner/create-task-graph'; import { allFileData } from '../../utils/all-file-data'; import { splitArgsIntoNxArgsAndOverrides } from '../../utils/command-line-utils'; -import { NxJsonConfiguration } from '../../config/nx-json'; import { HashPlanner, transferProjectGraph } from '../../native'; import { transformProjectGraphForRust } from '../../native/transform-objects'; import { getAffectedGraphNodes } from '../affected/affected'; @@ -887,7 +883,7 @@ async function createTaskGraphClientResponse( const nxJson = readNxJson(); performance.mark('task graph generation:start'); - const taskGraphs = getAllTaskGraphsForWorkspace(nxJson, graph); + const taskGraphs = getAllTaskGraphsForWorkspace(graph); performance.mark('task graph generation:end'); const planner = new HashPlanner( @@ -957,17 +953,10 @@ async function createExpandedTaskInputResponse( return response; } -function getAllTaskGraphsForWorkspace( - nxJson: NxJsonConfiguration, - projectGraph: ProjectGraph -): { +function getAllTaskGraphsForWorkspace(projectGraph: ProjectGraph): { taskGraphs: Record; errors: Record; } { - const defaultDependencyConfigs = mapTargetDefaultsToDependencies( - nxJson.targetDefaults - ); - const taskGraphs: Record = {}; const taskGraphErrors: Record = {}; @@ -981,7 +970,7 @@ function getAllTaskGraphsForWorkspace( try { taskGraphs[taskId] = createTaskGraph( projectGraph, - defaultDependencyConfigs, + {}, [projectName], [target], undefined, @@ -1007,7 +996,7 @@ function getAllTaskGraphsForWorkspace( try { taskGraphs[taskId] = createTaskGraph( projectGraph, - defaultDependencyConfigs, + {}, [projectName], [target], configuration, @@ -1221,15 +1210,9 @@ async function createJsonOutput( }; if (targets?.length) { - const nxJson = readNxJson(); - - const defaultDependencyConfigs = mapTargetDefaultsToDependencies( - nxJson.targetDefaults - ); - const taskGraph = createTaskGraph( rawGraph, - defaultDependencyConfigs, + {}, projects, targets, undefined,