fix(core): resolve input files for targets with defaultConfiguration#34638
fix(core): resolve input files for targets with defaultConfiguration#34638
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
| const targetConfig = graph.nodes[projectName]?.data?.targets?.[targetName]; | ||
| const defaultConfig = targetConfig?.defaultConfiguration; | ||
| const taskId = defaultConfig | ||
| ? `${projectName}:${targetName}:${defaultConfig}` |
There was a problem hiding this comment.
@copilot this should respect the passed in configuration prop if available. We should also throw if the config isnt in the inspected hash plan instead of silently passing
There was a problem hiding this comment.
Done in f12f6f7. The resolveInputFiles function now:
- Prefers the explicitly passed
configurationoverdefaultConfiguration:const effectiveConfig = configuration ?? targetConfig?.defaultConfiguration; - Throws if the task ID is not found in the hash plan instead of silently returning empty defaults
Also updated showTargetInputsHandler to extract the configuration from the target string (project:target:config) or the -c flag and forward it to resolveInputFiles.
Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
View your CI Pipeline Execution ↗ for commit eb56670
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
✅ The fix from Nx Cloud was applied automatically
We've applied Prettier formatting to resolve the format:check failure in target.ts. The formatter adjusted the line wrapping of the destructuring assignment to comply with the project's code style guidelines, ensuring the changes from the defaultConfiguration fix meet formatting standards.
Tip
✅ We verified this fix by re-running nx-cloud record -- nx format:check.
Suggested Fix changes
diff --git a/packages/nx/src/command-line/show/target.ts b/packages/nx/src/command-line/show/target.ts
index 631f7fc3eb..f3d0feca10 100644
--- a/packages/nx/src/command-line/show/target.ts
+++ b/packages/nx/src/command-line/show/target.ts
@@ -73,11 +73,8 @@ export async function showTargetInputsHandler(
const graph = await createProjectGraphAsync();
const nxJson = readNxJson();
- const { projectName, targetName, configurationName } = resolveTargetIdentifier(
- args,
- graph,
- nxJson
- );
+ const { projectName, targetName, configurationName } =
+ resolveTargetIdentifier(args, graph, nxJson);
const node = resolveProjectNode(projectName, graph);
const targetConfig = node.data.targets?.[targetName];
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
View interactive diff ↗🎓 Learn more about Self-Healing CI on nx.dev
Co-authored-by: Copilot <Copilot@users.noreply.github.com>
nx show target inputsreturns empty results for any target withdefaultConfigurationset becauseHashPlanInspector.inspectTaskInputs()keys results asproject:target:config(e.g.my-app:build:local), but the lookup was usingproject:target— a guaranteed miss.Changes
packages/nx/src/command-line/show/target.ts: InresolveInputFiles, construct the plan lookup key using the explicitly passedconfigurationfirst, then fall back to the target'sdefaultConfiguration:If the computed
taskIdis not found in the hash plan, an error is thrown instead of silently returning empty results.showTargetInputsHandler: Now extracts the configuration from the target string (project:target:config) or the-c/--configurationflag and forwards it toresolveInputFiles.ShowTargetInputsOptions(command-object.ts): Addedconfiguration?: stringso the type correctly reflects the prop.packages/nx/src/command-line/show/target.spec.ts: Added tests covering:defaultConfigurationis setconfigurationoverdefaultConfigurationOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.