|
1 | 1 | "Rules for running Rollup under Bazel"
|
2 | 2 |
|
3 | 3 | 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") |
4 | 5 | load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect", "register_node_modules_linker")
|
5 | 6 |
|
6 | 7 | _DOC = """Runs the Rollup.js CLI under Bazel.
|
@@ -151,7 +152,7 @@ Passed to the [`--sourcemap` option](https://github.com/rollup/rollup/blob/maste
|
151 | 152 | values = ["inline", "true", "false"],
|
152 | 153 | ),
|
153 | 154 | "deps": attr.label_list(
|
154 |
| - aspects = [module_mappings_aspect], |
| 155 | + aspects = [module_mappings_aspect, collect_node_modules_aspect], |
155 | 156 | doc = """Other libraries that are required by the code, or by the rollup.config.js""",
|
156 | 157 | ),
|
157 | 158 | }
|
@@ -247,6 +248,11 @@ def _rollup_bundle(ctx):
|
247 | 248 | deps_depsets.append(dep[JSEcmaScriptModuleInfo].sources)
|
248 | 249 | elif hasattr(dep, "files"):
|
249 | 250 | 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) |
250 | 256 | deps_inputs = depset(transitive = deps_depsets).to_list()
|
251 | 257 |
|
252 | 258 | inputs = _filter_js(ctx.files.entry_point) + _filter_js(ctx.files.entry_points) + ctx.files.srcs + deps_inputs
|
|
0 commit comments