https://github.com/angular/angular
Raw File
Tip revision: f1a2816ba9432b3bf186c94e5f538d72d992dca4 authored by Andrew Kushnir on 06 April 2022, 15:58:29 UTC
release: cut the v14.0.0-next.11 release (#45550)
Tip revision: f1a2816
extract_typings_rule.bzl
"""Starlark file that exposes a rule for extracting type definitions of dependencies."""

load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo")

def _extract_typings_rule_impl(ctx):
    """Implementation of the `extract_typings` rule."""
    transitive_depsets = []

    for dep in ctx.attr.deps:
        # Based on whether declarations should be collected, extract direct
        # and transitive declaration files using the `DeclarationInfo` provider.
        if DeclarationInfo in dep:
            transitive_depsets.append(dep[DeclarationInfo].transitive_declarations)

    return [DefaultInfo(files = depset(transitive = transitive_depsets))]

# TODO: Move into shared dev-infra package.
extract_typings = rule(
    implementation = _extract_typings_rule_impl,
    doc = """Rule that extracts all transitive typings of dependencies""",
    attrs = {
        "deps": attr.label_list(
            allow_files = True,
        ),
    },
)
back to top