Repository navigation
Description
🐞 bug report
Affected Rule
ts_library() possibly? In my reproduction, it is the only bazelbuild/rules_typescript rule being used.
Is this a regression?
I have only checked this behavior with v0.22.1.
Description
When using rollup_bundle() (from bazelbuild/rules_nodejs) on the output of a ts_library() rule, I need to either re-specify the (full, transitive) set of fine-grained dependencies used by the ts_library() rule, or node_modules = "@npm//:node_modules" (which is supposed to be deprecated, or at least discouraged).
I expected that the transitive set of fine-grained dependencies would be aggregated by ts_library(), and made available to rollup_bundle(), but that does not appear to be the case. As it is impractical to repeat the full list of dependencies in calling rollup_bundle(), I seem to have to fall back on using the full @npm//:node_modules filegroup.
🔬 Minimal Reproduction
🔥 Exception or Error
$ bazel build //:bundle
INFO: Invocation ID: 4adabf83-5c54-499c-9dae-038ef7841983
INFO: Analysed target //:bundle (0 packages loaded, 1 target configured).
INFO: Found 1 target...
ERROR: /usr/home/james/pg/bazel-typescript-npm-dep/BUILD:9:1: SkylarkAction bundle.es6.js failed (Exit 1) rollup failed: error executing command bazel-out/host/bin/external/build_bazel_rules_nodejs/internal/rollup/rollup --config bazel-out/freebsd-fastbuild/bin/_bundle.rollup.conf.js --output.file bazel-out/freebsd-fastbuild/bin/bundle.es6.js ... (remaining 4
argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
[!] (Plugin at pos 2 plugin) Error: Could not resolve import 'lit-html' from '/usr/home/james/.cache/bazel/_bazel_james/88a369858ad9d1bd75821a00db0f8b09/sandbox/processwrapper-sandbox/1/execroot/demo/bazel-out/freebsd-fastbuild/bin/bundle.es6/lib.js'
WARNING: Due to a breaking change in rules_nodejs 0.13.2, target //:bundle
must now declare either an explicit node_modules attribute, or
list explicit deps[] fine grained dependencies on npm labels
if it has any node_modules dependencies.
See https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-rules_nodejs-013
Error: Could not resolve import 'lit-html' from '/usr/home/james/.cache/bazel/_bazel_james/88a369858ad9d1bd75821a00db0f8b09/sandbox/processwrapper-sandbox/1/execroot/demo/bazel-out/freebsd-fastbuild/bin/bundle.es6/lib.js'
WARNING: Due to a breaking change in rules_nodejs 0.13.2, target //:bundle
must now declare either an explicit node_modules attribute, or
list explicit deps[] fine grained dependencies on npm labels
if it has any node_modules dependencies.
See https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-rules_nodejs-013
at Object.notResolved (/usr/home/james/.cache/bazel/_bazel_james/88a369858ad9d1bd75821a00db0f8b09/execroot/demo/bazel-out/freebsd-fastbuild/bin/_bundle.rollup.conf.js:109:11)
at /usr/home/james/.cache/bazel/_bazel_james/88a369858ad9d1bd75821a00db0f8b09/sandbox/processwrapper-sandbox/1/execroot/demo/bazel-out/host/bin/external/build_bazel_rules_nodejs/internal/rollup/rollup.runfiles/build_bazel_rules_nodejs_rollup_deps/node_modules/rollup/dist/rollup.js:20831:25
Target //:bundle failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.538s, Critical Path: 0.46s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
$ bazel build //:bundle_with_dep //:bundle_with_modules
INFO: Invocation ID: 9563f6e6-7d48-4945-87ed-3735833c89a2
INFO: Analysed 2 targets (1 packages loaded, 49 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 2.933s, Critical Path: 2.84s
INFO: 6 processes: 6 processwrapper-sandbox.
INFO: Build completed successfully, 148 total actions
🌍 Your Environment
Operating System:
$ uname -srm
FreeBSD 11.2-STABLE amd64
Output of bazel version:
$ bazel version
INFO: Invocation ID: ef5df72e-2399-4c76-9afd-f2a7c87208b9
Build label: 0.21.0
Build target: bazel-out/freebsd-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Dec 18 09:59:39 2018 (1545127179)
Build timestamp: 1545127179
Build timestamp as int: 1545127179
Rules version (SHA):
Activity
alexeagle commentedon Feb 21, 2019
Yeah in many cases the values and types come from two different labels, so it's expected to have
ts_library(deps = ["@npm//@types/foo"])rollup_bundle(deps = ["@npm//foo"])but in cases where types and values are together in one label I agree that ts_library should propagate these in the "data" providers so rollup_bundle finds them