2021-05-21 16:58:25 -04:00
|
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
|
|
|
|
load("//packages/common/locales:index.bzl", "LOCALES", "generate_all_locale_files", "generate_closure_locales_file")
|
2019-12-28 19:37:59 -05:00
|
|
|
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
|
2017-12-16 23:08:49 -05:00
|
|
|
|
2019-01-16 04:19:01 -05:00
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
|
2021-05-21 16:58:25 -04:00
|
|
|
# This generates the `closure-locale.ts` file through the `generate-locales` tool. Since
|
|
|
|
# the `closure-locale.ts` file is checked-in for Google3, we add a `generated_file_test` to
|
|
|
|
# ensure the checked-in file is up-to-date. To disambiguate from the test, we use a more
|
|
|
|
# precise target name here.
|
|
|
|
generate_closure_locales_file(
|
|
|
|
name = "closure_locales_file_generated",
|
|
|
|
output_file = "closure_locales_generated.ts",
|
|
|
|
)
|
|
|
|
|
|
|
|
generated_file_test(
|
|
|
|
name = "closure_locale_file",
|
|
|
|
src = "closure-locale.ts",
|
|
|
|
generated = ":closure_locales_file_generated",
|
|
|
|
)
|
|
|
|
|
|
|
|
generate_all_locale_files(
|
|
|
|
name = "locale_files",
|
|
|
|
)
|
|
|
|
|
2017-12-16 23:08:49 -05:00
|
|
|
ts_library(
|
|
|
|
name = "locales",
|
2021-05-21 16:58:25 -04:00
|
|
|
# TODO(devversion): Remove glob for checked-in legacy locale files that haven't been
|
|
|
|
# removed in the past (when CLDR has been updated). These can be removed in a major.
|
|
|
|
srcs = [file for l in LOCALES for file in [
|
|
|
|
"%s.ts" % l,
|
|
|
|
"extra/%s.ts" % l,
|
|
|
|
]] + glob(
|
|
|
|
[
|
|
|
|
"*.ts",
|
|
|
|
"extra/*.ts",
|
|
|
|
],
|
2017-12-16 23:08:49 -05:00
|
|
|
exclude = ["closure-locale.ts"],
|
|
|
|
),
|
|
|
|
)
|
2018-04-03 17:10:21 -04:00
|
|
|
|
2019-12-28 19:37:59 -05:00
|
|
|
pkg_npm(
|
2018-04-03 17:10:21 -04:00
|
|
|
name = "package",
|
2021-05-21 16:58:25 -04:00
|
|
|
srcs = ["package.json"],
|
2019-12-28 19:37:59 -05:00
|
|
|
substitutions = {
|
2019-01-16 04:19:01 -05:00
|
|
|
# Workaround for `.d.ts`` containing `/// <amd-module .../>`
|
|
|
|
# which are generated in TypeScript v2.9, but not before.
|
|
|
|
"/// <amd-module name=.*/>": "",
|
2018-04-09 10:17:29 -04:00
|
|
|
# Workaround for https://github.com/angular/angular/issues/23217
|
|
|
|
# Webpack will detect that the UMD outputs from TypeScript pass the
|
|
|
|
# `require` function into the module, and cannot accurately track
|
|
|
|
# dependencies in case require was called.
|
|
|
|
# We don't actually import anything in the locale code so we can
|
|
|
|
# null out the require reference passed into the module.
|
2021-01-26 11:57:44 -05:00
|
|
|
"factory\\(require, exports\\)": "factory(null, exports)",
|
2018-04-09 10:17:29 -04:00
|
|
|
},
|
2021-05-21 16:58:25 -04:00
|
|
|
# TODO(devversion): Remove glob for checked-in legacy locale files that haven't been
|
|
|
|
# removed in the past (when CLDR has been updated). These can be removed in a major.
|
|
|
|
deps = ["global/%s.js" % l for l in LOCALES] + [":locales"] + glob(["global/*.js"]),
|
2018-04-03 17:10:21 -04:00
|
|
|
)
|