Skip to content

Commit 18e8001

Browse files
feat(rollup): add silent attr to rollup_bundle to support --silent flag (#1680)
* feat(rollup): add silent attr to rollup_bundle to support --silent flag As rollup_bundle already supports specific rollup flags with specific attributes on the rollup_bundle rule, adding a boolean attribute for silent makes the most sense. This boolean determines if the --silent flag is added to the rollup command when called. * fixup! fix(examples): change build target label to //src:prodapp * fixup! fix(examples): change build target label to //src:prodapp
1 parent 94c6182 commit 18e8001

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/rollup/src/rollup_bundle.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ Otherwise, the outputs are assumed to be a single file.
178178
cfg = "host",
179179
default = "@npm//rollup/bin:rollup",
180180
),
181+
"silent": attr.bool(
182+
doc = """Whether to execute the rollup binary with the --silent flag, defaults to False.
183+
184+
Using --silent can cause rollup to [ignore errors/warnings](https://github.com/rollup/rollup/blob/master/docs/999-big-list-of-options.md#onwarn)
185+
which are only surfaced via logging. Since bazel expects printing nothing on success, setting silent to True
186+
is a more Bazel-idiomatic experience, however could cause rollup to drop important warnings.
187+
""",
188+
),
181189
"sourcemap": attr.string(
182190
doc = """Whether to produce sourcemaps.
183191
@@ -316,6 +324,10 @@ def _rollup_bundle(ctx):
316324

317325
args.add_all(["--format", ctx.attr.format])
318326

327+
if ctx.attr.silent:
328+
# Run the rollup binary with the --silent flag
329+
args.add("--silent")
330+
319331
stamp = ctx.attr.node_context_data[NodeContextInfo].stamp
320332

321333
config = ctx.actions.declare_file("_%s.rollup_config.js" % ctx.label.name)

0 commit comments

Comments
 (0)