Skip to content

Commit cb83746

Browse files
author
Dylan
authored
fix(): remove node and use toolchain (#3144)
1 parent 55a7521 commit cb83746

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

docs/Built-ins.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Defaults to `"1.22.11"`
263263

264264
<pre>
265265
nodejs_binary(<a href="#nodejs_binary-name">name</a>, <a href="#nodejs_binary-chdir">chdir</a>, <a href="#nodejs_binary-configuration_env_vars">configuration_env_vars</a>, <a href="#nodejs_binary-data">data</a>, <a href="#nodejs_binary-default_env_vars">default_env_vars</a>, <a href="#nodejs_binary-entry_point">entry_point</a>, <a href="#nodejs_binary-env">env</a>,
266-
<a href="#nodejs_binary-link_workspace_root">link_workspace_root</a>, <a href="#nodejs_binary-node">node</a>, <a href="#nodejs_binary-templated_args">templated_args</a>, <a href="#nodejs_binary-toolchain">toolchain</a>)
266+
<a href="#nodejs_binary-link_workspace_root">link_workspace_root</a>, <a href="#nodejs_binary-templated_args">templated_args</a>, <a href="#nodejs_binary-toolchain">toolchain</a>)
267267
</pre>
268268

269269
Runs some JavaScript code in NodeJS.
@@ -397,12 +397,6 @@ If source files need to be required then they can be copied to the bin_dir with
397397

398398
Defaults to `False`
399399

400-
<h4 id="nodejs_binary-node">node</h4>
401-
402-
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*)
403-
404-
Defaults to `@nodejs//:node_bin`
405-
406400
<h4 id="nodejs_binary-templated_args">templated_args</h4>
407401

408402
(*List of strings*): Arguments which are passed to every execution of the program.
@@ -497,7 +491,7 @@ Defaults to `None`
497491

498492
<pre>
499493
nodejs_test(<a href="#nodejs_test-name">name</a>, <a href="#nodejs_test-chdir">chdir</a>, <a href="#nodejs_test-configuration_env_vars">configuration_env_vars</a>, <a href="#nodejs_test-data">data</a>, <a href="#nodejs_test-default_env_vars">default_env_vars</a>, <a href="#nodejs_test-entry_point">entry_point</a>, <a href="#nodejs_test-env">env</a>,
500-
<a href="#nodejs_test-expected_exit_code">expected_exit_code</a>, <a href="#nodejs_test-link_workspace_root">link_workspace_root</a>, <a href="#nodejs_test-node">node</a>, <a href="#nodejs_test-templated_args">templated_args</a>, <a href="#nodejs_test-toolchain">toolchain</a>)
494+
<a href="#nodejs_test-expected_exit_code">expected_exit_code</a>, <a href="#nodejs_test-link_workspace_root">link_workspace_root</a>, <a href="#nodejs_test-templated_args">templated_args</a>, <a href="#nodejs_test-toolchain">toolchain</a>)
501495
</pre>
502496

503497

@@ -663,12 +657,6 @@ If source files need to be required then they can be copied to the bin_dir with
663657

664658
Defaults to `False`
665659

666-
<h4 id="nodejs_test-node">node</h4>
667-
668-
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*)
669-
670-
Defaults to `@nodejs//:node_bin`
671-
672660
<h4 id="nodejs_test-templated_args">templated_args</h4>
673661

674662
(*List of strings*): Arguments which are passed to every execution of the program.

docs/Cypress.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Defaults to `None`
125125

