Skip to content

Commit 83dbaed

Browse files
committed
feat: add bzlmod node_repositories support
Close #3781
1 parent eeb322c commit 83dbaed

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

e2e/nodejs_host/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"nodejs",
2121
"node16",
2222
"node16_nvmrc",
23+
"node17_custom",
2324
]
2425
]
2526

@@ -64,5 +65,7 @@
6465
("node16", "npx", []),
6566
("node16_nvmrc", "npm", []),
6667
("node16_nvmrc", "npx", []),
68+
("node17_custom", "npm", []),
69+
("node17_custom", "npx", []),
6770
]
6871
]

e2e/nodejs_host/MODULE.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ node.toolchain(
2020
name = "node16_nvmrc",
2121
node_version_from_nvmrc = "//:.nvmrc",
2222
)
23+
node.toolchain(
24+
name = "node17_custom",
25+
node_repositories = {
26+
"17.0.1-darwin_arm64": ("node-v17.0.1-darwin-arm64.tar.gz", "node-v17.0.1-darwin-arm64", "b49c65be9112f7e5de4e39f4f01e541ee73b3d28d3e2bbd3ea85a86952d0dc2d"),
27+
"17.0.1-darwin_amd64": ("node-v17.0.1-darwin-x64.tar.gz", "node-v17.0.1-darwin-x64", "0dfe6f904f3f20652e3d34c60885b790603f120d5d51a53031355827a4eaf6a9"),
28+
"17.0.1-linux_arm64": ("node-v17.0.1-linux-arm64.tar.xz", "node-v17.0.1-linux-arm64", "6cbd83ba5778a1af740a152839026cbd068610ec6e5ebf67739e546eba426171"),
29+
"17.0.1-linux_ppc64le": ("node-v17.0.1-linux-ppc64le.tar.xz", "node-v17.0.1-linux-ppc64le", "3f5665b92bce8c81caf35d1b0e10f59594499c8e5afeb8a12e101dd7dc62e6ed"),
30+
"17.0.1-linux_s390x": ("node-v17.0.1-linux-s390x.tar.xz", "node-v17.0.1-linux-s390x", "df8c44e3f10c14924a2b78530a6dd9e08557bc6694bc6342f18cd4fbdca30dfb"),
31+
"17.0.1-linux_amd64": ("node-v17.0.1-linux-x64.tar.xz", "node-v17.0.1-linux-x64", "30484910d6a25c96902f329c1fdfb753ddff9bf8c65a6e5ec5c818bac8135953"),
32+
"17.0.1-windows_amd64": ("node-v17.0.1-win-x64.zip", "node-v17.0.1-win-x64", "0b644e2499018884027a0fe5e0e159a18acd33e500c63a89898ba687189f7337"),
33+
},
34+
node_urls = ["https://nodejs.org/dist/v17.0.1/{filename}"],
35+
node_version = "17.0.1.custom",
36+
)
2337

2438
# FIXME(6.0): a repo rule with name=foo should create a repo named @foo, not @foo_toolchains
2539
use_repo(
@@ -38,6 +52,13 @@ use_repo(
3852
"node16_nvmrc_windows_amd64",
3953
"node16_toolchains",
4054
"node16_windows_amd64",
55+
"node17_custom",
56+
"node17_custom_darwin_amd64",
57+
"node17_custom_darwin_arm64",
58+
"node17_custom_linux_amd64",
59+
"node17_custom_linux_arm64",
60+
"node17_custom_toolchains",
61+
"node17_custom_windows_amd64",
4162
"nodejs",
4263
"nodejs_darwin_amd64",
4364
"nodejs_darwin_arm64",

e2e/nodejs_host/WORKSPACE.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ nodejs_register_toolchains(
2121
node_version_from_nvmrc = "//:.nvmrc",
2222
)
2323

24+
nodejs_register_toolchains(
25+
name = "node17_custom",
26+
node_repositories = {
27+
"17.0.1-darwin_arm64": ("node-v17.0.1-darwin-arm64.tar.gz", "node-v17.0.1-darwin-arm64", "b49c65be9112f7e5de4e39f4f01e541ee73b3d28d3e2bbd3ea85a86952d0dc2d"),
28+
"17.0.1-darwin_amd64": ("node-v17.0.1-darwin-x64.tar.gz", "node-v17.0.1-darwin-x64", "0dfe6f904f3f20652e3d34c60885b790603f120d5d51a53031355827a4eaf6a9"),
29+
"17.0.1-linux_arm64": ("node-v17.0.1-linux-arm64.tar.xz", "node-v17.0.1-linux-arm64", "6cbd83ba5778a1af740a152839026cbd068610ec6e5ebf67739e546eba426171"),
30+
"17.0.1-linux_ppc64le": ("node-v17.0.1-linux-ppc64le.tar.xz", "node-v17.0.1-linux-ppc64le", "3f5665b92bce8c81caf35d1b0e10f59594499c8e5afeb8a12e101dd7dc62e6ed"),
31+
"17.0.1-linux_s390x": ("node-v17.0.1-linux-s390x.tar.xz", "node-v17.0.1-linux-s390x", "df8c44e3f10c14924a2b78530a6dd9e08557bc6694bc6342f18cd4fbdca30dfb"),
32+
"17.0.1-linux_amd64": ("node-v17.0.1-linux-x64.tar.xz", "node-v17.0.1-linux-x64", "30484910d6a25c96902f329c1fdfb753ddff9bf8c65a6e5ec5c818bac8135953"),
33+
"17.0.1-windows_amd64": ("node-v17.0.1-win-x64.zip", "node-v17.0.1-win-x64", "0b644e2499018884027a0fe5e0e159a18acd33e500c63a89898ba687189f7337"),
34+
},
35+
node_urls = ["https://nodejs.org/dist/v17.0.1/{filename}"],
36+
node_version = "17.0.1.custom",
37+
)
38+
2439
http_archive(
2540
name = "bazel_skylib",
2641
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",

nodejs/extensions.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def _toolchain_extension(module_ctx):
4949
node_version = v.node_version,
5050
node_version_from_nvmrc = v.node_version_from_nvmrc,
5151
node_urls = v.node_urls,
52+
node_repositories = v.node_repositories,
5253
include_headers = v.include_headers,
5354
register = False,
5455
)
@@ -84,6 +85,15 @@ This setting creates a dependency on a c++ toolchain.
8485
""",
8586
default = [DEFAULT_NODE_URL],
8687
),
88+
"node_repositories": attr.string_list_dict(
89+
doc = """Custom list of node repositories to use
90+
91+
A dictionary mapping Node.js versions to sets of hosts and their corresponding (filename, strip_prefix, sha256) tuples.
92+
You should list a node binary for every platform users have, likely Mac, Windows, and Linux.
93+
94+
By default, if this attribute has no items, we'll use a list of all public Node.js releases.
95+
""",
96+
),
8797
}
8898

8999
node = module_extension(

0 commit comments

Comments
 (0)