feat(core): deprecate custom task runners (#28253)
## Current Behavior <!-- This is the behavior we have today --> Custom task runners are a high level abstraction to customize caching, a relatively low level mechanism, to utilize other methods of remote caching. The abstraction of custom task runners makes it hard for Nx to make guarantees to make it faster. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Custom task runners are now deprecated. They will still work for Nx 20 but a warning will be shown when they are being used. The migration path is to use Nx Cloud (the ideal caching solution) or a Nx Powerpack cache (written by the Nx Core team which we can make guarantees about). ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
81892b51fd
commit
23a217d8dd
@ -270,7 +270,10 @@ Dependencies between different target names across all projects
|
|||||||
|
|
||||||
• `Optional` **tasksRunnerOptions**: `Object`
|
• `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
|
#### Index signature
|
||||||
|
|
||||||
|
|||||||
@ -370,7 +370,10 @@ Dependencies between different target names across all projects
|
|||||||
|
|
||||||
• `Optional` **tasksRunnerOptions**: `Object`
|
• `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
|
#### Index signature
|
||||||
|
|
||||||
|
|||||||
@ -393,7 +393,8 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|||||||
appsDir?: string;
|
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?: {
|
tasksRunnerOptions?: {
|
||||||
[tasksRunnerName: string]: {
|
[tasksRunnerName: string]: {
|
||||||
|
|||||||
@ -790,7 +790,7 @@ export function getRunner(
|
|||||||
runnerOptions: any;
|
runnerOptions: any;
|
||||||
} {
|
} {
|
||||||
let runner = nxArgs.runner;
|
let runner = nxArgs.runner;
|
||||||
runner = runner || 'default';
|
runner = runner ?? 'default';
|
||||||
|
|
||||||
if (runner !== 'default' && !nxJson.tasksRunnerOptions?.[runner]) {
|
if (runner !== 'default' && !nxJson.tasksRunnerOptions?.[runner]) {
|
||||||
throw new Error(`Could not find runner configuration for ${runner}`);
|
throw new Error(`Could not find runner configuration for ${runner}`);
|
||||||
@ -799,6 +799,16 @@ export function getRunner(
|
|||||||
const modulePath: string = getTasksRunnerPath(runner, nxJson);
|
const modulePath: string = getTasksRunnerPath(runner, nxJson);
|
||||||
|
|
||||||
try {
|
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);
|
const tasksRunner = loadTasksRunner(modulePath);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -815,6 +825,8 @@ export function getRunner(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultTasksRunnerPath = require.resolve('./default-tasks-runner');
|
||||||
|
|
||||||
function getTasksRunnerPath(
|
function getTasksRunnerPath(
|
||||||
runner: string,
|
runner: string,
|
||||||
nxJson: NxJsonConfiguration<string[] | '*'>
|
nxJson: NxJsonConfiguration<string[] | '*'>
|
||||||
@ -838,7 +850,7 @@ function getTasksRunnerPath(
|
|||||||
// Nx Cloud ID specified in nxJson
|
// Nx Cloud ID specified in nxJson
|
||||||
nxJson.nxCloudId;
|
nxJson.nxCloudId;
|
||||||
|
|
||||||
return isCloudRunner ? 'nx-cloud' : require.resolve('./default-tasks-runner');
|
return isCloudRunner ? 'nx-cloud' : defaultTasksRunnerPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRunnerOptions(
|
export function getRunnerOptions(
|
||||||
@ -901,3 +913,8 @@ export function getRunnerOptions(
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
function isCustomRunnerPath(modulePath: string) {
|
||||||
|
return !['nx-cloud', '@nrwl/nx-cloud', defaultTasksRunnerPath].includes(
|
||||||
|
modulePath
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@ -14,6 +14,9 @@ export interface RawNxArgs extends NxArgs {
|
|||||||
export interface NxArgs {
|
export interface NxArgs {
|
||||||
targets?: string[];
|
targets?: string[];
|
||||||
configuration?: string;
|
configuration?: string;
|
||||||
|
/**
|
||||||
|
* @deprecated Custom task runners will no longer be supported in Nx 21. Use Nx Cloud or Nx Powerpack instead.
|
||||||
|
*/
|
||||||
runner?: string;
|
runner?: string;
|
||||||
parallel?: number;
|
parallel?: number;
|
||||||
untracked?: boolean;
|
untracked?: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user