I am trying to sort out how to correctly use rollup_bundle()
in bazel in a workspace using multiple languages, including JavaScript, and defining multiple npm packages in different directories.
It appears that the rollup bazel rules assume a more centralized setup than I would like: in the context of this workspace I would like each npm package to manage its own node_modules
(see WORKSPACE.bazel
in reproducible).
Small reproducible (toy example):
$ bazel build //js/alpha
Starting local Bazel server and connecting to it...
ERROR: /path/to/bazel-nodejs-rollup-multi-package/js/alpha/BUILD.bazel:6:14: every rule of type rollup_bundle implicitly depends upon the target '//@bazel/rollup/bin:rollup-worker', but this target could not be found because of: no such package '@bazel/rollup/bin': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
- /path/to/bazel-nodejs-rollup-multi-package/@bazel/rollup/bin
Documentation for implicit attribute rollup_worker_bin of rules of type rollup_bundle:
Internal use only
ERROR: Analysis of target '//js/alpha:alpha' failed; build aborted: Analysis failed
INFO: Elapsed time: 2.363s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 5 targets configured)
currently loading: @rules_nodejs//nodejs/stamp
This error seems to suggest that I may need to specify rollup_bin
and/or rollup_worker_bin
, but I have had no luck attempting to refer to sources in //js/alpha/node_modules/@bazel/...
or //js/alpha/node_modules/rollup/...
. The npm documentation for @bazel/rollup suggests that because I am using npm_install()
to set up my in-tree npm packages I should not need to set rollup_bin
(because related instructions begin with "If you didn't use the yarn_install
or npm_install
rule, [...]").
How do I keep my multiple-npm-packages-in-same-workspace setup while using bazel rules to run rollup?