Skip to content

Commit

Permalink
feat(rollup): add silent attr to rollup_bundle to support --silent fl…
Browse files Browse the repository at this point in the history
…ag (#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
  • Loading branch information
josephperrott committed Mar 2, 2020
1 parent 94c6182 commit 18e8001
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/rollup/src/rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ Otherwise, the outputs are assumed to be a single file.
cfg = "host",
default = "@npm//rollup/bin:rollup",
),
"silent": attr.bool(
doc = """Whether to execute the rollup binary with the --silent flag, defaults to False.
Using --silent can cause rollup to [ignore errors/warnings](https://github.com/rollup/rollup/blob/master/docs/999-big-list-of-options.md#onwarn)
which are only surfaced via logging. Since bazel expects printing nothing on success, setting silent to True
is a more Bazel-idiomatic experience, however could cause rollup to drop important warnings.
""",
),
"sourcemap": attr.string(
doc = """Whether to produce sourcemaps.
Expand Down Expand Up @@ -316,6 +324,10 @@ def _rollup_bundle(ctx):

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

if ctx.attr.silent:
# Run the rollup binary with the --silent flag
args.add("--silent")

stamp = ctx.attr.node_context_data[NodeContextInfo].stamp

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

0 comments on commit 18e8001

Please sign in to comment.