Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: permit more label syntax when pre-computing outputs #585

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/path_mappings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
# bazel-bin/examples/path_mappings/foo.d.ts
ts_project(
name = "path_mappings",
srcs = ["foo.ts"],
# Use a fully-qualified label as a test that the macro logic still produces
# the expected pre-declared output file for foo.js
srcs = ["//examples/path_mappings:foo.ts"],
declaration = True,
validate = False,
deps = [
Expand All @@ -20,5 +22,5 @@ ts_project(

build_test(
name = "path_mappings_test",
targets = [":path_mappings"],
targets = [":foo.js"],
)
6 changes: 4 additions & 2 deletions examples/srcs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ write_file(
ts_project(
name = "srcs-generated",
# Demonstrates that you can mix sources with generated files
# (Also verifies that relative labels work with macro logic for predeclared outputs)
srcs = [
"a.ts",
"generated.ts",
"//examples/srcs:a.ts",
":b.ts",
":generated.ts",
],
out_dir = "generated",
)
Expand Down
3 changes: 3 additions & 0 deletions ts/private/ts_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def _replace_ext(f, ext_map):
return None

def _to_out_path(f, out_dir, root_dir):
# convert to a label first, to normalize syntax like
# srcs = ["@//path/to:a.ts", "//path/to:b.ts", ":c.ts", "d.ts"]
f = f[f.find(":") + 1:]
if root_dir:
f = f.removeprefix(root_dir + "/")
if out_dir:
Expand Down
Loading