fix(core): all graph nodes should have targets block, even if its empty #18625
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
After #18032 project nodes on the graph may not have a
targets
block. We've always supported projects having undefined targets in generators when a project is defined by package.json or similar, but once they are in the graph they have generally had the targets block. This was a result of themergePluginTargets
function which assigned targets from nx plugin'sregisterProjectTargets
method.In #18032 we removed that method entirely, and didn't notice that it was essentially doing
node.data.targets ??= {}
.In our own code, this resulted in
nx graph
failing when it tried to build the task graphs for the UI to display but it would not be unrealistic to say that there would be other cases that this would crop up in the Nx codebase or user's custom scripts.Expected Behavior
Project nodes have a
targets
block, even if it may be empty and allcreateNodes
functions returned undefined targets.Related Issue(s)
Fixes #