Skip to content

Commit

Permalink
fix: ts_project fails if root_dir used deep in source tree (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpanta authored Sep 13, 2022
1 parent 323f61c commit 90edabb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ts/private/ts_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _out_paths(srcs, out_dir, root_dir, allow_js, ext_map):
outs = []
for f in srcs:
if _is_ts_src(f, allow_js):
out = _join(out_dir, f[:f.rindex(".")].replace(rootdir_replace_pattern, "") + _replace_ext(f, ext_map))
out = _join(out_dir, f[:f.rindex(".")].replace(rootdir_replace_pattern, "", 1) + _replace_ext(f, ext_map))

# Don't declare outputs that collide with inputs
# for example, a.js -> a.js
Expand Down
14 changes: 14 additions & 0 deletions ts/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ write_file(
content = ["export const a: string = \"1\";"],
)

write_file(
name = "gen_deep_src",
out = "root/deep/root/deep_src.ts",
content = ["export const a: string = \"1\";"],
)

ts_project(
name = "transpile",
srcs = ["big.ts"],
Expand Down Expand Up @@ -90,6 +96,14 @@ ts_project(

transpiler_test_suite()

# Ensure that when determining output location, the `root_dir` attribute is only removed once.
ts_project(
name = "rootdir_works_with_repeated_directory",
srcs = ["root/deep/root/deep_src.ts"],
transpiler = mock,
tsconfig = _TSCONFIG,
root_dir = "root",
)

copy_file(
name = "copy_ts_project_worker",
Expand Down

0 comments on commit 90edabb

Please sign in to comment.