Skip to content

Commit 77289e0

Browse files
committed
fix(rollup): handle transitive npm deps in rollup_bundle
1 parent 9c2d831 commit 77289e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/rollup/src/rollup_bundle.bzl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"Rules for running Rollup under Bazel"
22

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

67
_DOC = """Runs the Rollup.js CLI under Bazel.
@@ -151,7 +152,7 @@ Passed to the [`--sourcemap` option](https://github.com/rollup/rollup/blob/maste
151152
values = ["inline", "true", "false"],
152153
),
153154
"deps": attr.label_list(
154-
aspects = [module_mappings_aspect],
155+
aspects = [module_mappings_aspect, collect_node_modules_aspect],
155156
doc = """Other libraries that are required by the code, or by the rollup.config.js""",
156157
),
157158
}
@@ -247,6 +248,11 @@ def _rollup_bundle(ctx):
247248
deps_depsets.append(dep[JSEcmaScriptModuleInfo].sources)
248249
elif hasattr(dep, "files"):
249250
deps_depsets.append(dep.files)
251+
252+
# Also include files from npm deps as inputs.
253+
# These deps are identified by the NodeModuleSources provider.
254+
if NodeModuleSources in dep:
255+
deps_depsets.append(dep[NodeModuleSources].sources)
250256
deps_inputs = depset(transitive = deps_depsets).to_list()
251257

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

0 commit comments

Comments
 (0)