Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: align handling of non-transpiled .js/.d.ts #746

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions ts/private/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
outputs.append(ctx.outputs.buildinfo_out)

output_sources = js_outs + map_outs + assets_outs + ctx.files.pretranspiled_js
output_types = typings_outs + typing_maps_outs + ctx.files.pretranspiled_dts

# Add JS inputs that collide with outputs (see #250).
#
# Unfortunately this duplicates logic in ts_lib._to_js_out_paths:
# files collide iff the following conditions are met:
# - They are JS files (ext in [js, json])
# - They are files not renamed when transpiled (ext in [.d.ts, js, json])
# - out_dir == root_dir
#
# The duplication is hard to avoid, since out_paths works on path strings
Expand All @@ -190,15 +191,13 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
for s in srcs_inputs:
if _lib.is_js_src(s.path, ctx.attr.allow_js, ctx.attr.resolve_json_module):
output_sources.append(s)

typings_srcs = [s for s in srcs_inputs if _lib.is_typings_src(s.path)]
if _lib.is_typings_src(s.path):
output_types.append(s)

# Make sure the user has acknowledged that transpiling is slow
if len(outputs) > 0 and ctx.attr.transpile == -1 and not ctx.attr.emit_declaration_only and not options.default_to_tsc_transpiler:
fail(transpiler_selection_required)

output_types = typings_outs + typing_maps_outs + typings_srcs + ctx.files.pretranspiled_dts

# What tsc will be emitting
use_tsc_for_js = len(js_outs) > 0
use_tsc_for_dts = len(typings_outs) > 0
Expand Down
Loading