126126
<pre>
127127
cypress_web_test(<a href="#cypress_web_test-name">name</a>, <a href="#cypress_web_test-chdir">chdir</a>, <a href="#cypress_web_test-config_file">config_file</a>, <a href="#cypress_web_test-configuration_env_vars">configuration_env_vars</a>, <a href="#cypress_web_test-cypress_npm_package">cypress_npm_package</a>, <a href="#cypress_web_test-data">data</a>,
128-
<a href="#cypress_web_test-default_env_vars">default_env_vars</a>, <a href="#cypress_web_test-entry_point">entry_point</a>, <a href="#cypress_web_test-env">env</a>, <a href="#cypress_web_test-expected_exit_code">expected_exit_code</a>, <a href="#cypress_web_test-link_workspace_root">link_workspace_root</a>, <a href="#cypress_web_test-node">node</a>,
128+
<a href="#cypress_web_test-default_env_vars">default_env_vars</a>, <a href="#cypress_web_test-entry_point">entry_point</a>, <a href="#cypress_web_test-env">env</a>, <a href="#cypress_web_test-expected_exit_code">expected_exit_code</a>, <a href="#cypress_web_test-link_workspace_root">link_workspace_root</a>,
129129
<a href="#cypress_web_test-plugin_file">plugin_file</a>, <a href="#cypress_web_test-srcs">srcs</a>, <a href="#cypress_web_test-templated_args">templated_args</a>, <a href="#cypress_web_test-toolchain">toolchain</a>)
130130
</pre>
131131

@@ -250,12 +250,6 @@ If source files need to be required then they can be copied to the bin_dir with
250250

251251
Defaults to `False`
252252

253-
<h4 id="cypress_web_test-node">node</h4>
254-
255-
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*)
256-
257-
Defaults to `@nodejs//:node_bin`
258-
259253
<h4 id="cypress_web_test-plugin_file">plugin_file</h4>
260254

261255
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Your cypress plugin file. See https://docs.cypress.io/guides/tooling/plugins-guide

internal/node/node.bzl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ load("//internal/common:path_utils.bzl", "strip_external")
2828
load("//internal/common:preserve_legacy_templated_args.bzl", "preserve_legacy_templated_args")
2929
load("//internal/common:windows_utils.bzl", "create_windows_native_launcher_script", "is_windows")
3030
load("//internal/linker:link_node_modules.bzl", "LinkerPackageMappingInfo", "module_mappings_aspect", "write_node_modules_manifest")
31-
load("//nodejs:repositories.bzl", "BUILT_IN_NODE_PLATFORMS")
3231

3332
def _trim_package_node_modules(package_name):
3433
# trim a package name down to its path prior to a node_modules
@@ -248,13 +247,13 @@ fi
248247
#
249248
# Rules such as nodejs_image should use only ctx.toolchains["@build_bazel_rules_nodejs//toolchains/node:toolchain_type"].nodeinfo
250249
# when building the image as that will reflect the selected --platform.
251-
node_tool_files = ctx.files.node[:]
252250

253251
if ctx.attr.toolchain:
254252
node_toolchain = ctx.attr.toolchain[platform_common.ToolchainInfo]
255253
else:
256254
node_toolchain = ctx.toolchains["@build_bazel_rules_nodejs//toolchains/node:toolchain_type"]
257255

256+
node_tool_files = []
258257
node_tool_files.extend(node_toolchain.nodeinfo.tool_files)
259258
node_tool_files.append(ctx.file._link_modules_script)
260259
node_tool_files.append(ctx.file._runfile_helpers_bundle)
@@ -263,8 +262,6 @@ fi
263262
node_tool_files.append(ctx.file._lcov_merger_script)
264263
node_tool_files.append(node_modules_manifest)
265264

266-
is_builtin = ctx.attr.node.label.workspace_name in ["nodejs_%s" % p for p in BUILT_IN_NODE_PLATFORMS]
267-
268265
runfiles = runfiles[:]
269266
runfiles.extend(node_tool_files)
270267
runfiles.extend(ctx.files._bash_runfile_helper)
@@ -322,7 +319,7 @@ fi
322319
"TEMPLATED_repository_args": _to_manifest_path(ctx, ctx.file._repository_args),
323320
"TEMPLATED_require_patch_script": _to_manifest_path(ctx, ctx.outputs.require_patch_script),
324321
"TEMPLATED_runfiles_helper_script": _to_manifest_path(ctx, ctx.file._runfile_helpers_main),
325-
"TEMPLATED_vendored_node": "" if is_builtin else strip_external(ctx.file.node.path),
322+
"TEMPLATED_vendored_node": strip_external(node_toolchain.nodeinfo.target_tool_path),
326323
}
327324

