Skip to content

Commit

Permalink
wip: reproduce issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Oct 31, 2024
1 parent 6df0fe6 commit ebb4759
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ts_project(
# "." is the same as default
# explicitly given as a regression test for https://github.com/aspect-build/rules_ts/issues/195
out_dir = ".",
visibility = ["//examples:__subpackages__"],
# Note, the tsconfig attribute defaults to the tsconfig.json file in this directory.
# tsconfig = "<default>",
deps = [
Expand Down
55 changes: 55 additions & 0 deletions examples/srcs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@ ts_project(
out_dir = "filegroup",
)

ts_project(
name = "srcs-filegroup-gentsconfig",
srcs = [":srcs"],
tsconfig = {
"compilerOptions": {
"outDir": "filegroup-gentsconfig",
},
},
)

ts_project(
name = "srcs-filegroup-sibling",
srcs = [
":srcs",
"//examples/simple:ts",
],
out_dir = "filegroup-sibling",
)

ts_project(
name = "srcs-filegroup-sibling-gentsconfig",
srcs = [
":srcs",
"//examples/simple:ts",
],
tsconfig = {
"compilerOptions": {
"allowJs": True,
"outDir": "filegroup-sibling-gentsconfig",
},
},
)

# Tools can also generate .ts source files, so the sources are actually in the bazel-out tree.
# This example just writes one directly but this could instead be some tool.
write_file(
Expand All @@ -47,6 +80,20 @@ ts_project(
out_dir = "generated",
)

ts_project(
name = "srcs-generated-gentsconfig",
# Demonstrates that you can mix sources with generated files
srcs = [
"a.ts",
"generated.ts",
],
tsconfig = {
"compilerOptions": {
"outDir": "generated-gentsconfig",
},
},
)

# Testing what outputs are actually produced
[
params_file(
Expand All @@ -58,7 +105,11 @@ ts_project(
for case in [
"auto",
"filegroup",
"filegroup-gentsconfig",
"filegroup-sibling",
"filegroup-sibling-gentsconfig",
"generated",
"generated-gentsconfig",
]
]

Expand All @@ -71,7 +122,11 @@ ts_project(
for case in [
"auto",
"filegroup",
"filegroup-gentsconfig",
"filegroup-sibling",
"filegroup-sibling-gentsconfig",
"generated",
"generated-gentsconfig",
]
]

Expand Down
5 changes: 5 additions & 0 deletions ts/private/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def _ts_project_impl(ctx):

validation_outs = []
if ctx.attr.validate:
package_slash = ctx.label.package + "/"
for src in srcs_inputs:
if not src.path.startswith(package_slash):
fail("ts_project(%s) src (%s) must be in the same package" % (ctx.label, src.path))

validation_outs.extend(_validate_lib.validation_action(ctx, tsconfig_inputs))
_lib.validate_tsconfig_dirs(ctx.attr.root_dir, ctx.attr.out_dir, typings_out_dir)

Expand Down

0 comments on commit ebb4759

Please sign in to comment.