Skip to content

Commit

Permalink
chore(NA): moving @kbn/securitysolution-list-utils to babel transpiler (
Browse files Browse the repository at this point in the history
elastic#110488)

* chore(NA): moving @kbn/securitysolution-list-utils to babel transpiler

* chore(NA): introduce web bundles
  • Loading branch information
mistic authored and kibanamachine committed Aug 31, 2021
1 parent 3f8d2c7 commit 4a1db48
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
4 changes: 4 additions & 0 deletions packages/kbn-securitysolution-list-utils/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@kbn/babel-preset/node_preset"],
"ignore": ["**/*.test.ts", "**/*.test.tsx"]
}
4 changes: 4 additions & 0 deletions packages/kbn-securitysolution-list-utils/.babelrc.browser
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@kbn/babel-preset/webpack_preset"],
"ignore": ["**/*.test.ts", "**/*.test.tsx"]
}
40 changes: 29 additions & 11 deletions packages/kbn-securitysolution-list-utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")

PKG_BASE_NAME = "kbn-securitysolution-list-utils"

Expand Down Expand Up @@ -27,23 +28,38 @@ NPM_MODULE_EXTRA_FILES = [
"README.md",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-es-query",
"//packages/kbn-i18n",
"//packages/kbn-securitysolution-list-constants",
"//packages/kbn-securitysolution-io-ts-list-types",
"//packages/kbn-securitysolution-list-constants",
"//packages/kbn-securitysolution-utils",
"//packages/kbn-es-query",
"@npm//lodash",
"@npm//tslib",
]

TYPES_DEPS = [
"//packages/kbn-es-query",
"//packages/kbn-i18n",
"//packages/kbn-securitysolution-io-ts-list-types",
"//packages/kbn-securitysolution-list-constants",
"//packages/kbn-securitysolution-utils",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
config_file = ".babelrc.browser"
)

ts_config(
name = "tsconfig",
Expand All @@ -55,24 +71,26 @@ ts_config(
)

ts_project(
name = "tsc",
srcs = SRCS,
name = "tsc_types",
args = ["--pretty"],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
out_dir = "target",
emit_declaration_only = True,
out_dir = "target_types",
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,
deps = RUNTIME_DEPS + [":target_node", ":target_web", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
deps = DEPS + [":tsc"],

)

pkg_npm(
Expand Down
5 changes: 3 additions & 2 deletions packages/kbn-securitysolution-list-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "1.0.0",
"description": "security solution list utilities",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"browser": "./target_web/index.js",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"private": true
}
3 changes: 2 additions & 1 deletion packages/kbn-securitysolution-list-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"outDir": "target",
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-securitysolution-list-utils/src",
Expand Down

0 comments on commit 4a1db48

Please sign in to comment.