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")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
package(default_visibility = ["//visibility:public"])
# 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",
)
ts_library(
name = "locales",
# 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",
],
exclude = ["closure-locale.ts"],
),
)
pkg_npm(
name = "package",
srcs = ["package.json"],
substitutions = {
# Workaround for `.d.ts`` containing `/// `
# which are generated in TypeScript v2.9, but not before.
"/// ": "",
# 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.
"factory\\(require, exports\\)": "factory(null, exports)",
},
# 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"]),
)