mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Instead of relying on Microsoft's API extractor for `d.ts` bundling, we are switching to Rollup-based `.d.ts` bundling. This allows us to support code spliting, even for `.d.ts` files, allowing for relative imports to be used between entry-points, without ending up duplicating `.d.ts` definitions in two files. This would otherwise cause problems with assignability of types. It also nicely integrates into our existing rollup configuration, and overall simplifies the `ng_package` rule even further! Notably `tsup` also uses this rollup plugin, and it seems to work well. Keep in mind that Microsoft's API extractor is pretty hard to integrate, caused many problems in the past, and isn't capable of code splitting. This aligns our d.ts bundling with the .mjs bundling (great alignment). PR Close #60321 PR Close #60332
74 lines
1.9 KiB
Text
74 lines
1.9 KiB
Text
load("//tools:defaults.bzl", "api_golden_test_npm_package", "generate_api_docs", "ng_package", "ts_library")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
ts_library(
|
|
name = "localize",
|
|
srcs = glob(
|
|
[
|
|
"*.ts",
|
|
"src/**/*.ts",
|
|
],
|
|
),
|
|
module_name = "@angular/localize",
|
|
deps = [
|
|
"//packages/localize/src/localize",
|
|
"//packages/localize/src/utils",
|
|
],
|
|
)
|
|
|
|
ng_package(
|
|
name = "npm_package",
|
|
package_name = "@angular/localize",
|
|
srcs = [
|
|
"package.json",
|
|
],
|
|
nested_packages = [
|
|
"//packages/localize/schematics:npm_package",
|
|
"//packages/localize/tools:npm_package",
|
|
],
|
|
side_effect_entry_points = [
|
|
"@angular/localize/init",
|
|
],
|
|
tags = [
|
|
"release-with-framework",
|
|
],
|
|
deps = [
|
|
":localize",
|
|
"//packages/localize/init",
|
|
],
|
|
)
|
|
|
|
api_golden_test_npm_package(
|
|
name = "localize_api",
|
|
data = [
|
|
":npm_package",
|
|
"//goldens:public-api",
|
|
],
|
|
golden_dir = "angular/goldens/public-api/localize",
|
|
npm_package = "angular/packages/localize/npm_package",
|
|
# The logic for the localize function is exported in the primary entry-point, but users
|
|
# are not supposed to import it from there. We still want to guard these exports though.
|
|
strip_export_pattern = "^ɵ(?!.localize|LocalizeFn|TranslateFn)",
|
|
# The tool entry-point uses namespace aliases and API extractor needs to be
|
|
# able to resolve `@babel/core` to fully understand the `types` re-export/alias.
|
|
types = ["@npm//@types/babel__core"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "files_for_docgen",
|
|
srcs = glob([
|
|
"*.ts",
|
|
"src/**/*.ts",
|
|
]) + ["PACKAGE.md"],
|
|
)
|
|
|
|
generate_api_docs(
|
|
name = "localize_docs",
|
|
srcs = [
|
|
":files_for_docgen",
|
|
"//packages/localize/src/utils:files_for_docgen",
|
|
],
|
|
entry_point = ":index.ts",
|
|
module_name = "@angular/localize",
|
|
)
|