@@ -161,16 +161,7 @@ def _ts_project_impl(ctx):
161
161
inputs .extend (depset (transitive = deps_depsets ).to_list ())
162
162
163
163
# Gather TsConfig info from both the direct (tsconfig) and indirect (extends) attribute
164
- tsconfig_inputs = []
165
- if TsConfigInfo in ctx .attr .tsconfig :
166
- tsconfig_inputs .extend (ctx .attr .tsconfig [TsConfigInfo ].deps )
167
- else :
168
- tsconfig_inputs .append (ctx .file .tsconfig )
169
- if hasattr (ctx .attr , "extends" ) and ctx .attr .extends :
170
- if TsConfigInfo in ctx .attr .extends :
171
- tsconfig_inputs .extend (ctx .attr .extends [TsConfigInfo ].deps )
172
- else :
173
- tsconfig_inputs .extend (ctx .attr .extends .files .to_list ())
164
+ tsconfig_inputs = _tsconfig_inputs (ctx )
174
165
inputs .extend (tsconfig_inputs )
175
166
176
167
# We do not try to predeclare json_outs, because their output locations generally conflict with their path in the source tree.
@@ -249,6 +240,20 @@ def _ts_project_impl(ctx):
249
240
250
241
return providers
251
242
243
+ def _tsconfig_inputs (ctx ):
244
+ """Returns all transitively referenced tsconfig files from "tsconfig" and "extends" attributes."""
245
+ inputs = []
246
+ if TsConfigInfo in ctx .attr .tsconfig :
247
+ inputs .extend (ctx .attr .tsconfig [TsConfigInfo ].deps )
248
+ else :
249
+ inputs .append (ctx .file .tsconfig )
250
+ if hasattr (ctx .attr , "extends" ) and ctx .attr .extends :
251
+ if TsConfigInfo in ctx .attr .extends :
252
+ inputs .extend (ctx .attr .extends [TsConfigInfo ].deps )
253
+ else :
254
+ inputs .extend (ctx .attr .extends .files .to_list ())
255
+ return inputs
256
+
252
257
ts_project = rule (
253
258
implementation = _ts_project_impl ,
254
259
attrs = dict (_ATTRS , ** _OUTPUTS ),
@@ -271,11 +276,7 @@ def _validate_options_impl(ctx):
271
276
ts_build_info_file = ctx .attr .ts_build_info_file ,
272
277
).to_json ()])
273
278
274
- inputs = ctx .files .extends [:]
275
- if TsConfigInfo in ctx .attr .tsconfig :
276
- inputs .extend (ctx .attr .tsconfig [TsConfigInfo ].deps )
277
- else :
278
- inputs .append (ctx .file .tsconfig )
279
+ inputs = _tsconfig_inputs (ctx )
279
280
280
281
run_node (
281
282
ctx ,
0 commit comments