mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(bazel): allow ng_package to work with rules_js dependencies (#59316)
Currently the module mapping aspect fails when it transitively discovers a node module target managed by `rules_js`. That is because the targets don't have a `deps` attribute as part of their rule definition. PR Close #59316
This commit is contained in:
parent
8c5db3cfb7
commit
f8d22a9ba4
1 changed files with 12 additions and 7 deletions
|
|
@ -37,13 +37,18 @@ _NG_PACKAGE_MODULE_MAPPINGS_ATTR = "ng_package_module_mappings"
|
|||
|
||||
def _ng_package_module_mappings_aspect_impl(target, ctx):
|
||||
mappings = dict()
|
||||
for dep in ctx.rule.attr.deps:
|
||||
if hasattr(dep, _NG_PACKAGE_MODULE_MAPPINGS_ATTR):
|
||||
for k, v in getattr(dep, _NG_PACKAGE_MODULE_MAPPINGS_ATTR).items():
|
||||
if k in mappings and mappings[k] != v:
|
||||
fail(("duplicate module mapping at %s: %s maps to both %s and %s" %
|
||||
(target.label, k, mappings[k], v)), "deps")
|
||||
mappings[k] = v
|
||||
|
||||
# Note: the target might not have `deps`. e.g.
|
||||
# in `rules_js`, node module targets don't have such attribute.
|
||||
if hasattr(ctx.rule.attr, "deps"):
|
||||
for dep in ctx.rule.attr.deps:
|
||||
if hasattr(dep, _NG_PACKAGE_MODULE_MAPPINGS_ATTR):
|
||||
for k, v in getattr(dep, _NG_PACKAGE_MODULE_MAPPINGS_ATTR).items():
|
||||
if k in mappings and mappings[k] != v:
|
||||
fail(("duplicate module mapping at %s: %s maps to both %s and %s" %
|
||||
(target.label, k, mappings[k], v)), "deps")
|
||||
mappings[k] = v
|
||||
|
||||
if ((hasattr(ctx.rule.attr, "module_name") and ctx.rule.attr.module_name) or
|
||||
(hasattr(ctx.rule.attr, "module_root") and ctx.rule.attr.module_root)):
|
||||
mn = ctx.rule.attr.module_name
|
||||
|
|
|
|||
Loading…
Reference in a new issue