You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to discussions in #3854 having two toolchains of the same type for different things is troublesome. It's better to have separate runtime as well as compile toolchains.
This commit creates a new runtime_toolchain_type and registers toolchains without execution constraints for this type. Once merged, rules_ts can start consuming the new toolchain type in its js_binary rule to ensure the correct Node for the correct target environment is selected.
Fixed [Bug]: Execution toolchain defined without `target_compatible_with` makes it a candidate to selection
Fixes#3854
Work towards #3795
Copy file name to clipboardExpand all lines: docs/Toolchains.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,16 @@
3
3
API docs for [Toolchain](https://docs.bazel.build/versions/main/toolchains.html) support.
4
4
5
5
When you call `nodejs_register_toolchains()` in your `WORKSPACE` file it will setup a node toolchain for executing tools on all currently supported platforms.
6
+
In `bzlmod` default toolchains are registered automatically when you depend on `rules_nodejs`.
7
+
8
+
There are two toolchain types:
9
+
10
+
1) The transpilation toolchain, which provides the Node runtime used to execute the transpiler (and type checker), as well as various helper tools and settings.
11
+
(`@rules_nodejs//nodejs:toolchain_type`)
12
+
2) The Node runtime that executable Node outputs (e.g., js_binary) will run on.
13
+
(`@rules_nodejs//nodejs:runtime_toolchain_type`)
14
+
15
+
See [//nodjes/BUILD.bazel](https://github.com/bazel-contrib/rules_nodejs/blob/main/nodejs/BUILD.bazel) for details.
6
16
7
17
If you have an advanced use-case and want to use a version of node not supported by this repository, you can also register your own toolchains.
8
18
@@ -13,9 +23,9 @@ To run a custom toolchain (i.e., to run a node binary not supported by the built
13
23
1) A rule which can build or load a node binary from your repository
14
24
(a checked-in binary or a build using a relevant [`rules_foreign_cc` build rule](https://bazelbuild.github.io/rules_foreign_cc/) will do nicely).
15
25
2) A [`nodejs_toolchain` rule](Core.html#nodejs_toolchain) which depends on your binary defined in step 1 as its `node`.
16
-
3)A[`toolchain`rule](https://bazel.build/reference/be/platform#toolchain)that depends on your `nodejs_toolchain` rule defined in step 2 as its `toolchain`
17
-
and on `@rules_nodejs//nodejs:toolchain_type` as its `toolchain_type`. Make sure to define appropriate platform restrictions as described in the
18
-
documentation for the `toolchain` rule.
26
+
3)Two[`toolchain`rules](https://bazel.build/reference/be/platform#toolchain)each depends on your `nodejs_toolchain` rule defined in step 2 as its `toolchain`
27
+
and one on `@rules_nodejs//nodejs:toolchain_type` as its `toolchain_type` and the other one `@rules_nodejs//nodejs:runtime_toolchain_type`.
28
+
Make sure to define appropriate platform restrictions as described in the documentation for the `toolchain` rule.
19
29
4) A call to [the `register_toolchains` function](https://bazel.build/rules/lib/globals#register_toolchains) in your `WORKSPACE`
20
30
that refers to the `toolchain` rule defined in step 3.
0 commit comments