11load ("@npm//@bazel/typescript:index.bzl" , "ts_config" , "ts_project" )
22load ("@build_bazel_rules_nodejs//:index.bzl" , "js_library" , "pkg_npm" )
3+ load ("//src/dev/bazel:index.bzl" , "jsts_transpiler" )
34
45PKG_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
2727NPM_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
4640TYPES_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
5563ts_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-
7472ts_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-
10286js_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
11094pkg_npm (
@@ -120,4 +104,4 @@ filegroup(
120104 ":npm_module" ,
121105 ],
122106 visibility = ["//visibility:public" ],
123- )
107+ )
0 commit comments