aspect-build / aspect-build/rules_js
[Bug]: js_run_binary defaults to opt runfiles for all compilation modes.
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 29
Description
### What happened?
It looks like the runfiles defaults to `opt` for `js_run_binary`, irrespective of the Bazel compilation mode, and I'm not sure I understand why. In my particular case I'm using esbuild to generate files and toggling `splitting` and `minifying` based on the compilation mode (on for `opt` and off for `fastbuild`), which in turn means that the hashes in the file names differ based on compilation mode.
I have a script that goes looking in the runfiles for the generated JS, and under `fastbuild` it goes looking for those that would've been generated under `opt`.
### Version
Development (host) and target OS/architectures: Mac
Output of `bazel --version`: bazel 5.3.2
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: 1.6.9
Language(s) and/or frameworks involved: JavaScript & Node
### How to reproduce
Given a `js_binary` like this:
```bazel
js_binary(
name = "test",
entry_point = ":test.js",
)
```
Running `bazel run //:test` and logging `process.env.RUNFILES` I see a `fastbuild` path:
```RUNFILES: '/path/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/test.sh.runfiles'```
However, if I now run that same `js_binary` as the tool for a `js_run_binary` like this:
```bazel
js_run_binary(
name = "test-bin",
outs = ["foo"],
silent_on_success = False,
tool = "//:test",
)
```
The `process.env.RUNFILES` is now set to an `opt` path:
```
RUNFILES: '/path/execroot/__main__/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/src/test.sh.runfiles'
```
Contributor guide
Research direction
Start with the js_run_binary and js_binary entry points and reproduce the issue in the provided Bazel examples, comparing RUNFILES under fastbuild and opt. Trace how the tool's compilation mode is selected and how its runfiles path is assembled. Done means js_run_binary uses the matching compilation-mode runfiles so generated filenames resolve correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100