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

Conversation

josephperrott
Copy link
Collaborator

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.

I was unable to add tests for this as its change is to the stdout of the execution
of bazel, not the results of the rollup command.

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.
@alexeagle
Copy link
Collaborator

Note: related to #1661 which was also for --silent.

My take is: we wrap rollup in a custom rule, and attrs like sourcemap make sense for Bazel to know about since they affect the output files. So we should continue to mirror the Rollup API in attributes.

This has an unfortunate meaning in rollup - --silent also causes builds to pass that would have otherwise failed, because they treat many fatal conditions as a warning and you have to supply a custom handler to find out about these if you use --silent https://github.com/rollup/rollup/blob/master/docs/999-big-list-of-options.md#onwarn
so that's why we can't make the default here True, which would make it more Bazel-idiomatic.

@@ -168,6 +168,9 @@ 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.

Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

thanks

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 nother on success, setting silent to True
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: nother->nothing

Copy link
Collaborator

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

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

🌮

@gregmagolan gregmagolan merged commit 18e8001 into bazelbuild:master Mar 2, 2020
@josephperrott josephperrott deleted the rollup branch March 2, 2020 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants