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 args attribute to rollup_bundle rule #1681

Merged
merged 1 commit into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/rollup/src/rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ You must not repeat file(s) passed to entry_point/entry_points.
# Don't try to constrain the filenames, could be json, svg, whatever
allow_files = True,
),
"args": attr.string_list(
doc = """Command line arguments to pass to rollup. Can be used to override config file settings.

These argument passed on the command line before all arguments that are always added by the
rule such as `--output.dir` or `--output.file`, `--format`, `--config` and `--preserveSymlinks` and
also those that are optionally added by the rule such as `--sourcemap`.

See rollup CLI docs https://rollupjs.org/guide/en/#command-line-flags for complete list of supported arguments.""",
default = [],
),
"config_file": attr.label(
doc = """A rollup.config.js file

Expand Down Expand Up @@ -286,6 +296,9 @@ def _rollup_bundle(ctx):
# See CLI documentation at https://rollupjs.org/guide/en/#command-line-reference
args = ctx.actions.args()

# Add user specified arguments *before* rule supplied arguments
args.add_all(ctx.attr.args)

# List entry point argument first to save some argv space
# Rollup doc says
# When provided as the first options, it is equivalent to not prefix them with --input
Expand Down
5 changes: 5 additions & 0 deletions packages/rollup/test/sourcemaps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ load("@npm_bazel_rollup//:index.from_src.bzl", "rollup_bundle")
rollup_bundle(
name = "bundle",
srcs = ["s.js"],
# Test existance of args attribute
args = [
"--environment",
"FOO,BAR:baz",
],
# Use the desugared form to assert that it works
entry_points = {"input.js": "bundle"},
sourcemap = "true",
Expand Down