mirror of
https://github.com/elastic/kibana.git
synced 2025-04-22 08:49:27 -04:00
* [bazel] avoid a little boilerplate for @types packages * [bazel/ts] stop building sourcemaps since they're ignored
106 lines
1.8 KiB
Text
106 lines
1.8 KiB
Text
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
|
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
|
|
|
PKG_BASE_NAME = "kbn-utils"
|
|
PKG_REQUIRE_NAME = "@kbn/utils"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*.ts",
|
|
],
|
|
exclude = ["**/*.test.*"],
|
|
)
|
|
|
|
SRCS = SOURCE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"package.json",
|
|
"README.md"
|
|
]
|
|
|
|
RUNTIME_DEPS = [
|
|
"//packages/kbn-config-schema",
|
|
"@npm//load-json-file",
|
|
"@npm//tslib",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"//packages/kbn-config-schema:npm_module_types",
|
|
"@npm//load-json-file",
|
|
"@npm//tslib",
|
|
"@npm//@types/jest",
|
|
"@npm//@types/node",
|
|
]
|
|
|
|
jsts_transpiler(
|
|
name = "target_node",
|
|
srcs = SRCS,
|
|
build_pkg_name = package_name(),
|
|
)
|
|
|
|
ts_config(
|
|
name = "tsconfig",
|
|
src = "tsconfig.json",
|
|
deps = [
|
|
"//:tsconfig.base.json",
|
|
"//:tsconfig.bazel.json",
|
|
],
|
|
)
|
|
|
|
ts_project(
|
|
name = "tsc_types",
|
|
args = ['--pretty'],
|
|
srcs = SRCS,
|
|
deps = TYPES_DEPS,
|
|
declaration = True,
|
|
emit_declaration_only = True,
|
|
out_dir = "target_types",
|
|
root_dir = "src",
|
|
tsconfig = ":tsconfig",
|
|
)
|
|
|
|
js_library(
|
|
name = PKG_BASE_NAME,
|
|
srcs = NPM_MODULE_EXTRA_FILES,
|
|
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
|
|
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"],
|
|
)
|
|
|
|
pkg_npm_types(
|
|
name = "npm_module_types",
|
|
srcs = SRCS,
|
|
deps = [":tsc_types"],
|
|
package_name = PKG_REQUIRE_NAME,
|
|
tsconfig = ":tsconfig",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "build_types",
|
|
srcs = [
|
|
":npm_module_types",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|