Skip to content

Commit

Permalink
fix(rollup): handle transitive npm deps in rollup_bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Oct 4, 2019
1 parent 9c2d831 commit 77289e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/rollup/src/rollup_bundle.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"Rules for running Rollup under Bazel"

load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo")
load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleSources", "collect_node_modules_aspect")
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect", "register_node_modules_linker")

_DOC = """Runs the Rollup.js CLI under Bazel.
Expand Down Expand Up @@ -151,7 +152,7 @@ Passed to the [`--sourcemap` option](https://github.com/rollup/rollup/blob/maste
values = ["inline", "true", "false"],
),
"deps": attr.label_list(
aspects = [module_mappings_aspect],
aspects = [module_mappings_aspect, collect_node_modules_aspect],
doc = """Other libraries that are required by the code, or by the rollup.config.js""",
),
}
Expand Down Expand Up @@ -247,6 +248,11 @@ def _rollup_bundle(ctx):
deps_depsets.append(dep[JSEcmaScriptModuleInfo].sources)
elif hasattr(dep, "files"):
deps_depsets.append(dep.files)

# Also include files from npm deps as inputs.
# These deps are identified by the NodeModuleSources provider.
if NodeModuleSources in dep:
deps_depsets.append(dep[NodeModuleSources].sources)
deps_inputs = depset(transitive = deps_depsets).to_list()

inputs = _filter_js(ctx.files.entry_point) + _filter_js(ctx.files.entry_points) + ctx.files.srcs + deps_inputs
Expand Down

0 comments on commit 77289e0

Please sign in to comment.