Skip to content

Commit 8ffea3e

Browse files
authored
feat(esbuild): default log-level flag to warning, unless overridden (#2664)
1 parent 519cf85 commit 8ffea3e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/esbuild/esbuild.bzl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def _esbuild_impl(ctx):
6262
args.add("--preserve-symlinks")
6363
args.add_joined(["--platform", ctx.attr.platform], join_with = "=")
6464
args.add_joined(["--target", ctx.attr.target], join_with = "=")
65-
args.add_joined(["--log-level", "info"], join_with = "=")
6665
args.add_joined(["--metafile", metafile.path], join_with = "=")
6766
args.add_all(ctx.attr.define, format_each = "--define:%s")
6867
args.add_all(ctx.attr.external, format_each = "--external:%s")
@@ -111,7 +110,19 @@ def _esbuild_impl(ctx):
111110
args.add_joined(["--tsconfig", jsconfig_file.path], join_with = "=")
112111
inputs.append(jsconfig_file)
113112

114-
args.add_all([ctx.expand_location(arg) for arg in ctx.attr.args])
113+
log_level_flag = "--log-level"
114+
has_log_level_flag = False
115+
for arg in ctx.attr.args:
116+
if arg.startswith(log_level_flag):
117+
has_log_level_flag = True
118+
119+
args.add(ctx.expand_location(arg))
120+
121+
# by default the log level is "info" and includes an output file summary
122+
# under bazel this is slightly redundant and may lead to spammy logs
123+
# unless the user overrides the log level, set it to only show warnings and errors
124+
if not has_log_level_flag:
125+
args.add_joined([log_level_flag, "warning"], join_with = "=")
115126

116127
env = {}
117128
if ctx.attr.max_threads > 0:

packages/esbuild/test/splitting/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ ts_library(
1616

1717
esbuild(
1818
name = "bundle",
19-
args = ["--keep-names"],
19+
args = [
20+
# info log level may be helpful when splitting as esbuild will show each file emitted
21+
# where as bazel will only list the output directory
22+
"--log-level=info",
23+
"--keep-names",
24+
],
2025
entry_point = "main.ts",
2126
output_dir = True,
2227
deps = [":main"],

0 commit comments

Comments
 (0)