-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(core): add dependents property for reverse dependency execution #33389
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
Open
seriouscoderone
wants to merge
6
commits into
nrwl:master
Choose a base branch
from
seriouscoderone:feat/reverse-dependency-execution
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(core): add dependents property for reverse dependency execution #33389
seriouscoderone
wants to merge
6
commits into
nrwl:master
from
seriouscoderone:feat/reverse-dependency-execution
+574
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements reverse dependency graph execution (leaves-first) to support use cases
like AWS CloudFormation and Pulumi stack destruction where dependent resources
must be removed before their dependencies.
- Add dependents?: boolean property to TargetDependencyConfig interface
- Implement processTasksForDependents() using reverse() from project-graph/operators
- Add validation to ensure projects, dependencies, and dependents are mutually exclusive
- Add comprehensive unit tests for reverse dependency scenarios
Usage:
{
"targetDefaults": {
"destroy": {
"dependsOn": [{"target": "destroy", "dependents": true}]
}
}
}
This enables critical infrastructure-as-code teardown workflows where stacks
must be destroyed in reverse dependency order.
Addresses nrwl#9322
🤖 Generated with Claude Code (https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Author
|
@leosvelperez It's a relatively small PR. Let me know your thoughts. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current Behavior
Currently, Nx only supports forward dependency execution where dependencies must be built/executed before their dependents. For example, if
appdepends onlib, thebuildtarget runslib:buildbeforeapp:build.There's no built-in way to execute tasks in reverse dependency order (leaves-first), which is critical for infrastructure-as-code teardown workflows.
Expected Behavior
With this PR, users can now configure targets to run in reverse dependency order using the
dependents: trueproperty inTargetDependencyConfig.Usage Example:
{ "targetDefaults": { "destroy": { "dependsOn": [{"target": "destroy", "dependents": true}] } } }When destroying infrastructure, dependent resources (e.g., AWS CloudFormation stacks that import values) must be removed before their dependencies.
Related Issue(s)
Fixes #9322
Implementation Details
Changes Made:
Type Definition (
workspace-json-project-json.ts):dependents?: booleanproperty toTargetDependencyConfiginterfaceprojectsanddependenciesConfiguration Utilities (
utils.ts):projects,dependencies, anddependentsare mutually exclusiveexpandWildcardTargetConfiguration()to preservedependentspropertyTask Graph Creation (
create-task-graph.ts):processTasksForDependents()using the existingreverse()function fromproject-graph/operatorsprocessTasksForDependencies()logicComprehensive Tests:
Key Design Decisions:
reverse()function from devkit instead of implementing custom reverse traversal logicdependencies: trueUse Cases:
Fn::ImportValuedependencies must be destroyed in reverse order🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]