Skip to content

Commit b606b79

Browse files
authored
feat: make node toolchain_type public so new toolchains can be added (#2591)
Enables rules_nodejs to be used in cross-compilation contexts, where the target architecture is not supported by rules_nodejs. rules_nodejs's default toolchains are limited via target_compatible_with, which means they will not work when cross-compiling to Android or iOS with --platforms for example. With this change, users can define their own toolchain that is limited by execution platform instead of target platform. For example, if you're targeting an unsupported platform, but building on a Mac, you can place the following in the local WORKSPACE: register_toolchains("//ts/node_toolchain") And the following in ts/node_toolchain/BUILD.bazel: toolchain( name = "node_toolchain", exec_compatible_with = [ "@platforms//os:osx", "@platforms//cpu:x86_64", ], toolchain = "@nodejs_darwin_amd64_config//:toolchain", toolchain_type = "@build_bazel_rules_nodejs//toolchains/node:toolchain_type", ) Closes #2565
1 parent 472ed62 commit b606b79

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

toolchains/node/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ filegroup(
7070
)
7171

7272
# node toolchain type
73-
toolchain_type(name = "toolchain_type")
73+
toolchain_type(
74+
name = "toolchain_type",
75+
visibility = ["//visibility:public"],
76+
)
7477

7578
# Allow targets to use a toolchains attribute, such as sh_binary and genrule
7679
# This way they can reference the NODE_PATH make variable.

0 commit comments

Comments
 (0)