feat(core): allow specifying cacheability per target (#19672)
This commit is contained in:
parent
7d095d59ad
commit
2a18fd1f3f
@ -12,6 +12,7 @@ Target's configuration
|
||||
|
||||
### Properties
|
||||
|
||||
- [cache](../../devkit/documents/TargetConfiguration#cache): boolean
|
||||
- [command](../../devkit/documents/TargetConfiguration#command): string
|
||||
- [configurations](../../devkit/documents/TargetConfiguration#configurations): Object
|
||||
- [defaultConfiguration](../../devkit/documents/TargetConfiguration#defaultconfiguration): string
|
||||
@ -23,6 +24,14 @@ Target's configuration
|
||||
|
||||
## Properties
|
||||
|
||||
### cache
|
||||
|
||||
• `Optional` **cache**: `boolean`
|
||||
|
||||
Determines if Nx is able to cache a given target.
|
||||
|
||||
---
|
||||
|
||||
### command
|
||||
|
||||
• `Optional` **command**: `string`
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
# Type alias: TargetDefaults
|
||||
|
||||
Ƭ **TargetDefaults**: `Record`<`string`, `Partial`<[`TargetConfiguration`](../../devkit/documents/TargetConfiguration)\> & { `cache?`: `boolean` }\>
|
||||
Ƭ **TargetDefaults**: `Record`<`string`, `Partial`<[`TargetConfiguration`](../../devkit/documents/TargetConfiguration)\>\>
|
||||
|
||||
@ -108,6 +108,10 @@
|
||||
"command": {
|
||||
"type": "string",
|
||||
"description": "A shorthand for using the nx:run-commands executor"
|
||||
},
|
||||
"cache": {
|
||||
"type": "boolean",
|
||||
"description": "Specifies if the given target should be cacheable"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,6 +118,10 @@
|
||||
"command": {
|
||||
"type": "string",
|
||||
"description": "A shorthand for using the nx:run-commands executor"
|
||||
},
|
||||
"cache": {
|
||||
"type": "boolean",
|
||||
"description": "Specifies if the given target should be cacheable"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,16 +25,7 @@ export interface NxAffectedConfig {
|
||||
defaultBase?: string;
|
||||
}
|
||||
|
||||
export type TargetDefaults = Record<
|
||||
string,
|
||||
Partial<TargetConfiguration> & {
|
||||
/**
|
||||
* Determines if Nx is able to cache a given target.
|
||||
* Currently only supported in `targetDefaults`.
|
||||
*/
|
||||
cache?: boolean;
|
||||
}
|
||||
>;
|
||||
export type TargetDefaults = Record<string, Partial<TargetConfiguration>>;
|
||||
|
||||
export type TargetDependencies = Record<
|
||||
string,
|
||||
|
||||
@ -181,4 +181,9 @@ export interface TargetConfiguration<T = any> {
|
||||
* A default named configuration to use when a target configuration is not provided.
|
||||
*/
|
||||
defaultConfiguration?: string;
|
||||
|
||||
/**
|
||||
* Determines if Nx is able to cache a given target.
|
||||
*/
|
||||
cache?: boolean;
|
||||
}
|
||||
|
||||
@ -352,11 +352,7 @@ export function isCacheableTask(
|
||||
cacheableTargets?: string[] | null;
|
||||
}
|
||||
): boolean {
|
||||
if (
|
||||
task.cache !== undefined &&
|
||||
process.env.NX_ALLOW_PROJECT_LEVEL_CACHE === 'true' &&
|
||||
!longRunningTask(task)
|
||||
) {
|
||||
if (task.cache !== undefined && !longRunningTask(task)) {
|
||||
return task.cache;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user