nx
nx copied to clipboard
Allow targetDefaults dependsOn to specify a package
- [x] I'd be willing to implement this feature (contributing guide)
Description
I would like running a target to implicitly rely on a different target of a specific package
Motivation
Example use case: I have an eslint plugin which I consume from the workspace. Running lint
on any other package should require the plugin to be built
Suggested Implementation
Allow the targetDefaults dependsOn "package" property to be a package name instead of self
or dependencies
Alternate Implementations
- (No change to Nx) Setting up an implicit dependency for every other package (though this wouldn't limit it to just the lint target)
- (No change to Nx) Abusing inputs to also include inputs from the other package
- Somehow using the global implicit dependencies to specify the same thing instead of targetDefaults
That would be very useful.
A good use case for this one is when you only need to build some custom executor implementation that is used within the project.
Another alternative would be to allow the user to create dependency "groups".
For example:
(project.json)
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/project-1",
"projectType": "application",
"targets": {
"my-target": {
"executor": "my-executor",
"options": {},
"dependsOn": [
{
"projects": [
"project-2",
"project-3"
],
"target": "build"
}
]
}
}
}
Also a shorthand syntax would be nice:
{
"dependsOn": ["project-2:build", "project-3:build"]
}
@AgentEnder Should this be linked to #16100? (That PR was linked to itself)
Ah, yeah it should have been. Thanks.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.