Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/js_binary.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sh_test(
"@nodejs_linux_amd64//:node_files",
"@nodejs_linux_arm64//:node_files",
],
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
toolchains = ["@rules_nodejs//nodejs:current_node_runtime"],
)

build_test(
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace_rerooted/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sh_test(
"@nodejs_linux_amd64//:node_files",
"@nodejs_linux_arm64//:node_files",
],
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
toolchains = ["@rules_nodejs//nodejs:current_node_runtime"],
)

build_test(
Expand Down
17 changes: 17 additions & 0 deletions e2e/vendored_node/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ load("@rules_nodejs//nodejs:toolchain.bzl", "nodejs_toolchain")
]
]

[
toolchain(
name = "node_vendored_%s_runtime" % os,
target_compatible_with = [
"@platforms//os:" + os,
"@platforms//cpu:x86_64",
],
toolchain = ":node_" + os,
toolchain_type = "@rules_nodejs//nodejs:runtime_toolchain_type",
)
for os in [
"linux",
"macos",
"windows",
]
]

nodejs_toolchain(
name = "node_linux",
node = "@vendored_node_linux_amd64//:bin/node",
Expand Down
8 changes: 4 additions & 4 deletions examples/genrule/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ genrule(
# $@ is bazel shorthand for the path of the output file
">$@",
]),
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
tools = ["@nodejs_toolchains//:resolved_toolchain"],
toolchains = ["@rules_nodejs//nodejs:current_node_toolchain"],
tools = ["@rules_nodejs//nodejs:current_node_toolchain"],
)

diff_test(
Expand Down Expand Up @@ -74,8 +74,8 @@ genrule(
$(NODE_PATH) \\
./$(execpath :require_acorn_js) \\
$@""",
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
tools = ["@nodejs_toolchains//:resolved_toolchain"],
toolchains = ["@rules_nodejs//nodejs:current_node_toolchain"],
tools = ["@rules_nodejs//nodejs:current_node_toolchain"],
)

diff_test(
Expand Down
6 changes: 3 additions & 3 deletions js/private/js_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ _ATTRS = {
""",
),
"node_toolchain": attr.label(
doc = """The Node.js toolchain to use for this target.
doc = """The Node.js runtime toolchain to use for this target.

See https://bazel-contrib.github.io/rules_nodejs/Toolchains.html

Expand Down Expand Up @@ -490,7 +490,7 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [],
if ctx.attr.node_toolchain:
nodeinfo = ctx.attr.node_toolchain[platform_common.ToolchainInfo].nodeinfo
else:
nodeinfo = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo
nodeinfo = ctx.toolchains["@rules_nodejs//nodejs:runtime_toolchain_type"].nodeinfo

directory_path_provider = DirectoryPathInfo if DirectoryPathInfo in ctx.attr.entry_point else _LegacyDirectoryPathInfo
if directory_path_provider in ctx.attr.entry_point:
Expand Down Expand Up @@ -618,7 +618,7 @@ js_binary_lib = struct(
toolchains = [
# TODO: on Windows this toolchain is never referenced
"@bazel_tools//tools/sh:toolchain_type",
"@rules_nodejs//nodejs:toolchain_type",
"@rules_nodejs//nodejs:runtime_toolchain_type",
] + COPY_FILE_TO_BIN_TOOLCHAINS,
)

Expand Down
7 changes: 2 additions & 5 deletions js/private/js_image_layer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ else {
transitive = [files],
)

nodeinfo = ctx.attr._current_node[platform_common.ToolchainInfo].nodeinfo
nodeinfo = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo
node_exec = nodeinfo.node
ctx.actions.run(
inputs = inputs,
Expand All @@ -418,6 +418,7 @@ else {
executable = node_exec,
progress_message = "Computing Layer Groups %{label}",
mnemonic = "JsImageLayerGroups",
toolchain = "@rules_nodejs//nodejs:toolchain_type",
)

return expected_layer_groups
Expand Down Expand Up @@ -623,10 +624,6 @@ js_image_layer_lib = struct(
default = "//js/private:js_image_layer.mjs",
allow_single_file = True,
),
"_current_node": attr.label(
default = "@nodejs_toolchains//:resolved_toolchain",
cfg = "exec",
),
"binary": attr.label(
mandatory = True,
cfg = _js_image_layer_transition,
Expand Down
2 changes: 1 addition & 1 deletion npm/private/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ sh_test(
"@nodejs_linux_amd64//:node_files",
"@nodejs_linux_arm64//:node_files",
],
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
toolchains = ["@rules_nodejs//nodejs:current_node_runtime"],
)