Skip to content

Commit c2824a7

Browse files
committed
Improve naming using package() helper
1 parent 4f7ae85 commit c2824a7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
load("@npm//:defs.bzl", "link_js_packages")
1+
load("@npm//:defs.bzl", "link_js_packages", "package")
22
load("@aspect_rules_js//js:defs.bzl", "link_js_package")
33

44
# Building this target results in bazel-bin/examples/node_modules/@myorg/js_lib, so that
55
# TypeScript and other node programs beneath bazel-bin/examples are able to resolve its location.
66
link_js_package(
7-
name = "link_js_lib",
7+
name = package("@myorg/js_lib").name,
88
src = "//examples/js_lib",
99
visibility = ["//examples:__subpackages__"],
1010
)

examples/simple/BUILD.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
22
load("@bazel_skylib//rules:write_file.bzl", "write_file")
3+
load("@npm//:defs.bzl", "package")
34

45
# Dependencies for all targets in this package
56
_DEPS = [
6-
"//examples:link_js_lib",
7+
# For packages within the workspace, we use the package() helper to get a label
8+
# for the location where it's linked in the node_modules tree:
9+
package("@myorg/js_lib"),
10+
# Third-party packages from npm can be referenced directly:
711
"@npm//@types/node",
812
]
913

0 commit comments

Comments
 (0)