Skip to content

Add an example where the srcs of a ts_project is a directory of generated code#898

Closed
MatrixFrog wants to merge 3 commits intoaspect-build:mainfrom
MatrixFrog:generated-dir
Closed

Add an example where the srcs of a ts_project is a directory of generated code#898
MatrixFrog wants to merge 3 commits intoaspect-build:mainfrom
MatrixFrog:generated-dir

Conversation

@MatrixFrog
Copy link
Copy Markdown
Contributor

@MatrixFrog MatrixFrog commented Feb 26, 2026

I believe this might be a bug, or at least a surprising behavior. If you pass as the srcs of a ts_project, a directory of generated TS code, without specifying the exact filenames of all the TS files inside it, you get a target that essentially does nothing:

$ cd examples
$ bazel build //gen_srcs:ts_proj_typecheck_test
$ cat bazel-bin/gen_srcs/ts_proj_typecheck_test.sh # The entire test is just `exit 0`

Instead, it would be great if we got a warning or error at build-time: Input target ":code_generation" is an opaque directory and will be ignored or something like that.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Feb 26, 2026

Bazel 7 (Test)

All tests were cache hits

25 tests (100.0%) were fully cached saving 2s.


Bazel 8 (Test)

All tests were cache hits

25 tests (100.0%) were fully cached saving 2s.


Bazel 9 (Test)

All tests were cache hits

25 tests (100.0%) were fully cached saving 2s.


Bazel-7

e2e/bzlmodules

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel-8

e2e/bzlmodules

All tests were cache hits

1 test (100.0%) was fully cached saving 25ms.


Bazel-9

e2e/bzlmodules

All tests were cache hits

1 test (100.0%) was fully cached saving 34ms.


Bazel-7

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 333ms.


Bazel-7-wksp

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 233ms.


Bazel-8

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 277ms.


Bazel-9

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 378ms.


Bazel-7

e2e/external_dep/app

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel-7-wksp

e2e/external_dep/app

All tests were cache hits

1 test (100.0%) was fully cached saving 39ms.


Bazel-8

e2e/external_dep/app

All tests were cache hits

1 test (100.0%) was fully cached saving 62ms.


Bazel-9

e2e/external_dep/app

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel-7

e2e/nested_repos

All tests were cache hits

3 tests (100.0%) were fully cached saving 113ms.


Bazel-8

e2e/nested_repos

All tests were cache hits

3 tests (100.0%) were fully cached saving 116ms.


Bazel-9

e2e/nested_repos

All tests were cache hits

3 tests (100.0%) were fully cached saving 125ms.


Bazel-7

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 107ms.


Bazel-7-wksp

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 136ms.


Bazel-8

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 124ms.


Bazel-9

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 91ms.


Bazel-7

e2e/smoke_rjs3

All tests were cache hits

1 test (100.0%) was fully cached saving 39ms.


Bazel-8

e2e/smoke_rjs3

All tests were cache hits

1 test (100.0%) was fully cached saving 27ms.


Bazel-9

e2e/smoke_rjs3

All tests were cache hits

1 test (100.0%) was fully cached saving 43ms.


Bazel-7

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 287ms.


Bazel-7-wksp

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 406ms.


Bazel-8

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 329ms.


Bazel-9

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 317ms.


Bazel 8 (Test)

examples

⚠️ Buildkite build #547 failed.

//gen_srcs:ts_proj failed to build

in ts_project rule //gen_srcs:ts_proj:
Traceback (most recent call last):
	File "/mnt/ephemeral/output/rules_ts/examples/external/aspect_rules_ts+/ts/private/ts_project.bzl", line 87,
column 17, in _ts_project_impl
		fail("srcs of a ts_project should be files not directories")
Error in fail: srcs of a ts_project should be files not directories

💡 To reproduce the build failures, run

bazel build //gen_srcs:ts_proj

Bazel 9 (Test)

examples

⚠️ Buildkite build #547 failed.

//gen_srcs:ts_proj failed to build

in ts_project rule //gen_srcs:ts_proj:
Traceback (most recent call last):
	File "/mnt/ephemeral/output/rules_ts/examples/external/aspect_rules_ts+/ts/private/ts_project.bzl", line 87,
column 17, in _ts_project_impl
		fail("srcs of a ts_project should be files not directories")
Error in fail: srcs of a ts_project should be files not directories

💡 To reproduce the build failures, run

bazel build //gen_srcs:ts_proj

Buildifier      Format

@jbedard
Copy link
Copy Markdown
Member

jbedard commented Mar 20, 2026

I think adding the error is acceptable. I think the test reproducing it needs to just be dropped though?

@MatrixFrog
Copy link
Copy Markdown
Contributor Author

Unless there's a way to mark a target as expected to fail or something, yeah.

@jbedard
Copy link
Copy Markdown
Member

jbedard commented Mar 20, 2026

e2e tests can have a test.sh which runs bazel and assets on things like the exit code or stdout. We could potentially have an e2e test with multiple invalid ts_projects and a few of these assertions?

You can try that if you'd like, otherwise maybe I will another time 🤔

@jbedard
Copy link
Copy Markdown
Member

jbedard commented Mar 20, 2026

Actually, sorry the test.sh thing doesn't exist in this repo (unlike others like rules_js), but rules_ts has something better... checkout e2e/test and the bats tests.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 21, 2026

CLA assistant check
All committers have signed the CLA.

Comment thread examples/gen_srcs/BUILD.bazel
@MatrixFrog MatrixFrog marked this pull request as draft March 23, 2026 17:56
@MatrixFrog
Copy link
Copy Markdown
Contributor Author

Moving to #912

@jbedard
Copy link
Copy Markdown
Member

jbedard commented Mar 26, 2026

close then?

@MatrixFrog MatrixFrog closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants