diff --git a/packages/nx/src/project-graph/build-nodes/workspace-projects.spec.ts b/packages/nx/src/project-graph/build-nodes/workspace-projects.spec.ts index 8687e8df7621c..94f1bf2f3f843 100644 --- a/packages/nx/src/project-graph/build-nodes/workspace-projects.spec.ts +++ b/packages/nx/src/project-graph/build-nodes/workspace-projects.spec.ts @@ -312,6 +312,32 @@ describe('workspace-projects', () => { ).toEqual({ a: 'a', b: 'my/project' }); }); + it('should merge options when targets use executors with defaults', () => { + expect( + normalizeProjectTargets( + { + root: 'my/project', + targets: { + build: { + executor: '@nx/jest:jest', + options: { + a: 'a', + }, + }, + }, + }, + { + '@nx/jest:jest': { + options: { + b: 'b', + }, + }, + }, + 'build' + ).build.options + ).toEqual({ a: 'a', b: 'b' }); + }); + it('should not merge options when targets use different executors', () => { expect( normalizeProjectTargets( diff --git a/packages/nx/src/project-graph/build-nodes/workspace-projects.ts b/packages/nx/src/project-graph/build-nodes/workspace-projects.ts index 62f4a92389a4c..5b6f7cff71b1f 100644 --- a/packages/nx/src/project-graph/build-nodes/workspace-projects.ts +++ b/packages/nx/src/project-graph/build-nodes/workspace-projects.ts @@ -134,9 +134,8 @@ export function normalizeProjectTargets( // We need to know the executor for use in readTargetDefaultsForTarget, // but we haven't resolved the `command` syntactic sugar yet. const executor = - targets[target].executor ?? targets[target].command - ? 'nx:run-commands' - : null; + targets[target].executor ?? + (targets[target].command ? 'nx:run-commands' : null); // Allows things like { targetDefaults: { build: { command: tsc } } } const defaults = resolveCommandSyntacticSugar(