diff --git a/examples/path_mappings/BUILD.bazel b/examples/path_mappings/BUILD.bazel index 9ff4d765..07fc8706 100644 --- a/examples/path_mappings/BUILD.bazel +++ b/examples/path_mappings/BUILD.bazel @@ -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 = [ @@ -20,5 +22,5 @@ ts_project( build_test( name = "path_mappings_test", - targets = [":path_mappings"], + targets = [":foo.js"], ) diff --git a/examples/srcs/BUILD.bazel b/examples/srcs/BUILD.bazel index a902f228..0fc55eef 100644 --- a/examples/srcs/BUILD.bazel +++ b/examples/srcs/BUILD.bazel @@ -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", ) diff --git a/ts/private/ts_lib.bzl b/ts/private/ts_lib.bzl index 8cfcabea..387c4d14 100644 --- a/ts/private/ts_lib.bzl +++ b/ts/private/ts_lib.bzl @@ -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: