Skip to content

Commit

Permalink
fix: include package store directory in default output of npm_link_pa…
Browse files Browse the repository at this point in the history
…ckage_store
  • Loading branch information
gregmagolan committed May 28, 2024
1 parent 8533e95 commit 0855720
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 1 addition & 3 deletions examples/genrule/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ 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"],
cmd = " ".join([
"$(NODE_PATH)",
# reference the location where the "acorn" npm package was linked in the rules_js npm package store.
"./$(execpath //:node_modules/acorn/dir)/bin/acorn",
"--compact",
"$(execpath :one.js)",
Expand Down Expand Up @@ -69,7 +68,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 = """
Expand Down
2 changes: 1 addition & 1 deletion npm/private/npm_link_package_store.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
16 changes: 16 additions & 0 deletions npm/private/test/npm_package/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ npm_package(
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"],
)

copy_to_directory(
name = "expected_pkg",
srcs = [
Expand All @@ -40,6 +50,12 @@ diff_test(
file2 = ":expected_pkg",
)

diff_test(
name = "test_pkg_2",
file1 = ":pkg_2",
file2 = ":expected_pkg",
)

npm_package(
name = "pkg_with_node_modules",
srcs = [":lib_a"],
Expand Down

0 comments on commit 0855720

Please sign in to comment.