Skip to content

Commit 6f0502f

Browse files
committed
feat: support custom progress messages
For Angular we fully rely on `ts_project` just with a custom `tsc` executable. We would like to have better distinction between Angular or TypeScript targets. It seems like it would be useful to control the progress message. This would also allow better distinction when e.g. compiling with a different configuration. e.g. we use a transition for Angular to compile with a different compilation mode when shipping to npm.
1 parent f332843 commit 6f0502f

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

ts/private/ts_lib.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ https://docs.aspect.build/rulesets/aspect_rules_js/docs/js_library#deps for more
115115
settings in the tsconfig.json file""",
116116
default = True,
117117
),
118+
"build_progress_message": attr.string(
119+
doc = "Custom progress message for the build action.",
120+
),
121+
"isolated_typecheck_progress_message": attr.string(
122+
doc = "Custom progress message for the isolated typecheck action.",
123+
),
118124
"validator": attr.label(mandatory = True, executable = True, cfg = "exec"),
119125
"_options": attr.label(
120126
default = "@aspect_rules_ts//ts:options",

ts/private/ts_project.bzl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
277277
else:
278278
env["JS_BINARY__STDOUT_OUTPUT_FILE"] = typecheck_output.path
279279

280+
default_progress_message = "Type-checking TypeScript project %s [tsc -p %s]" % (
281+
ctx.label,
282+
tsconfig_path,
283+
)
284+
280285
ctx.actions.run(
281286
executable = executable,
282287
inputs = tsc_transitive_inputs_depset,
@@ -285,10 +290,7 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
285290
mnemonic = "TsProjectCheck",
286291
execution_requirements = execution_requirements,
287292
resource_set = resource_set(ctx.attr),
288-
progress_message = "Type-checking TypeScript project %s [tsc -p %s]" % (
289-
ctx.label,
290-
tsconfig_path,
291-
),
293+
progress_message = ctx.attr.isolated_typecheck_progress_message if ctx.attr.isolated_typecheck_progress_message else default_progress_message,
292294
env = env,
293295
)
294296
else:
@@ -323,6 +325,15 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
323325
tsc_emit_arguments.use_param_file("@%s", use_always = True)
324326
tsc_emit_arguments.set_param_file_format("multiline")
325327

328+
default_progress_message = "Transpiling%s%s TypeScript project %s [tsc -p %s]" % (
329+
# Mention what is being emitted if not both
330+
"" if use_tsc_for_dts and use_tsc_for_js else " (dts)" if use_tsc_for_dts else " (js)",
331+
# Mention type-checking if done in this action
332+
" & type-checking" if not ctx.attr.isolated_typecheck else "",
333+
ctx.label,
334+
tsconfig_path,
335+
)
336+
326337
ctx.actions.run(
327338
executable = executable,
328339
inputs = inputs_depset,
@@ -331,14 +342,7 @@ See https://github.com/aspect-build/rules_ts/issues/361 for more details.
331342
mnemonic = "TsProjectEmit" if ctx.attr.isolated_typecheck else "TsProject",
332343
execution_requirements = execution_requirements,
333344
resource_set = resource_set(ctx.attr),
334-
progress_message = "Transpiling%s%s TypeScript project %s [tsc -p %s]" % (
335-
# Mention what is being emitted if not both
336-
"" if use_tsc_for_dts and use_tsc_for_js else " (dts)" if use_tsc_for_dts else " (js)",
337-
# Mention type-checking if done in this action
338-
" & type-checking" if not ctx.attr.isolated_typecheck else "",
339-
ctx.label,
340-
tsconfig_path,
341-
),
345+
progress_message = ctx.attr.build_progress_message if ctx.attr.build_progress_message else default_progress_message,
342346
env = {
343347
"BAZEL_BINDIR": ctx.bin_dir.path,
344348
},

0 commit comments

Comments
 (0)