diff --git a/docs/generated/devkit/NxJsonConfiguration.md b/docs/generated/devkit/NxJsonConfiguration.md index 93d50df8a5..c7efdc6cdb 100644 --- a/docs/generated/devkit/NxJsonConfiguration.md +++ b/docs/generated/devkit/NxJsonConfiguration.md @@ -270,7 +270,10 @@ Dependencies between different target names across all projects • `Optional` **tasksRunnerOptions**: `Object` -Available Task Runners +**`Deprecated`** + +Custom task runners will no longer be supported in Nx 21. Use Nx Cloud or Nx Powerpack instead. +Available Task Runners for Nx to use #### Index signature diff --git a/docs/generated/devkit/Workspace.md b/docs/generated/devkit/Workspace.md index 1778f5ba0a..78fbb58467 100644 --- a/docs/generated/devkit/Workspace.md +++ b/docs/generated/devkit/Workspace.md @@ -370,7 +370,10 @@ Dependencies between different target names across all projects • `Optional` **tasksRunnerOptions**: `Object` -Available Task Runners +**`Deprecated`** + +Custom task runners will no longer be supported in Nx 21. Use Nx Cloud or Nx Powerpack instead. +Available Task Runners for Nx to use #### Index signature diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts index 4848d417d8..65f789572e 100644 --- a/packages/nx/src/config/nx-json.ts +++ b/packages/nx/src/config/nx-json.ts @@ -393,7 +393,8 @@ export interface NxJsonConfiguration { appsDir?: string; }; /** - * Available Task Runners + * @deprecated Custom task runners will no longer be supported in Nx 21. Use Nx Cloud or Nx Powerpack instead. + * Available Task Runners for Nx to use */ tasksRunnerOptions?: { [tasksRunnerName: string]: { diff --git a/packages/nx/src/tasks-runner/run-command.ts b/packages/nx/src/tasks-runner/run-command.ts index a94c275afe..019b307c10 100644 --- a/packages/nx/src/tasks-runner/run-command.ts +++ b/packages/nx/src/tasks-runner/run-command.ts @@ -790,7 +790,7 @@ export function getRunner( runnerOptions: any; } { let runner = nxArgs.runner; - runner = runner || 'default'; + runner = runner ?? 'default'; if (runner !== 'default' && !nxJson.tasksRunnerOptions?.[runner]) { throw new Error(`Could not find runner configuration for ${runner}`); @@ -799,6 +799,16 @@ export function getRunner( const modulePath: string = getTasksRunnerPath(runner, nxJson); try { + if (isCustomRunnerPath(modulePath)) { + output.warn({ + title: `Custom task runners will no longer be supported in Nx 21.`, + bodyLines: [ + `Use Nx Cloud or the Nx Powerpack caches instead.`, + `For more information, see https://nx.dev/features/powerpack/custom-caching`, + ], + }); + } + const tasksRunner = loadTasksRunner(modulePath); return { @@ -815,6 +825,8 @@ export function getRunner( } } +const defaultTasksRunnerPath = require.resolve('./default-tasks-runner'); + function getTasksRunnerPath( runner: string, nxJson: NxJsonConfiguration @@ -838,7 +850,7 @@ function getTasksRunnerPath( // Nx Cloud ID specified in nxJson nxJson.nxCloudId; - return isCloudRunner ? 'nx-cloud' : require.resolve('./default-tasks-runner'); + return isCloudRunner ? 'nx-cloud' : defaultTasksRunnerPath; } export function getRunnerOptions( @@ -901,3 +913,8 @@ export function getRunnerOptions( return result; } +function isCustomRunnerPath(modulePath: string) { + return !['nx-cloud', '@nrwl/nx-cloud', defaultTasksRunnerPath].includes( + modulePath + ); +} diff --git a/packages/nx/src/utils/command-line-utils.ts b/packages/nx/src/utils/command-line-utils.ts index 4689468824..19a83feb79 100644 --- a/packages/nx/src/utils/command-line-utils.ts +++ b/packages/nx/src/utils/command-line-utils.ts @@ -14,6 +14,9 @@ export interface RawNxArgs extends NxArgs { export interface NxArgs { targets?: string[]; configuration?: string; + /** + * @deprecated Custom task runners will no longer be supported in Nx 21. Use Nx Cloud or Nx Powerpack instead. + */ runner?: string; parallel?: number; untracked?: boolean;