@@ -5,7 +5,6 @@ inputs and produces JavaScript or declaration (.d.ts) outputs.
55"""
66
77load ("@aspect_bazel_lib//lib:utils.bzl" , "to_label" )
8- load ("@aspect_rules_js//js:defs.bzl" , "js_library" )
98load ("@bazel_skylib//lib:partial.bzl" , "partial" )
109load ("//ts/private:build_test.bzl" , "build_test" )
1110load ("//ts/private:ts_config.bzl" , "write_tsconfig" , _TsConfigInfo = "TsConfigInfo" , _ts_config = "ts_config" )
@@ -340,7 +339,6 @@ def ts_project(
340339 emit_tsc_dts = emit_dts and not emit_transpiler_dts
341340
342341 # Target names for tsc, dts+js transpilers
343- tsc_target_name = name
344342 declarations_target_name = None
345343 transpile_target_name = None
346344
@@ -368,35 +366,6 @@ def ts_project(
368366 transpile_target_name = "%s_transpile" % name
369367 _invoke_custom_transpiler ("transpiler" , transpiler , transpile_target_name , srcs , common_kwargs )
370368
371- # Default target produced by the macro gives the js, dts and map outs,
372- # with the transitive dependencies.
373- if transpile_target_name or declarations_target_name :
374- tsc_target_name = "%s_tsc" % name
375-
376- # Always include tsc target since even if it doesn't output js+dts, it may
377- # still be needed for JSON files to be included in the sources. Downstream
378- # dependencies of the js_library won't inadvertently cause this target to be
379- # typechecked when both transpiler targets for js+dts are present because
380- # the js_library doesn't include the ".typecheck" file which is only in the
381- # "typecheck" output group.
382- lib_srcs = [tsc_target_name ]
383-
384- # Include the transpiler targets for both js+dts if they exist.
385- if transpile_target_name :
386- lib_srcs .append (transpile_target_name )
387- if declarations_target_name :
388- lib_srcs .append (declarations_target_name )
389-
390- # Include direct & transitive deps in addition to transpiled sources so
391- # that this js_library can be a valid dep for downstream ts_project or other rules_js derivative rules.
392- js_library (
393- name = name ,
394- srcs = lib_srcs + assets ,
395- deps = deps ,
396- data = data ,
397- ** common_kwargs
398- )
399-
400369 # If the primary target does not output dts files then type-checking has a separate target.
401370 if not emit_tsc_js or not emit_tsc_dts :
402371 types_target_name = "%s_types" % name
@@ -415,15 +384,15 @@ def ts_project(
415384 # tsc outputs the types and must be extracted via output_group
416385 native .filegroup (
417386 name = types_target_name ,
418- srcs = [tsc_target_name ],
387+ srcs = [name ],
419388 output_group = "types" ,
420389 ** common_kwargs
421390 )
422391
423392 # Users should build this target to get a failed build when typechecking fails
424393 native .filegroup (
425394 name = typecheck_target_name ,
426- srcs = [tsc_target_name ],
395+ srcs = [name ],
427396 output_group = "typecheck" ,
428397 ** common_kwargs
429398 )
@@ -453,7 +422,7 @@ def ts_project(
453422 })
454423
455424 ts_project_rule (
456- name = tsc_target_name ,
425+ name = name ,
457426 srcs = srcs ,
458427 args = args ,
459428 assets = assets ,
@@ -485,6 +454,8 @@ def ts_project(
485454 tsc_worker = tsc_worker ,
486455 transpile = - 1 if not transpiler else int (transpiler == "tsc" ),
487456 declaration_transpile = declaration_transpiler != None ,
457+ pretranspiled_js = transpile_target_name ,
458+ pretranspiled_dts = declarations_target_name ,
488459 supports_workers = supports_workers ,
489460 is_typescript_5_or_greater = is_typescript_5_or_greater ,
490461 validate = validate ,
0 commit comments