Skip to content

Commit

Permalink
feat(esbuild): default log-level flag to warning, unless overridden (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattem authored May 11, 2021
1 parent 519cf85 commit 8ffea3e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 13 additions & 2 deletions packages/esbuild/esbuild.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion packages/esbuild/test/splitting/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 8ffea3e

Please sign in to comment.