ac07ebba87
* Adds boilerplate for new hook-utils package * Move existing, identified utils into our hook-utils package Updates references, and fixes a few missing config that were preventing packages from building. * Extracts a common type and adds a little more JSdoc for clarity * Adds new useObservable hook Similar to useAsync (a nearly identical interface), this is meant to wrap a thunk returning an observable, allowing conditional invocation and progressive updates as the observable continues to emit. * Remove orphaned test This function (and its tests) were moved to the hook-utils package; this was simply missed. * Remove optional chaining from kbn package The build system does not currently support these typescript features. While a valid fix would also have been to build separate browser and node targets a la #99390, the use here was very minimal and so changing to a supported syntax was the most pragmatic fix. * Update old reference in test file Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
87 lines
1.3 KiB
Python
87 lines
1.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-securitysolution-hook-utils"
|
|
|
|
PKG_REQUIRE_NAME = "@kbn/securitysolution-hook-utils"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*.ts",
|
|
],
|
|
exclude = [
|
|
"**/*.test.*",
|
|
"**/*.mock.*",
|
|
],
|
|
)
|
|
|
|
SRCS = SOURCE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"package.json",
|
|
"README.md",
|
|
]
|
|
|
|
SRC_DEPS = [
|
|
"@npm//react",
|
|
"@npm//rxjs",
|
|
"@npm//tslib",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"@npm//@types/jest",
|
|
"@npm//@types/node",
|
|
"@npm//@types/react",
|
|
]
|
|
|
|
DEPS = SRC_DEPS + TYPES_DEPS
|
|
|
|
ts_config(
|
|
name = "tsconfig",
|
|
src = "tsconfig.json",
|
|
deps = [
|
|
"//:tsconfig.base.json",
|
|
],
|
|
)
|
|
|
|
ts_project(
|
|
name = "tsc",
|
|
srcs = SRCS,
|
|
args = ["--pretty"],
|
|
declaration = True,
|
|
declaration_map = True,
|
|
incremental = True,
|
|
out_dir = "target",
|
|
root_dir = "src",
|
|
source_map = True,
|
|
tsconfig = ":tsconfig",
|
|
deps = DEPS,
|
|
)
|
|
|
|
js_library(
|
|
name = PKG_BASE_NAME,
|
|
package_name = PKG_REQUIRE_NAME,
|
|
srcs = NPM_MODULE_EXTRA_FILES,
|
|
visibility = ["//visibility:public"],
|
|
deps = DEPS + [":tsc"],
|
|
)
|
|
|
|
pkg_npm(
|
|
name = "npm_module",
|
|
deps = [
|
|
":%s" % PKG_BASE_NAME,
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "build",
|
|
srcs = [
|
|
":npm_module",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|