feat: eliminate distinction between srcs
and assets
#750
+114
−84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I believe the distinction between
srcs
andassets
is unnecessary and the two attributes should be combined. The desired behavior is thatts_project
should produce at least one output file for every input file insrcs
. Either the input should produce transpiled/declaration output(s), or it should be copied to the output directory, obeying the path rewriting rules implied byroot_dir
/out_dir
/declaration_dir
.Empirically, users at Figma have found the current behavior of
srcs
confusing. A typical experience is that they put non-TS files insrcs
, expecting them to get copied toout_dir
, and then observed some sort of failure, often at runtime, because the file was silently ignored instead.Some specific gotchas under the current behavior of
srcs
are:resolve_json_module = True, transpiler = "tsc"
, .json files insrcs
that are imported by one of the other input files get copied toout_dir
as expected. But .json files that are listed in srcs but unreferenced by any input file produce an "output was not created" Bazel error. With the change proposed here, all .json files get copied toout_dir
, regardless of whether they are imported somewhere or not.resolve_json_module = True, transpiler = "tsc"
target and change it to transpile with swc, any .json files insrcs
will no longer get copied toout_dir
. With the change proposed here, the behavior is consistent between tsc and swc..d.ts
files insrcs
is unpredictable and changes between rules_ts releases. Prior to 3.3.2,.d.ts
files did get copied to output, but withoutout_dir
applied. In rules_ts 3.3.2, they stopped being output altogether. With the change proposed here, they have a consistent and predictable behavior: they are always outputs, in thetypes
output group, withroot_dir
/out_dir
/declaration_dir
applied.Changes are visible to end-users: yes
This would be a breaking change because it removes the
assets
attribute. Generally, the migration action is simply to merge theassets
value intosrcs
.Test plan