bazel-contrib / rules_nodejs

NodeJS toolchain for Bazel.
https://bazelbuild.github.io/rules_nodejs/
Apache License 2.0
729 stars 523 forks source link

fix: make CcInfo/cc dep in nodejs toolchain opt-in via include_headers attribute #3760

Closed gregmagolan closed 5 months ago

gregmagolan commented 5 months ago

Fixes https://github.com/bazelbuild/rules_nodejs/issues/3722.

Having a cc_library target always included in the headers field of the NodeInfo provided by the Node.js toolchain means that there must be always c++ toolchain available when using rules_nodejs which is not desirable. This change makes the cc_library target in headers an opt-in via the include_headers attribute.

Users can set this attribute as follows,

WORKSPACE:

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
nodejs_register_toolchains(include_headers = True, ...)

MODULE.bazel

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(include_headers = True, ...)