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
|
### Properties
|
||||||
|
|
||||||
|
- [cache](../../devkit/documents/TargetConfiguration#cache): boolean
|
||||||
- [command](../../devkit/documents/TargetConfiguration#command): string
|
- [command](../../devkit/documents/TargetConfiguration#command): string
|
||||||
- [configurations](../../devkit/documents/TargetConfiguration#configurations): Object
|
- [configurations](../../devkit/documents/TargetConfiguration#configurations): Object
|
||||||
- [defaultConfiguration](../../devkit/documents/TargetConfiguration#defaultconfiguration): string
|
- [defaultConfiguration](../../devkit/documents/TargetConfiguration#defaultconfiguration): string
|
||||||
@ -23,6 +24,14 @@ Target's configuration
|
|||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
|
### cache
|
||||||
|
|
||||||
|
• `Optional` **cache**: `boolean`
|
||||||
|
|
||||||
|
Determines if Nx is able to cache a given target.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### command
|
### command
|
||||||
|
|
||||||
• `Optional` **command**: `string`
|
• `Optional` **command**: `string`
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
# Type alias: TargetDefaults
|
# 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": {
|
"command": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "A shorthand for using the nx:run-commands executor"
|
"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": {
|
"command": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "A shorthand for using the nx:run-commands executor"
|
"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;
|
defaultBase?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TargetDefaults = Record<
|
export type TargetDefaults = Record<string, Partial<TargetConfiguration>>;
|
||||||
string,
|
|
||||||
Partial<TargetConfiguration> & {
|
|
||||||
/**
|
|
||||||
* Determines if Nx is able to cache a given target.
|
|
||||||
* Currently only supported in `targetDefaults`.
|
|
||||||
*/
|
|
||||||
cache?: boolean;
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type TargetDependencies = Record<
|
export type TargetDependencies = Record<
|
||||||
string,
|
string,
|
||||||
|
|||||||
@ -181,4 +181,9 @@ export interface TargetConfiguration<T = any> {
|
|||||||
* A default named configuration to use when a target configuration is not provided.
|
* A default named configuration to use when a target configuration is not provided.
|
||||||
*/
|
*/
|
||||||
defaultConfiguration?: string;
|
defaultConfiguration?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if Nx is able to cache a given target.
|
||||||
|
*/
|
||||||
|
cache?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -352,11 +352,7 @@ export function isCacheableTask(
|
|||||||
cacheableTargets?: string[] | null;
|
cacheableTargets?: string[] | null;
|
||||||
}
|
}
|
||||||
): boolean {
|
): boolean {
|
||||||
if (
|
if (task.cache !== undefined && !longRunningTask(task)) {
|
||||||
task.cache !== undefined &&
|
|
||||||
process.env.NX_ALLOW_PROJECT_LEVEL_CACHE === 'true' &&
|
|
||||||
!longRunningTask(task)
|
|
||||||
) {
|
|
||||||
return task.cache;
|
return task.cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user