Skip to content

Commit c4d1e7d

Browse files
chore(NA): moving @kbn/alerts to babel transpiler (#109320)
* chore(NA): moving @kbn/alerts to babel transpiler * chore(NA): finetune package * chore(NA): miss dep Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 5a00ff3 commit c4d1e7d

File tree

7 files changed

+40
-95
lines changed

7 files changed

+40
-95
lines changed

packages/kbn-alerts/.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@kbn/babel-preset/node_preset"],
3+
"ignore": ["**/*.test.ts", "**/*.test.tsx"]
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@kbn/babel-preset/webpack_preset"],
3+
"ignore": ["**/*.test.ts", "**/*.test.tsx"]
4+
}

packages/kbn-alerts/BUILD.bazel

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
22
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
3+
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
34

45
PKG_BASE_NAME = "kbn-alerts"
56

@@ -12,8 +13,7 @@ SOURCE_FILES = glob(
1213
],
1314
exclude = [
1415
"**/*.test.*",
15-
"**/*.mock.*",
16-
"**/*.mocks.*",
16+
"**/__snapshots__"
1717
],
1818
)
1919

@@ -25,32 +25,40 @@ filegroup(
2525
)
2626

2727
NPM_MODULE_EXTRA_FILES = [
28-
"react/package.json",
2928
"package.json",
3029
"README.md",
3130
]
3231

33-
SRC_DEPS = [
34-
"//packages/kbn-babel-preset",
35-
"//packages/kbn-dev-utils",
32+
RUNTIME_DEPS = [
3633
"//packages/kbn-i18n",
37-
"@npm//@babel/core",
38-
"@npm//babel-loader",
3934
"@npm//@elastic/eui",
35+
"@npm//enzyme",
4036
"@npm//react",
4137
"@npm//resize-observer-polyfill",
42-
"@npm//rxjs",
43-
"@npm//tslib",
4438
]
4539

4640
TYPES_DEPS = [
47-
"@npm//typescript",
41+
"//packages/kbn-i18n",
42+
"@npm//@elastic/eui",
43+
"@npm//resize-observer-polyfill",
44+
"@npm//@types/enzyme",
4845
"@npm//@types/jest",
4946
"@npm//@types/node",
5047
"@npm//@types/react",
5148
]
5249

53-
DEPS = SRC_DEPS + TYPES_DEPS
50+
jsts_transpiler(
51+
name = "target_node",
52+
srcs = SRCS,
53+
build_pkg_name = package_name(),
54+
)
55+
56+
jsts_transpiler(
57+
name = "target_web",
58+
srcs = SRCS,
59+
build_pkg_name = package_name(),
60+
config_file = ".babelrc.browser"
61+
)
5462

5563
ts_config(
5664
name = "tsconfig",
@@ -61,50 +69,26 @@ ts_config(
6169
],
6270
)
6371

64-
ts_config(
65-
name = "tsconfig_browser",
66-
src = "tsconfig.browser.json",
67-
deps = [
68-
"//:tsconfig.base.json",
69-
"//:tsconfig.browser.json",
70-
"//:tsconfig.browser_bazel.json",
71-
],
72-
)
73-
7472
ts_project(
75-
name = "tsc",
73+
name = "tsc_types",
7674
args = ["--pretty"],
7775
srcs = SRCS,
78-
deps = DEPS,
79-
allow_js = True,
76+
deps = TYPES_DEPS,
8077
declaration = True,
81-
declaration_dir = "target_types",
8278
declaration_map = True,
83-
out_dir = "target_node",
79+
emit_declaration_only = True,
80+
out_dir = "target_types",
8481
root_dir = "src",
8582
source_map = True,
8683
tsconfig = ":tsconfig",
8784
)
8885

89-
ts_project(
90-
name = "tsc_browser",
91-
args = ['--pretty'],
92-
srcs = SRCS,
93-
deps = DEPS,
94-
allow_js = True,
95-
declaration = False,
96-
out_dir = "target_web",
97-
source_map = True,
98-
root_dir = "src",
99-
tsconfig = ":tsconfig_browser",
100-
)
101-
10286
js_library(
10387
name = PKG_BASE_NAME,
104-
package_name = PKG_REQUIRE_NAME,
10588
srcs = NPM_MODULE_EXTRA_FILES,
89+
deps = RUNTIME_DEPS + [":target_node", ":target_web", ":tsc_types"],
90+
package_name = PKG_REQUIRE_NAME,
10691
visibility = ["//visibility:public"],
107-
deps = [":tsc", ":tsc_browser"] + DEPS,
10892
)
10993

11094
pkg_npm(
@@ -120,4 +104,4 @@ filegroup(
120104
":npm_module",
121105
],
122106
visibility = ["//visibility:public"],
123-
)
107+
)

packages/kbn-alerts/babel.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/kbn-alerts/react/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/kbn-alerts/tsconfig.browser.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/kbn-alerts/tsconfig.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"extends": "../../tsconfig.bazel.json",
33
"compilerOptions": {
4-
"allowJs": true,
5-
"declarationDir": "./target_types",
6-
"outDir": "target_node",
74
"declaration": true,
85
"declarationMap": true,
6+
"emitDeclarationOnly": true,
7+
"outDir": "target_types",
8+
"rootDir": "src",
99
"sourceMap": true,
1010
"sourceRoot": "../../../../packages/kbn-alerts/src",
11-
"rootDir": "src",
1211
"types": ["jest", "node", "resize-observer-polyfill"]
1312
},
14-
"include": ["src/**/*"]
15-
}
13+
"include": ["src/**/*"],
14+
}

0 commit comments

Comments
 (0)