Make it more convenient to get a perf trace for TypeScript compilation.
Only enabling perf_trace for a specific label also avoids having to rebuild all of its transitive dependencies when changing the flag.
Usage:
bazel build --define TYPESCRIPT_PERF_TRACE_TARGET=//some:target //whatever:target
PiperOrigin-RevId: 183985921
diff --git a/internal/common/compilation.bzl b/internal/common/compilation.bzl
index 5125c27..995baaa 100644
--- a/internal/common/compilation.bzl
+++ b/internal/common/compilation.bzl
@@ -203,6 +203,8 @@
# The trace file location will be printed as a build result and can be read
# in Chrome's chrome://tracing/ UI.
perf_trace = False
+ if "TYPESCRIPT_PERF_TRACE_TARGET" in ctx.var:
+ perf_trace = str(ctx.label) == ctx.var["TYPESCRIPT_PERF_TRACE_TARGET"]
compilation_inputs = input_declarations + extra_dts_files + srcs
tsickle_externs_path = tsickle_externs[0] if tsickle_externs else None