feat: add node_data attribute to nodejs_toolchain#3911
feat: add node_data attribute to nodejs_toolchain#3911djedward wants to merge 1 commit intobazel-contrib:mainfrom
Conversation
The node_data attribute allows for additional runtime files to be provided with the node binary.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1862e131c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| allow_single_file = True, | ||
| ), | ||
| "node_path": attr.string(), | ||
| "node_data": attr.label_list(allow_files = True), |
There was a problem hiding this comment.
Resolve node_data in exec configuration
The new node_data attribute is declared without cfg = "exec", while node is explicitly exec-configured. In toolchain rules this causes node_data labels/selects to resolve in the target configuration, so cross-platform builds can pair an exec-platform Node binary with target-platform companion files (for example, host x86_64 tool with arm64-target node_data), which can break wrapper scripts or native runtime dependencies at execution time.
Useful? React with 👍 / 👎.
|
Can you provide an example of when this would be used instead of simply using |
|
Our use-case is that our node team produces our node toolchain with a wrapper script: So when we setup the toolchain for other teams to consume, we need a way for both of these files to be present in the sandbox. One hack we played with was including it in the |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Only the node binary itself can be provided for a toolchain. No supporting files may be included.
Issue Number: N/A
What is the new behavior?
This introduces a new, optional, node_data attribute to nodejs_toolchain to allow for additional runtime files to be provided with the node binary. Though this is likely not a common need, we ran into issues for some of our node toolchains which have wrapper scripts to handle special setups. I'm working on a corresponding update to rules_js to use this new attribute as well.
Does this PR introduce a breaking change?
Other information
All of the links in the existing documentation to nodejs_toolchain appear to go to non-existent places, so outside of the documetation in the toolchain.bzl, I didn't add any.