Skip to content

Commit

Permalink
fix(builtin): fixes nodejs_binary to collect JSNamedModuleInfo
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lukas Holzer authored and alexeagle committed Jul 4, 2020
1 parent c1d4885 commit 4f95cc4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4f95cc4

Please sign in to comment.