Skip to content

Commit

Permalink
chore(NA): moving @kbn/alerts to babel transpiler
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic committed Aug 19, 2021
1 parent cfd5dad commit ddeb770
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 77 deletions.
4 changes: 4 additions & 0 deletions packages/kbn-alerts/.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-alerts/.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"]
}
62 changes: 30 additions & 32 deletions packages/kbn-alerts/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-alerts"

Expand Down Expand Up @@ -30,7 +31,7 @@ NPM_MODULE_EXTRA_FILES = [
"README.md",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-babel-preset",
"//packages/kbn-dev-utils",
"//packages/kbn-i18n",
Expand All @@ -44,13 +45,33 @@ SRC_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-babel-preset",
"//packages/kbn-dev-utils",
"//packages/kbn-i18n",
"@npm//@babel/core",
"@npm//@elastic/eui",
"@npm//babel-loader",
"@npm//resize-observer-polyfill",
"@npm//rxjs",
"@npm//tslib",
"@npm//typescript",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/react",
]

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 @@ -61,50 +82,27 @@ ts_config(
],
)

ts_config(
name = "tsconfig_browser",
src = "tsconfig.browser.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.browser.json",
"//:tsconfig.browser_bazel.json",
],
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ["--pretty"],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
allow_js = True,
declaration = True,
declaration_dir = "target_types",
declaration_map = True,
out_dir = "target_node",
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
)

ts_project(
name = "tsc_browser",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
allow_js = True,
declaration = False,
out_dir = "target_web",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig_browser",
)

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 = [":tsc", ":tsc_browser"] + DEPS,
)

pkg_npm(
Expand All @@ -120,4 +118,4 @@ filegroup(
":npm_module",
],
visibility = ["//visibility:public"],
)
)
19 changes: 0 additions & 19 deletions packages/kbn-alerts/babel.config.js

This file was deleted.

22 changes: 0 additions & 22 deletions packages/kbn-alerts/tsconfig.browser.json

This file was deleted.

8 changes: 4 additions & 4 deletions packages/kbn-alerts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"allowJs": true,
"declarationDir": "./target_types",
"outDir": "target_node",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-alerts/src",
"rootDir": "src",
"types": ["jest", "node", "resize-observer-polyfill"]
},
"include": ["src/**/*"]
}
}

0 comments on commit ddeb770

Please sign in to comment.