-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dependencyOf - the inverse of dependsOn #19414
Comments
the mentioned implementation would transform these targets
to
maybe it would be a useful feature to copy original
|
@AgentEnder @FrozenPandaz I see that you both work on project graph. Can you comment on whether it might be a good idea and PR for it might be merged or it would definitely be rejected? |
Hey, I wouldn't recommend submitting a PR for this just yet. Its not a crazy feature or anything, but its something we will need to discuss internally to decide if its something that we want to support. Anything that could be described by dependencyOf, could after all be described by one or more dependendsOn targets too. |
Maybe I am missing something, but how people handle cases where they simply want to split a target into 2 targets to run them in parallel? ie: if I have setup, build and test targets, and build depends on setup, test depends on build. With dependencyOf feature it can be modeled like this:
then I extract "build-css" into separate task:
then I make "build" a dummy target, that does nothing and extract everything into separate tasks as well:
then I can do the same trick with tests:
with such configuration the last target graph would be translated into this one:
|
Yeah, so you just shown that the proposed |
it's all about what can be added by developers without needing to rewrite their existing targets |
currently if you have a chain of A target depends on B, B depends on C, if you need to insert something in the B layer (imagine the B is the "build" in my example) - you need to rewrite both B and C. with my proposal you can insert B1 without touching neither B, nor C. |
the alternative that potentially can allow doing something like this is to allow dependOn to have wildcards, so that if I define
then I can split "build" to "build-css"+"build-js" without changing that test target. And I can define such additional targets in different plugins, for example. |
@AgentEnder would wildcard/regex target dependencies have more chances to be accepted? |
We're trying to build a CI system with multiple layers of task executions and nx in this case is lacking ability for plugins to add targets dynamically between already defined targets, cause V2 extension points don't allow you to see the "already defined targets for a project". Since v2 plugins were introduced for a reason - I understand that "modifying an already built project graph" is not something nx is willing to support - hence I am trying to find an extension points that could be accepted within "the nx vision". |
I've made an example implementation for wildcards in target dependencies to make it clear what we would like to have. |
@AgentEnder any chance to get at least preliminary response of the PR, please? |
Closing in favor of #19611, but unfortunately it doesn't seem to be interested anyone from core team :( |
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. |
Now it is possible to define targets like this: ``` { "targets": { "build-css": {}, "build-js": {}, "test": { "dependsOn": ["build-*"] }, } } ``` <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior No support for wildcard target dependencies. ## Expected Behavior This PR is an example of what I described here: #19414. ## Related Issue(s) Closes #19414 --------- Co-authored-by: Craigory Coppola <[email protected]>
Now it is possible to define targets like this: ``` { "targets": { "build-css": {}, "build-js": {}, "test": { "dependsOn": ["build-*"] }, } } ``` <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior No support for wildcard target dependencies. ## Expected Behavior This PR is an example of what I described here: #19414. ## Related Issue(s) Closes #19414 --------- Co-authored-by: Craigory Coppola <[email protected]> (cherry picked from commit 3e0d2de)
Description
I'd like to add the
dependencyOf
field to theTargetConfiguration
interface, which would allow users and plugins to add additional targets that would automatically add themselves to other targets'dependsOn
lists.Motivation
Main motivation is to programmatically (in plugins) add targets that would execute before other targets. This would allow to easily implement
preBuild
functionality without needed to modify the existingbuild
target or even know if it exists.Suggested Implementation
The idea is to add a
dependencyOf
field to theTargetConfiguration
and transform such dependencies to thedependsOn
ones on the ProjectGraph creation step, so that everything that works with the ProjectGraph itself would not care about thedependencyOf
and continue to rely only ondependsOn
. It can be done after building full projectGraph here: https://github.com/nrwl/nx/blob/master/packages/nx/src/project-graph/build-project-graph.ts#L196 by iterating over all projects like this:Alternate Implementations
...
The text was updated successfully, but these errors were encountered: