Skip to content

Commit

Permalink
fix: handle absolute and relative ts_project srcs labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Apr 11, 2024
1 parent 4237138 commit 970bfb8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
51 changes: 51 additions & 0 deletions examples/srcs_targets/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Shows different ways to pass source files into ts_project"""

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")

[
write_file(
name = "gen-%s-ts" % n,
out = "%s.ts" % n,
content = [
"export const %s = 42" % n,
],
)
for n in [
"a",
"b",
"c",
"d",
"e",
]
]

# Various ways of declaring sources
ts_project(
name = "out-refs",
srcs = [
# Labels of various syntaxes to files
"a.ts",
":b.ts",
"//%s:c.ts" % package_name(),
"@//%s:d.ts" % package_name(),
"@aspect_rules_ts//%s:e.ts" % package_name(),

# Label to some rules
":gen-a-ts",
],
out_dir = "out",
)

build_test(
name = "test",
targets = [
"out-refs",
"out/a.js",
"out/b.js",
"out/c.js",
"out/d.js",
"out/e.js",
],
)
1 change: 1 addition & 0 deletions examples/srcs_targets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions ts/private/ts_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def _replace_ext(f, ext_map):
return None

def _to_out_path(f, out_dir, root_dir):
f = f[f.find(":") + 1:]
if root_dir:
f = f.removeprefix(root_dir + "/")
if out_dir:
Expand Down

0 comments on commit 970bfb8

Please sign in to comment.