rules_nixpkgs icon indicating copy to clipboard operation
rules_nixpkgs copied to clipboard

Update rules_nodejs version

Open dimatosaurus opened this issue 1 year ago • 3 comments

dimatosaurus avatar Jan 04 '25 21:01 dimatosaurus

Thank you for this contribution! Just out of interest: Is there a specific new feature this unblocks for you?

malt3 avatar Jan 06 '25 08:01 malt3

@malt3 This would be useful for any project that uses rules_js >= 2.0 which in turn sets a minimum rules_nodejs >= 6.0.0. I was able to get this PR working for my use case with a minor tweak to not use the deprecated node_toolchain rule:

diff --git a/private/common.bzl b/private/common.bzl
index a93d3c0..a4c5c47 100644
--- a/private/common.bzl
+++ b/private/common.bzl
@@ -1,5 +1,5 @@
 load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_package")
-load("@rules_nodejs//nodejs/private:toolchains_repo.bzl", "PLATFORMS")
+load("@rules_nodejs//nodejs/private:nodejs_toolchains_repo.bzl", "PLATFORMS")
 
 
 def _mk_mapping(rules_nodejs_platform_name):
@@ -41,10 +41,17 @@ pkgs.buildEnv {{
         visibility = ["//visibility:public"],
     )
 
-    load("@rules_nodejs//nodejs:toolchain.bzl", "node_toolchain")
-    node_toolchain(
+    filegroup(
+        name = "npm",
+        srcs = ["bin/npm"],
+        visibility = ["//visibility:public"],
+    )
+
+    load("@rules_nodejs//nodejs:toolchain.bzl", "nodejs_toolchain")
+    nodejs_toolchain(
         name = "nodejs_nix_impl",
-        target_tool = ":nodejs",
+        node = ":nodejs",
+        npm = ":npm",
         visibility = ["//visibility:public"],
     )

williamjenagility avatar Mar 15 '25 04:03 williamjenagility

Thank you for this contribution! Just out of interest: Is there a specific new feature this unblocks for you?

Just playing around with mono repo setups built on top of nix and bazel.

dimatosaurus avatar Mar 15 '25 12:03 dimatosaurus