From 09bd66272a0c0f60341abe276cc17a2e29f738e7 Mon Sep 17 00:00:00 2001 From: Matt Mackay Date: Sun, 9 May 2021 08:35:27 -0400 Subject: [PATCH] feat(esbuild): default log-level flag to warning, unless overridden --- packages/esbuild/esbuild.bzl | 15 +++++++++++++-- packages/esbuild/test/splitting/BUILD.bazel | 7 ++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/esbuild/esbuild.bzl b/packages/esbuild/esbuild.bzl index 1a14ebf50a..12247e2d8b 100644 --- a/packages/esbuild/esbuild.bzl +++ b/packages/esbuild/esbuild.bzl @@ -62,7 +62,6 @@ def _esbuild_impl(ctx): args.add("--preserve-symlinks") args.add_joined(["--platform", ctx.attr.platform], join_with = "=") args.add_joined(["--target", ctx.attr.target], join_with = "=") - args.add_joined(["--log-level", "info"], join_with = "=") args.add_joined(["--metafile", metafile.path], join_with = "=") args.add_all(ctx.attr.define, format_each = "--define:%s") args.add_all(ctx.attr.external, format_each = "--external:%s") @@ -111,7 +110,19 @@ def _esbuild_impl(ctx): args.add_joined(["--tsconfig", jsconfig_file.path], join_with = "=") inputs.append(jsconfig_file) - args.add_all([ctx.expand_location(arg) for arg in ctx.attr.args]) + log_level_flag = "--log-level" + has_log_level_flag = False + for arg in ctx.attr.args: + if arg.startswith(log_level_flag): + has_log_level_flag = True + + args.add(ctx.expand_location(arg)) + + # by default the log level is "info" and includes an output file summary + # under bazel this is slightly redundant and may lead to spammy logs + # unless the user overrides the log level, set it to only show warnings and errors + if not has_log_level_flag: + args.add_joined([log_level_flag, "warning"], join_with = "=") env = {} if ctx.attr.max_threads > 0: diff --git a/packages/esbuild/test/splitting/BUILD.bazel b/packages/esbuild/test/splitting/BUILD.bazel index 7b0f622bff..70a146e551 100644 --- a/packages/esbuild/test/splitting/BUILD.bazel +++ b/packages/esbuild/test/splitting/BUILD.bazel @@ -16,7 +16,12 @@ ts_library( esbuild( name = "bundle", - args = ["--keep-names"], + args = [ + # info log level may be helpful when splitting as esbuild will show each file emitted + # where as bazel will only list the output directory + "--log-level=info", + "--keep-names", + ], entry_point = "main.ts", output_dir = True, deps = [":main"],