328325
# TODO when we have "link_all_bins" we will only need to look in one place for the entry point
@@ -596,10 +593,6 @@ Predefined genrule variables are not supported in this context.
596593
default = Label("//internal/node:loader.js"),
597594
allow_single_file = True,
598595
),
599-
"node": attr.label(
600-
default = Label("@nodejs//:node_bin"),
601-
allow_single_file = True,
602-
),
603596
"toolchain": attr.label(),
604597
"_repository_args": attr.label(
605598
default = Label("@nodejs//:bin/node_repo_args.sh"),

internal/node/test/BUILD.bazel

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ nodejs_binary(
557557
entry_point = "binary_version.js",
558558
# using the select statement will download toolchains for all three platforms
559559
# you can also just provide an individual toolchain if you don't want to download them all
560-
node = select({
560+
toolchain = select({
561561
"@bazel_tools//src/conditions:linux_x86_64": "@node15_linux_amd64//:node_toolchain",
562562
"@bazel_tools//src/conditions:darwin": "@node15_darwin_amd64//:node_toolchain",
563563
"@bazel_tools//src/conditions:windows": "@node15_windows_amd64//:node_toolchain",
@@ -569,7 +569,7 @@ nodejs_binary(
569569
entry_point = "binary_version.js",
570570
# using the select statement will download toolchains for all three platforms
571571
# you can also just provide an individual toolchain if you don't want to download them all
572-
node = select({
572+
toolchain = select({
573573
"@bazel_tools//src/conditions:linux_x86_64": "@node16_linux_amd64//:node_toolchain",
574574
"@bazel_tools//src/conditions:darwin": "@node16_darwin_amd64//:node_toolchain",
575575
"@bazel_tools//src/conditions:windows": "@node16_windows_amd64//:node_toolchain",
@@ -586,7 +586,7 @@ nodejs_test(
586586
entry_point = "toolchain_test_v15.14.0.js",
587587
# using the select statement will download toolchains for all three platforms
588588
# you can also just provide an individual toolchain if you don't want to download them all
589-
node = select({
589+
toolchain = select({
590590
"@bazel_tools//src/conditions:linux_x86_64": "@node15_linux_amd64//:node_toolchain",
591591
"@bazel_tools//src/conditions:darwin": "@node15_darwin_amd64//:node_toolchain",
592592
"@bazel_tools//src/conditions:windows": "@node15_windows_amd64//:node_toolchain",
@@ -598,7 +598,7 @@ nodejs_test(
598598
entry_point = "toolchain_test_v16.js",
599599
# using the select statement will download toolchains for all three platforms
600600
# you can also just provide an individual toolchain if you don't want to download them all
601-
node = select({
601+
toolchain = select({
602602
"@bazel_tools//src/conditions:linux_x86_64": "@node16_linux_amd64//:node_toolchain",
603603
"@bazel_tools//src/conditions:darwin": "@node16_darwin_amd64//:node_toolchain",
604604
"@bazel_tools//src/conditions:windows": "@node16_windows_amd64//:node_toolchain",
@@ -615,7 +615,6 @@ nodejs_test(
615615
nodejs_binary(
616616
name = "main_multiple_loop_" + id,
617617
entry_point = "binary_version.js",
618-
node = tc,
619618
toolchain = tc,
620619
)
621620
for id, tc in zip(
@@ -651,7 +650,6 @@ nodejs_test(
651650
"data/data.json",
652651
],
653652
entry_point = ":data_resolution.spec.js",
654-
node = tc,
655653
toolchain = tc,
656654
)
657655
for id, tc in zip(
@@ -684,7 +682,6 @@ nodejs_test(
684682
nodejs_test(
685683
name = "main_test_multiple_version_" + id,
686684
entry_point = entry,
687-
node = tc,
688685
toolchain = tc,
689686
)
690687
for id, entry, tc in zip(

0 commit comments

Comments
 (0)