133 lines
2.3 KiB
Python
133 lines
2.3 KiB
Python
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
|
|
|
|
PKG_BASE_NAME = "kbn-i18n"
|
|
PKG_REQUIRE_NAME = "@kbn/i18n"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*.ts",
|
|
"src/**/*.tsx",
|
|
"src/core/locales.js",
|
|
"types/**/*.ts",
|
|
],
|
|
exclude = [
|
|
"**/*.test.*",
|
|
"**/__fixtures__/**",
|
|
"**/__snapshots__/**",
|
|
],
|
|
)
|
|
|
|
SRCS = SOURCE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"angular/package.json",
|
|
"react/package.json",
|
|
"package.json",
|
|
"GUIDELINE.md",
|
|
"README.md"
|
|
]
|
|
|
|
SRC_DEPS = [
|
|
"//packages/kbn-babel-preset",
|
|
"//packages/kbn-dev-utils",
|
|
"@npm//@babel/core",
|
|
"@npm//babel-loader",
|
|
"@npm//del",
|
|
"@npm//getopts",
|
|
"@npm//intl-format-cache",
|
|
"@npm//intl-messageformat",
|
|
"@npm//intl-relativeformat",
|
|
"@npm//prop-types",
|
|
"@npm//react",
|
|
"@npm//react-intl",
|
|
"@npm//supports-color",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"@npm//typescript",
|
|
"@npm//@types/angular",
|
|
"@npm//@types/intl-relativeformat",
|
|
"@npm//@types/jest",
|
|
"@npm//@types/prop-types",
|
|
"@npm//@types/react",
|
|
"@npm//@types/react-intl",
|
|
]
|
|
|
|
DEPS = SRC_DEPS + TYPES_DEPS
|
|
|
|
ts_config(
|
|
name = "tsconfig",
|
|
src = "tsconfig.json",
|
|
deps = [
|
|
"//:tsconfig.base.json",
|
|
],
|
|
)
|
|
|
|
ts_config(
|
|
name = "tsconfig_browser",
|
|
src = "tsconfig.browser.json",
|
|
deps = [
|
|
"//:tsconfig.base.json",
|
|
"//:tsconfig.browser.json",
|
|
],
|
|
)
|
|
|
|
ts_project(
|
|
name = "tsc",
|
|
args = ['--pretty'],
|
|
srcs = SRCS,
|
|
deps = DEPS,
|
|
allow_js = True,
|
|
declaration = True,
|
|
declaration_dir = "target_types",
|
|
declaration_map = True,
|
|
incremental = True,
|
|
out_dir = "target_node",
|
|
source_map = True,
|
|
root_dir = "src",
|
|
tsconfig = ":tsconfig",
|
|
)
|
|
|
|
ts_project(
|
|
name = "tsc_browser",
|
|
args = ['--pretty'],
|
|
srcs = SRCS,
|
|
deps = DEPS,
|
|
allow_js = True,
|
|
declaration = False,
|
|
incremental = True,
|
|
out_dir = "target_web",
|
|
source_map = True,
|
|
root_dir = "src",
|
|
tsconfig = ":tsconfig_browser",
|
|
)
|
|
|
|
js_library(
|
|
name = PKG_BASE_NAME,
|
|
srcs = NPM_MODULE_EXTRA_FILES,
|
|
deps = DEPS + [":tsc", ":tsc_browser"],
|
|
package_name = PKG_REQUIRE_NAME,
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
pkg_npm(
|
|
name = "npm_module",
|
|
deps = [
|
|
":%s" % PKG_BASE_NAME,
|
|
]
|
|
)
|
|
|
|
filegroup(
|
|
name = "build",
|
|
srcs = [
|
|
":npm_module",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|