bazelbuild / bazelbuild/rules_rust
Runfiles for `rust_wasm_bindgen` targets
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Currently, `rust_wasm_bindgen` doesn't include runfiles of the underlying `wasm_file` target which in some cases is a `rust_binary` that uses the runfiles API as the common way to look up data files at runtime. For example:
```starlark
load("@tar.bzl", "tar")
load("@rules_rust_wasm_bindgen//:defs.bzl", "rust_wasm_bindgen")
rust_wasm_bindgen(
name = "app",
target = "web",
wasm_file = "//:app",
)
tar(
name = "archive",
srcs = [
"index.html",
":app",
],
include_runfiles = True,
)
```
Currently `app` is only the generated web files from `wasm-bindgen` and the `.wasm` file itself but there is no runfiles tree rendered next to it. I believe this is because `rust_wasm_bindgen` is not executable and therefore no runfiles tree is created. It would be easy to convert this to an executable but it's unclear what the "entrypoint" would be or if this makes sense semantically as the wasm file nor any of the javascript is directly executable. It would be nice though to have a way to author something like the example and have `app.runfiles/` in the tar.
Contributor guide
Research direction
Start with the rust_wasm_bindgen rule and its wasm_file target, using the provided tar example to understand the expected artifact layout. Investigate how runfiles are produced for the underlying rust_binary and how the generated app is packaged. Done means the example can include app.runfiles/ in the tar without requiring an ambiguous executable entrypoint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100