From 4f95cc4cb6898081ef3693ed1793cb4cef512861 Mon Sep 17 00:00:00 2001 From: Lukas Holzer Date: Fri, 3 Jul 2020 10:38:37 +0200 Subject: [PATCH] fix(builtin): fixes nodejs_binary to collect JSNamedModuleInfo To be backwards compatible with earlier versions still support the `JSNamedModuleInfo` provider for nodejs_binary dependencies along with the new `JSModuleInfo`. This should help dependencies to transition to the new provider without having to patch it. Fixes #1998 --- internal/node/node.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/node/node.bzl b/internal/node/node.bzl index 05cd6d9daa..6da9759278 100644 --- a/internal/node/node.bzl +++ b/internal/node/node.bzl @@ -20,7 +20,7 @@ They support module mapping: any targets in the transitive dependencies with a `module_name` attribute can be `require`d by that name. """ -load("//:providers.bzl", "JSModuleInfo", "NodeRuntimeDepsInfo", "NpmPackageInfo", "node_modules_aspect") +load("//:providers.bzl", "JSModuleInfo", "JSNamedModuleInfo", "NodeRuntimeDepsInfo", "NpmPackageInfo", "node_modules_aspect") load("//internal/common:expand_into_runfiles.bzl", "expand_location_into_runfiles") load("//internal/common:module_mappings.bzl", "module_mappings_runtime_aspect") load("//internal/common:path_utils.bzl", "strip_external") @@ -167,6 +167,11 @@ def _nodejs_binary_impl(ctx): for d in ctx.attr.data: if JSModuleInfo in d: sources_depsets.append(d[JSModuleInfo].sources) + + # Deprecated should be removed with version 3.x.x at least have a transition phase + # for dependencies to provide the output under the JSModuleInfo instead. + if JSNamedModuleInfo in d: + sources_depsets.append(d[JSNamedModuleInfo].sources) if hasattr(d, "files"): sources_depsets.append(d.files) sources = depset(transitive = sources_depsets)