From 2517a35d7486829ea4eb2dd5d161b328743b5b92 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 28 May 2024 02:41:26 -0700 Subject: [PATCH] fix: include package store directory in default output of npm_link_package_store --- examples/genrule/BUILD.bazel | 3 --- npm/private/npm_link_package_store.bzl | 2 +- npm/private/test/npm_package/BUILD.bazel | 20 +++++++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/genrule/BUILD.bazel b/examples/genrule/BUILD.bazel index dd176bb965..8905bc9654 100644 --- a/examples/genrule/BUILD.bazel +++ b/examples/genrule/BUILD.bazel @@ -31,8 +31,6 @@ genrule( name = "call_acorn", srcs = [ ":one.js", - # reference the location where the "acorn" npm package was linked in our root Bazel package. - "//:node_modules/acorn", "//:node_modules/acorn/dir", ], outs = ["out1"], @@ -69,7 +67,6 @@ genrule( ":require_acorn_js", # reference the location where the "acorn" npm package was linked in our root Bazel package. "//:node_modules/acorn", - "//:node_modules/acorn/dir", ], outs = ["out2"], cmd = """ diff --git a/npm/private/npm_link_package_store.bzl b/npm/private/npm_link_package_store.bzl index f523bca704..2af66d9b00 100644 --- a/npm/private/npm_link_package_store.bzl +++ b/npm/private/npm_link_package_store.bzl @@ -92,7 +92,7 @@ def _npm_link_package_store_impl(ctx): ) files.append(bin_file) - files_depset = depset(files) + files_depset = depset(files, transitive = [store_info.files]) transitive_files_depset = depset(files, transitive = [store_info.transitive_files]) diff --git a/npm/private/test/npm_package/BUILD.bazel b/npm/private/test/npm_package/BUILD.bazel index 1971dcc38f..4968300c01 100644 --- a/npm/private/test/npm_package/BUILD.bazel +++ b/npm/private/test/npm_package/BUILD.bazel @@ -22,7 +22,19 @@ js_library( npm_package( name = "pkg", - srcs = [":lib_a"], + srcs = [ + ":lib_a", + ], + visibility = ["//visibility:public"], +) + +npm_package( + name = "pkg_2", + srcs = [ + ":lib_a", + ":node_modules/chalk", # should be excluded + "//:node_modules/chalk", # should be excluded + ], visibility = ["//visibility:public"], ) @@ -39,3 +51,9 @@ diff_test( file1 = ":pkg", file2 = ":expected_pkg", ) + +diff_test( + name = "test_2", + file1 = ":pkg_2", + file2 = ":expected_pkg", +)