Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rollup): add silent attr to rollup_bundle to support --silent flag #1680

Merged
merged 3 commits into from
Mar 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/rollup/src/rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ Otherwise, the outputs are assumed to be a single file.
cfg = "host",
default = "@npm//rollup/bin:rollup",
),
"silent": attr.bool(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a warning in this doc that using silent can cause rollup to ignore problems in your code, and link to https://github.com/rollup/rollup/blob/master/docs/999-big-list-of-options.md#onwarn and maybe rollup/rollup#2686 ?

You could also mention that Bazel expects tools to print nothing on success, so enabling --silent gives a more Bazel-idiomatic experience, but the default here is False due to how it also drops warnings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I added this information to the attr docstring.

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 @@ -303,6 +311,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