-
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
fix(js): properly identify buildable project #17798
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 1306531. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
0f0c813
to
727f230
Compare
727f230
to
692aecc
Compare
692aecc
to
0c97247
Compare
0c97247
to
8d7798b
Compare
8d7798b
to
3bbd80a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to consider is that while this addresses the issue for projects using that list of executors, it leaves out projects that might be using executors from third-party plugins or even nx:run-commands
.
This would be a breaking change for any workspace using such a setup. Maybe that was never intended to be supported and it was meant to be used only with executors from first-party plugins (I don't know), but the implementation allowed using others and folks might be using it.
If we don't want to add such a constraint and make a breaking change now, what about we add this new solution as a fallback to the previous one? The previous solution is quicker and would correctly catch the buildable dependency for some scenarios. If we don't find the target, then we look for known executors.
That would still address the issue while keeping the existing behavior. I would avoid changing the current behavior because we might change this later by using the TaskGraph
instead of the ProjectGraph
. The executor context now contains the task graph, so we can use it now. The project graph knows nothing about target dependencies, but the task graph does.
@leosvelperez sure, I'll keep the old way in there, too, as a fallback to the new way! Sounds like a good practice, indeed! Maybe this should somehow be in the docs, though, too? @juristr what do you think? For a later addition, of course, not as part of this PR. Like, if you have dependencies, keep the name of the build target consistent, to make sure third-party plugins work? |
It's in some docs https://nx.dev/recipes/other/setup-incremental-builds-angular#build-target-name, but it should probably be generalized here https://nx.dev/more-concepts/incremental-builds. That said, the requirement might change soon, if we get to refactor this to use the task graph. When that happens, the target name will no longer be relevant and I think the only relevant thing will be the outputs which is what is consumed with buildable libraries. So maybe we don't rush updating the docs because they might change soon. |
761507e
to
cd6a5fa
Compare
cd6a5fa
to
e371193
Compare
e371193
to
1306531
Compare
Closing this, and will incorporate in a new effort to refactor some things. For now, the solution to this issue is one of the two:
OR
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
Right now, we identify if a project is buildable like this:
The
target
there is the name of the build target of a parent project. In that function, we try to understand if a project's dependency is buildable. This technique is flawed, since we cannot know for sure the name of thebuild
target, and we cannot assume it's the same as the parent project's build target name.This results in this: If one project imports another project, both projects' build targets need to have the same name. If projects have different names for the build target, then you get an irrelevant error.
Expected Behavior
isBuildable
should not rely on a parent project's build target name, but rather look through the child project's executors, and find if it has an executor which is a build executor.Retain existing behaviour to avoid breaking changes, and also allow it to work for build executors of other plugins (not
@nx/*
).Related Issue(s)
Fixes #17764