Skip to content

Conversation

Wito-1
Copy link

@Wito-1 Wito-1 commented Jul 10, 2025

Minimal reproduction of trying to add a filegroup() target as a data dependency to a ts_project().

$ bazel build examples/json_data:tsc
ERROR: /home/juan/rules_ts/examples/json_data/BUILD.bazel:5:11: in ts_project rule //examples/json_data:tsc: 
Traceback (most recent call last):
	File "/home/juan/rules_ts/ts/private/ts_project.bzl", line 372, column 46, in _ts_project_impl
		runfiles = js_lib_helpers.gather_runfiles(
	File "/home/juan/.cache/bazel/_bazel_juan/0e06919cd12c94b9e9b15f43bcec7198/external/aspect_rules_js~/js/private/js_helpers.bzl", line 200, column 65, in gather_runfiles
		files_runfiles.append(copy_js_file_to_bin_action(ctx, d))
	File "/home/juan/.cache/bazel/_bazel_juan/0e06919cd12c94b9e9b15f43bcec7198/external/aspect_rules_js~/js/private/js_helpers.bzl", line 109, column 13, in copy_js_file_to_bin_action
		fail(msg)
Error in fail: 

Expected to find source file tsdata.json in '//examples/json_data', but instead it is in '//examples/json_data/src/test_data'.

All source and data files that are not in the Bazel output tree must be in the same package as the
target so that they can be copied to the output tree in an action.

See https://docs.aspect.build/rules/aspect_rules_js/docs/#javascript for more context on why this is required.

Either move tsdata.json to '//examples/json_data', or add a 'js_library'
target in tsdata.json's package and add that target to the deps of @@//examples/json_data:tsc:

buildozer 'new_load @aspect_rules_js//js:defs.bzl js_library' //examples/json_data/src/test_data:__pkg__
buildozer 'new js_library tsdata_json' //examples/json_data/src/test_data:__pkg__
buildozer 'add srcs tsdata.json' //examples/json_data/src/test_data:tsdata_json
buildozer 'add visibility //examples/json_data:__pkg__' //examples/json_data/src/test_data:tsdata_json
buildozer 'remove srcs //examples/json_data/src/test_data:tsdata.json' @@//examples/json_data:tsc
buildozer 'add srcs //examples/json_data/src/test_data:tsdata_json' @@//examples/json_data:tsc

For exceptional cases where copying is not possible or not suitable for an input file such as
a file in an external repository, exceptions can be added to 'no_copy_to_bin'. In most cases,
this option is not needed.


Changes are visible to end-users: yes/no

  • Searched for relevant documentation and updated as needed: yes/no
  • Breaking change (forces users to change their own code or config): yes/no
  • Suggested release notes appear below: yes/no

Test plan

  • Covered by existing test cases
  • New test cases added
  • Manual testing; please provide instructions so we can reproduce:

Copy link

aspect-workflows bot commented Jul 10, 2025

Test

⚠️ Buildkite build #261 failed.

//examples/json_data:tsc failed to build

in ts_project rule //examples/json_data:tsc:
Traceback (most recent call last):
	File "/mnt/ephemeral/workdir/aspect-build/rules_ts/ts/private/ts_project.bzl", line 372, column 46, in
_ts_project_impl
		runfiles = js_lib_helpers.gather_runfiles(
	File "/mnt/ephemeral/output/rules_ts/__main__/external/aspect_rules_js~/js/private/js_helpers.bzl", line
200, column 65, in gather_runfiles
		files_runfiles.append(copy_js_file_to_bin_action(ctx, d))
	File "/mnt/ephemeral/output/rules_ts/__main__/external/aspect_rules_js~/js/private/js_helpers.bzl", line
109, column 13, in copy_js_file_to_bin_action
		fail(msg)
Error in fail:
 
Expected to find source file tsdata.json in '//examples/json_data', but instead it is in
'//examples/json_data/src/test_data'.
 
All source and data files that are not in the Bazel output tree must be in the same package as the
target so that they can be copied to the output tree in an action.
 
See https://docs.aspect.build/rules/aspect_rules_js/docs/#javascript for more context on why this is
required.
 
Either move tsdata.json to '//examples/json_data', or add a 'js_library'
target in tsdata.json's package and add that target to the deps of @@//examples/json_data:tsc:
 
buildozer 'new_load @aspect_rules_js//js:defs.bzl js_library' //examples/json_data/src/test_data:__pkg__
buildozer 'new js_library tsdata_json' //examples/json_data/src/test_data:__pkg__
buildozer 'add srcs tsdata.json' //examples/json_data/src/test_data:tsdata_json
buildozer 'add visibility //examples/json_data:__pkg__' //examples/json_data/src/test_data:tsdata_json
buildozer 'remove srcs //examples/json_data/src/test_data:tsdata.json' @@//examples/json_data:tsc
buildozer 'add srcs //examples/json_data/src/test_data:tsdata_json' @@//examples/json_data:tsc
 
For exceptional cases where copying is not possible or not suitable for an input file such as
a file in an external repository, exceptions can be added to 'no_copy_to_bin'. In most cases,
this option is not needed.
in ts_project rule //examples/json_data:tsc:
Traceback (most recent call last):
	File "/mnt/ephemeral/workdir/aspect-build/rules_ts/ts/private/ts_project.bzl", line 372, column 46, in
_ts_project_impl
		runfiles = js_lib_helpers.gather_runfiles(
	File "/mnt/ephemeral/output/rules_ts/__main__/external/aspect_rules_js~/js/private/js_helpers.bzl", line
200, column 65, in gather_runfiles
		files_runfiles.append(copy_js_file_to_bin_action(ctx, d))
	File "/mnt/ephemeral/output/rules_ts/__main__/external/aspect_rules_js~/js/private/js_helpers.bzl", line
109, column 13, in copy_js_file_to_bin_action
		fail(msg)
Error in fail:
 
Expected to find source file tsdata.json in '//examples/json_data', but instead it is in
'//examples/json_data/src/test_data'.
 
All source and data files that are not in the Bazel output tree must be in the same package as the
target so that they can be copied to the output tree in an action.
 
See https://docs.aspect.build/rules/aspect_rules_js/docs/#javascript for more context on why this is
required.
 
Either move tsdata.json to '//examples/json_data', or add a 'js_library'
target in tsdata.json's package and add that target to the deps of @@//examples/json_data:tsc:
 
buildozer 'new_load @aspect_rules_js//js:defs.bzl js_library' //examples/json_data/src/test_data:__pkg__
buildozer 'new js_library tsdata_json' //examples/json_data/src/test_data:__pkg__
buildozer 'add srcs tsdata.json' //examples/json_data/src/test_data:tsdata_json
buildozer 'add visibility //examples/json_data:__pkg__' //examples/json_data/src/test_data:tsdata_json
buildozer 'remove srcs //examples/json_data/src/test_data:tsdata.json' @@//examples/json_data:tsc
buildozer 'add srcs //examples/json_data/src/test_data:tsdata_json' @@//examples/json_data:tsc
 
For exceptional cases where copying is not possible or not suitable for an input file such as
a file in an external repository, exceptions can be added to 'no_copy_to_bin'. In most cases,
this option is not needed.

💡 To reproduce the build failures, run

bazel build //examples/json_data:tsc

Test

e2e/external_dep

All tests were cache hits

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


Test

e2e/smoke

All tests were cache hits

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


Test

e2e/test

⚠️ Buildkite build #261 failed.

//examples/json_data:tsc failed to build

in ts_project rule //examples/json_data:tsc:
Traceback (most recent call last):
	File "/mnt/ephemeral/workdir/aspect-build/rules_ts/ts/private/ts_project.bzl", line 372, column 46, in
_ts_project_impl
		runfiles = js_lib_helpers.gather_runfiles(
	File "/mnt/ephemeral/output/rules_ts/e2e_test/external/aspect_rules_js~/js/private/js_helpers.bzl", line
200, column 65, in gather_runfiles
		files_runfiles.append(copy_js_file_to_bin_action(ctx, d))
	File "/mnt/ephemeral/output/rules_ts/e2e_test/external/aspect_rules_js~/js/private/js_helpers.bzl", line
109, column 13, in copy_js_file_to_bin_action
		fail(msg)
Error in fail:
 
Expected to find source file tsdata.json in '//examples/json_data', but instead it is in
'//examples/json_data/src/test_data'.
 
All source and data files that are not in the Bazel output tree must be in the same package as the
target so that they can be copied to the output tree in an action.
 
See https://docs.aspect.build/rules/aspect_rules_js/docs/#javascript for more context on why this is
required.
 
Either move tsdata.json to '//examples/json_data', or add a 'js_library'
target in tsdata.json's package and add that target to the deps of @@//examples/json_data:tsc:
 
buildozer 'new_load @aspect_rules_js//js:defs.bzl js_library' //examples/json_data/src/test_data:__pkg__
buildozer 'new js_library tsdata_json' //examples/json_data/src/test_data:__pkg__
buildozer 'add srcs tsdata.json' //examples/json_data/src/test_data:tsdata_json
buildozer 'add visibility //examples/json_data:__pkg__' //examples/json_data/src/test_data:tsdata_json
buildozer 'remove srcs //examples/json_data/src/test_data:tsdata.json' @@//examples/json_data:tsc
buildozer 'add srcs //examples/json_data/src/test_data:tsdata_json' @@//examples/json_data:tsc
 
For exceptional cases where copying is not possible or not suitable for an input file such as
a file in an external repository, exceptions can be added to 'no_copy_to_bin'. In most cases,
this option is not needed.
in ts_project rule //examples/json_data:tsc:
Traceback (most recent call last):
	File "/mnt/ephemeral/workdir/aspect-build/rules_ts/ts/private/ts_project.bzl", line 372, column 46, in
_ts_project_impl
		runfiles = js_lib_helpers.gather_runfiles(
	File "/mnt/ephemeral/output/rules_ts/e2e_test/external/aspect_rules_js~/js/private/js_helpers.bzl", line
200, column 65, in gather_runfiles
		files_runfiles.append(copy_js_file_to_bin_action(ctx, d))
	File "/mnt/ephemeral/output/rules_ts/e2e_test/external/aspect_rules_js~/js/private/js_helpers.bzl", line
109, column 13, in copy_js_file_to_bin_action
		fail(msg)
Error in fail:
 
Expected to find source file tsdata.json in '//examples/json_data', but instead it is in
'//examples/json_data/src/test_data'.
 
All source and data files that are not in the Bazel output tree must be in the same package as the
target so that they can be copied to the output tree in an action.
 
See https://docs.aspect.build/rules/aspect_rules_js/docs/#javascript for more context on why this is
required.
 
Either move tsdata.json to '//examples/json_data', or add a 'js_library'
target in tsdata.json's package and add that target to the deps of @@//examples/json_data:tsc:
 
buildozer 'new_load @aspect_rules_js//js:defs.bzl js_library' //examples/json_data/src/test_data:__pkg__
buildozer 'new js_library tsdata_json' //examples/json_data/src/test_data:__pkg__
buildozer 'add srcs tsdata.json' //examples/json_data/src/test_data:tsdata_json
buildozer 'add visibility //examples/json_data:__pkg__' //examples/json_data/src/test_data:tsdata_json
buildozer 'remove srcs //examples/json_data/src/test_data:tsdata.json' @@//examples/json_data:tsc
buildozer 'add srcs //examples/json_data/src/test_data:tsdata_json' @@//examples/json_data:tsc
 
For exceptional cases where copying is not possible or not suitable for an input file such as
a file in an external repository, exceptions can be added to 'no_copy_to_bin'. In most cases,
this option is not needed.

💡 To reproduce the build failures, run

bazel build //examples/json_data:tsc

Test

e2e/worker

All tests were cache hits

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


Buildifier      Format

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.

1 participant