From bf6e1243f96bd42d56e43e9f39e01728e6df8711 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 26 Aug 2021 18:21:45 +0100 Subject: [PATCH] chore(NA): moving @kbn/securitysolution-io-ts-utils to babel transpiler (#110099) * chore(NA): moving @kbn/securitysolution-io-ts-utils to babel transpiler * chore(NA): introduce browser targets Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../kbn-securitysolution-io-ts-utils/.babelrc | 4 +++ .../.babelrc.browser | 4 +++ .../BUILD.bazel | 35 +++++++++++++------ .../package.json | 5 +-- .../tsconfig.json | 3 +- 5 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 packages/kbn-securitysolution-io-ts-utils/.babelrc create mode 100644 packages/kbn-securitysolution-io-ts-utils/.babelrc.browser diff --git a/packages/kbn-securitysolution-io-ts-utils/.babelrc b/packages/kbn-securitysolution-io-ts-utils/.babelrc new file mode 100644 index 0000000000000..40a198521b903 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-utils/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@kbn/babel-preset/node_preset"], + "ignore": ["**/*.test.ts", "**/*.test.tsx"] +} diff --git a/packages/kbn-securitysolution-io-ts-utils/.babelrc.browser b/packages/kbn-securitysolution-io-ts-utils/.babelrc.browser new file mode 100644 index 0000000000000..71bbfbcd6eb2f --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-utils/.babelrc.browser @@ -0,0 +1,4 @@ +{ + "presets": ["@kbn/babel-preset/webpack_preset"], + "ignore": ["**/*.test.ts", "**/*.test.tsx"] +} diff --git a/packages/kbn-securitysolution-io-ts-utils/BUILD.bazel b/packages/kbn-securitysolution-io-ts-utils/BUILD.bazel index f6c81a9adb9a3..346bd19451abd 100644 --- a/packages/kbn-securitysolution-io-ts-utils/BUILD.bazel +++ b/packages/kbn-securitysolution-io-ts-utils/BUILD.bazel @@ -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-io-ts-utils" PKG_REQUIRE_NAME = "@kbn/securitysolution-io-ts-utils" @@ -26,25 +27,38 @@ NPM_MODULE_EXTRA_FILES = [ "README.md", ] -SRC_DEPS = [ +RUNTIME_DEPS = [ "//packages/elastic-datemath", "@npm//fp-ts", "@npm//io-ts", "@npm//lodash", "@npm//moment", "@npm//tslib", - "@npm//uuid", ] TYPES_DEPS = [ - "@npm//@types/flot", + "//packages/elastic-datemath", + "@npm//fp-ts", + "@npm//io-ts", + "@npm//moment", + "@npm//tslib", "@npm//@types/jest", "@npm//@types/lodash", "@npm//@types/node", - "@npm//@types/uuid" ] -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", @@ -56,22 +70,23 @@ ts_config( ) ts_project( - name = "tsc", + name = "tsc_types", args = ['--pretty'], srcs = SRCS, - deps = DEPS, + deps = TYPES_DEPS, declaration = True, declaration_map = True, - out_dir = "target", - source_map = True, + emit_declaration_only = True, + out_dir = "target_types", root_dir = "src", + source_map = True, tsconfig = ":tsconfig", ) js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES, - deps = DEPS + [":tsc"], + deps = RUNTIME_DEPS + [":target_node", ":target_web", ":tsc_types"], package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], ) diff --git a/packages/kbn-securitysolution-io-ts-utils/package.json b/packages/kbn-securitysolution-io-ts-utils/package.json index 0912fbfcb6e8d..3b463e919448b 100644 --- a/packages/kbn-securitysolution-io-ts-utils/package.json +++ b/packages/kbn-securitysolution-io-ts-utils/package.json @@ -3,7 +3,8 @@ "version": "1.0.0", "description": "io ts utilities and types to be shared with plugins from the security solution project", "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 } diff --git a/packages/kbn-securitysolution-io-ts-utils/tsconfig.json b/packages/kbn-securitysolution-io-ts-utils/tsconfig.json index aa5aa4df550f2..7c71143083d4d 100644 --- a/packages/kbn-securitysolution-io-ts-utils/tsconfig.json +++ b/packages/kbn-securitysolution-io-ts-utils/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "declaration": true, "declarationMap": true, - "outDir": "target", + "emitDeclarationOnly": true, + "outDir": "target_types", "rootDir": "src", "sourceMap": true, "sourceRoot": "../../../../packages/kbn-securitysolution-io-ts-utils/src",