Description
What happened?
js_run_binary
sets use_execroot_entry_point = True
by default, and hoists runfiles of the tool to srcs so that they are included as execroot inputs to the action, while also preserving the runfiles input. The downside of this is that any actions required to build those runfiles will get executed twice: once under the default fastbuild
configuration, for the execroot input, and once under a transition, for the runfiles input. For example, if there are npm packages in the runfiles dependencies, then their NpmPackageExtract
(and NpmLifecycleHook
if present) actions run twice.
I was able to work around this in a specific case where it had a significant performance impact by avoiding the use of data dependencies, but it would be nice if there was a generic solution such that every use of js_run_binary
would not be affected by default.
Version
Development (host) and target OS/architectures:
Output of bazel --version
: bazel 7.4.0
Version of the Aspect rules, or other relevant rules from your
WORKSPACE
or MODULE.bazel
file: rules_js 2.1.2
Language(s) and/or frameworks involved: JS
How to reproduce
In rules_js, run bazel clean && bazel build --execution_log_compact_file=compact_exec.log //examples/js_binary:run2 && ../bazel/bazel-bin/src/tools/execlog/parser --log_path compact_exec.log
.
acorn/CHANGELOG.md output from first NpmPackageExtract
, in darwin_arm64-fastbuild
:
actual_outputs {
path: "bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
digest {
hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
size_bytes: 17478
hash_function_name: "SHA-256"
}
}
acorn/CHANGELOG.md output from second NpmPackageExtract
, in darwin_arm64-opt-exec-ST-d57f47055a04
:
actual_outputs {
path: "bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
digest {
hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
size_bytes: 17478
hash_function_name: "SHA-256"
}
}
First acorn/CHANGELOG.md input:
inputs {
path: "bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
digest {
hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
size_bytes: 17478
hash_function_name: "SHA-256"
}
}
Second acorn/CHANGELOG.md input:
inputs {
path: "bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/examples/js_binary/bin_/bin.runfiles/_main/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
digest {
hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
size_bytes: 17478
hash_function_name: "SHA-256"
}
is_tool: true
}
Any other information?
No response