mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
27535bfb79
This wires up the `@angular/localize/tools` entry-point. For context: This entry-point is being created to avoid deep imports into `@angular/localize/src/tools/<..>` like the CLI relies on. Deep imports do not play well with strict ESM, and now that all APF packages are strict ESM, the tool code needs to be either strict ESM as well. We use ESBuild to create individual bundles for the CLI entry-points, and the actual tool entry-point. We use a bundler because this enables the localize code be ESM compatible. Without a bundler, all relative imports within the `tools` entry-point would need to explicitly have the `.js` extension. This would be cumbersome and hard to maintain/enforce or validate. One might wonder why this is not a standard APF entry-point then. The answer is that the APF entry-points do not support exposing the CLI binaries (like `yarn localize-translate`). This could be done through tertiary entry-points, but using ESBuild directly gives us more control for now. We might want to revisit this in the future again. PR Close #43431
27 lines
955 B
Python
27 lines
955 B
Python
"""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,
|
|
),
|
|
},
|
|
)
|