* [build_ts_refs] improve caches, allow building a subset of projects * cleanup project def script and update refs in type check script * rename browser_bazel config to avoid kebab-case * remove execInProjects() helper * list references for tsconfig.types.json for api-extractor workload * disable composite features of tsconfig.types.json for api-extractor * set declaration: true to avoid weird debug error * fix jest tests Co-authored-by: spalger <spalger@users.noreply.github.com>
152 lines
3 KiB
Python
152 lines
3 KiB
Python
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
|
|
load("@npm//@babel/cli:index.bzl", "babel")
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
|
|
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
|
|
|
|
PKG_BASE_NAME = "kbn-test"
|
|
PKG_REQUIRE_NAME = "@kbn/test"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*"
|
|
],
|
|
exclude = [
|
|
"**/*.test.*",
|
|
"**/*.snap",
|
|
"**/__fixture__/**",
|
|
"**/__fixtures__/**",
|
|
"**/__snapshots__/**",
|
|
]
|
|
)
|
|
|
|
SRCS = SOURCE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"jest/package.json",
|
|
"jest-preset.js",
|
|
"jest_integration/jest-preset.js",
|
|
"jest.config.js",
|
|
"README.md",
|
|
"package.json",
|
|
]
|
|
|
|
RUNTIME_DEPS = [
|
|
"//packages/kbn-dev-utils",
|
|
"//packages/kbn-i18n",
|
|
"//packages/kbn-std",
|
|
"//packages/kbn-utils",
|
|
"@npm//@elastic/elasticsearch",
|
|
"@npm//axios",
|
|
"@npm//@babel/traverse",
|
|
"@npm//chance",
|
|
"@npm//del",
|
|
"@npm//enzyme",
|
|
"@npm//execa",
|
|
"@npm//exit-hook",
|
|
"@npm//form-data",
|
|
"@npm//globby",
|
|
"@npm//history",
|
|
"@npm//jest",
|
|
"@npm//jest-cli",
|
|
"@npm//jest-snapshot",
|
|
"@npm//jest-styled-components",
|
|
"@npm//@jest/reporters",
|
|
"@npm//joi",
|
|
"@npm//mustache",
|
|
"@npm//parse-link-header",
|
|
"@npm//prettier",
|
|
"@npm//react-dom",
|
|
"@npm//react-redux",
|
|
"@npm//react-router-dom",
|
|
"@npm//redux",
|
|
"@npm//rxjs",
|
|
"@npm//strip-ansi",
|
|
"@npm//xmlbuilder",
|
|
"@npm//xml2js",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"//packages/kbn-dev-utils",
|
|
"//packages/kbn-i18n",
|
|
"//packages/kbn-utils",
|
|
"@npm//@elastic/elasticsearch",
|
|
"@npm//del",
|
|
"@npm//form-data",
|
|
"@npm//jest",
|
|
"@npm//jest-cli",
|
|
"@npm//jest-snapshot",
|
|
"@npm//redux",
|
|
"@npm//rxjs",
|
|
"@npm//xmlbuilder",
|
|
"@npm//@types/chance",
|
|
"@npm//@types/enzyme",
|
|
"@npm//@types/history",
|
|
"@npm//@types/jest",
|
|
"@npm//@types/joi",
|
|
"@npm//@types/lodash",
|
|
"@npm//@types/mustache",
|
|
"@npm//@types/node",
|
|
"@npm//@types/parse-link-header",
|
|
"@npm//@types/prettier",
|
|
"@npm//@types/react-dom",
|
|
"@npm//@types/react-redux",
|
|
"@npm//@types/react-router-dom",
|
|
"@npm//@types/xml2js",
|
|
]
|
|
|
|
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,
|
|
declaration_map = True,
|
|
emit_declaration_only = True,
|
|
out_dir = "target_types",
|
|
source_map = True,
|
|
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"],
|
|
)
|