mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Prior to this, the `@angular/localize/init` was added as a polyfill which caused the `@angular/localize` types not to be included in the TypeScript program which caused errors such as the below: ``` Error: src/app/app.component.ts:9:11 - error TS2304: Cannot find name '$localize'. ``` With the recent changes in the CLI (https://github.com/angular/angular-cli/pull/24032), adding `@angular/localize/init` as polyfil or in the `main.server.ts` is no longer necessary. Instead we add this as a TypeScript type. When users are running in JIT mode, we add `@angular/localize/init` as an additional entrypoint. This change also exposes the `$localize` method as a global when importing `@angular/localize`. Closes #47677 PR Close #47763
64 lines
1.8 KiB
Text
64 lines
1.8 KiB
Text
load("//tools:defaults.bzl", "api_golden_test_npm_package", "extract_types", "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",
|
|
],
|
|
)
|
|
|
|
extract_types(
|
|
name = "api_type_definitions",
|
|
deps = [":localize"],
|
|
)
|
|
|
|
ng_package(
|
|
name = "npm_package",
|
|
srcs = [
|
|
"package.json",
|
|
":api_type_definitions",
|
|
],
|
|
nested_packages = [
|
|
"//packages/localize/schematics:npm_package",
|
|
"//packages/localize/tools:npm_package",
|
|
],
|
|
skip_type_bundling = [
|
|
# For the primary entry-point we disable type bundling because API extractor
|
|
# does not properly handle module augumentation.
|
|
# TODO: Remove once https://github.com/microsoft/rushstack/issues/2090 is solved.
|
|
"",
|
|
],
|
|
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"],
|
|
)
|