From 8bccc1a59d76b7924ec6b639440fb753de70f90d Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Sun, 19 Dec 2021 07:48:07 -0800 Subject: [PATCH] fix: account for repository mapping We can't rely on the npm_install generated repos having the name we expect --- js/npm_import.bzl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/npm_import.bzl b/js/npm_import.bzl index 0067cfa25..489b86b89 100644 --- a/js/npm_import.bzl +++ b/js/npm_import.bzl @@ -49,11 +49,20 @@ nodejs_package( visibility = ["//visibility:public"], deps = {deps}, ) + +# The name of the repo can be affected by repository mapping and may not match +# our declared "npm_foo-1.2.3" naming. So give a stable label as well to use +# when declaring dependencies between packages. +alias( + name = "pkg", + actual = "{name}", + visibility = ["//visibility:public"], +) """.format( name = repository_ctx.name, nested_folder = result.stdout.rstrip("\n"), package_name = repository_ctx.attr.package, - deps = [str(d) for d in repository_ctx.attr.deps], + deps = [str(d.relative(":pkg")) for d in repository_ctx.attr.deps], )) _npm_import = repository_rule(