fix(builtin): entry point from sources incorrectly used when binary is leveraged as tool, breaking resolution #3605
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.
Consider a
nodejs_binary
with a definition like the followed:This seems very standanrd and also works perfectly when the binary is invoked with
bazel run
. Via Bazel run, the Node Bash launcher resolves the entrypoint via the actual runfiles usingrlocation
.If this binary is used as a tool, e.g. in
npm_package_bin
- then the entry point is resolved from the execroot, landing ultimately on the actual source file. This is wrong and breaks resolution in RBE (where only necessary sources are in the execroot).This happens because the source entrypoint file. i.e. not the
entrypoint.js
frombazel-bin
is also ending up being included in the runfiles ofrun_node
viaNodeRuntimeDepsInfo
.This mismatch breaks resolution, and also results in an incorrect/ unnecessary file being added to the action inputs. The entry point used in
NodeRuntimeDepsInfo
should be the one derived from thedata
sources of the rule, ensuring the entry-point can access its other files of thejs_library
.i.e. entry-point should come from the
data
preferred, and if it's not found- then the source, orFile
can be directly used.This fixes RBE for angular.io which started unveiling some issues
when we attempted to enable RBE via: angular/angular#48316