From ad9917d765729ec0d5aeb111aac4041c4ca577ec Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 20 Aug 2021 13:56:04 +0100 Subject: [PATCH 1/3] chore(NA): moving @kbn/securitysolution-t-grid to babel transpiler --- packages/kbn-securitysolution-t-grid/.babelrc | 4 ++ .../.babelrc.browser | 4 ++ .../kbn-securitysolution-t-grid/BUILD.bazel | 57 +++++++++---------- .../babel.config.js | 19 ------- .../tsconfig.browser.json | 22 ------- .../kbn-securitysolution-t-grid/tsconfig.json | 6 +- 6 files changed, 39 insertions(+), 73 deletions(-) create mode 100644 packages/kbn-securitysolution-t-grid/.babelrc create mode 100644 packages/kbn-securitysolution-t-grid/.babelrc.browser delete mode 100644 packages/kbn-securitysolution-t-grid/babel.config.js delete mode 100644 packages/kbn-securitysolution-t-grid/tsconfig.browser.json diff --git a/packages/kbn-securitysolution-t-grid/.babelrc b/packages/kbn-securitysolution-t-grid/.babelrc new file mode 100644 index 0000000000000..40a198521b903 --- /dev/null +++ b/packages/kbn-securitysolution-t-grid/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@kbn/babel-preset/node_preset"], + "ignore": ["**/*.test.ts", "**/*.test.tsx"] +} diff --git a/packages/kbn-securitysolution-t-grid/.babelrc.browser b/packages/kbn-securitysolution-t-grid/.babelrc.browser new file mode 100644 index 0000000000000..71bbfbcd6eb2f --- /dev/null +++ b/packages/kbn-securitysolution-t-grid/.babelrc.browser @@ -0,0 +1,4 @@ +{ + "presets": ["@kbn/babel-preset/webpack_preset"], + "ignore": ["**/*.test.ts", "**/*.test.tsx"] +} diff --git a/packages/kbn-securitysolution-t-grid/BUILD.bazel b/packages/kbn-securitysolution-t-grid/BUILD.bazel index 0c5ef200fc965..70c33d3097122 100644 --- a/packages/kbn-securitysolution-t-grid/BUILD.bazel +++ b/packages/kbn-securitysolution-t-grid/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-t-grid" @@ -29,7 +30,7 @@ NPM_MODULE_EXTRA_FILES = [ "README.md", ] -SRC_DEPS = [ +RUNTIME_DEPS = [ "//packages/kbn-babel-preset", "//packages/kbn-dev-utils", "//packages/kbn-i18n", @@ -44,6 +45,12 @@ SRC_DEPS = [ ] TYPES_DEPS = [ + "//packages/kbn-babel-preset", + "//packages/kbn-dev-utils", + "//packages/kbn-i18n", + "@npm//@babel/core", + "@npm//babel-loader", + "@npm//tslib", "@npm//typescript", "@npm//@types/enzyme", "@npm//@types/jest", @@ -53,7 +60,18 @@ TYPES_DEPS = [ "@npm//@types/react-beautiful-dnd", ] -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", @@ -64,49 +82,26 @@ 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, 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( diff --git a/packages/kbn-securitysolution-t-grid/babel.config.js b/packages/kbn-securitysolution-t-grid/babel.config.js deleted file mode 100644 index b4a118df51af5..0000000000000 --- a/packages/kbn-securitysolution-t-grid/babel.config.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -module.exports = { - env: { - web: { - presets: ['@kbn/babel-preset/webpack_preset'], - }, - node: { - presets: ['@kbn/babel-preset/node_preset'], - }, - }, - ignore: ['**/*.test.ts', '**/*.test.tsx'], -}; diff --git a/packages/kbn-securitysolution-t-grid/tsconfig.browser.json b/packages/kbn-securitysolution-t-grid/tsconfig.browser.json deleted file mode 100644 index e951765c4b991..0000000000000 --- a/packages/kbn-securitysolution-t-grid/tsconfig.browser.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../tsconfig.browser_bazel.json", - "compilerOptions": { - "allowJs": true, - "outDir": "./target_web", - "declaration": false, - "isolatedModules": true, - "sourceMap": true, - "sourceRoot": "../../../../../packages/kbn-securitysolution-t-grid/src", - "types": [ - "jest", - "node" - ], - }, - "include": [ - "src/**/*.ts", - "src/**/*.tsx", - ], - "exclude": [ - "**/__fixtures__/**/*" - ] -} diff --git a/packages/kbn-securitysolution-t-grid/tsconfig.json b/packages/kbn-securitysolution-t-grid/tsconfig.json index 1d5957e516e00..b23bf77cbc115 100644 --- a/packages/kbn-securitysolution-t-grid/tsconfig.json +++ b/packages/kbn-securitysolution-t-grid/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-t-grid/src", @@ -14,5 +15,8 @@ }, "include": [ "src/**/*" + ], + "exclude": [ + "**/__fixtures__/**/*" ] } From be58be0b7a8932a9ae1364096c84a6e5e11f51b3 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 20 Aug 2021 17:40:19 +0100 Subject: [PATCH 2/3] chore(NA): fix package.json --- packages/kbn-securitysolution-t-grid/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-securitysolution-t-grid/package.json b/packages/kbn-securitysolution-t-grid/package.json index 68d3a8c71e7ca..92464f3246ecd 100644 --- a/packages/kbn-securitysolution-t-grid/package.json +++ b/packages/kbn-securitysolution-t-grid/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "security solution t-grid packages will allow sharing components between timelines and security_solution plugin until we transfer all functionality to timelines plugin", "license": "SSPL-1.0 OR Elastic License 2.0", - "browser": "./target_web/browser.js", + "browser": "./target_web/index.js", "main": "./target_node/index.js", "types": "./target_types/index.d.ts", "private": true From 7bcf6281320c8ae38153db99c9ce0afd62f2dcfb Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 20 Aug 2021 21:58:40 +0100 Subject: [PATCH 3/3] chore(NA): finetunning package --- packages/kbn-securitysolution-t-grid/BUILD.bazel | 16 ---------------- .../react/package.json | 5 ----- .../kbn-securitysolution-t-grid/tsconfig.json | 3 --- 3 files changed, 24 deletions(-) delete mode 100644 packages/kbn-securitysolution-t-grid/react/package.json diff --git a/packages/kbn-securitysolution-t-grid/BUILD.bazel b/packages/kbn-securitysolution-t-grid/BUILD.bazel index 70c33d3097122..f9a6a5d7934ad 100644 --- a/packages/kbn-securitysolution-t-grid/BUILD.bazel +++ b/packages/kbn-securitysolution-t-grid/BUILD.bazel @@ -25,38 +25,22 @@ filegroup( ) NPM_MODULE_EXTRA_FILES = [ - "react/package.json", "package.json", "README.md", ] RUNTIME_DEPS = [ - "//packages/kbn-babel-preset", - "//packages/kbn-dev-utils", - "//packages/kbn-i18n", - "@npm//@babel/core", - "@npm//babel-loader", - "@npm//enzyme", "@npm//jest", "@npm//lodash", - "@npm//react", "@npm//react-beautiful-dnd", "@npm//tslib", ] TYPES_DEPS = [ - "//packages/kbn-babel-preset", - "//packages/kbn-dev-utils", - "//packages/kbn-i18n", - "@npm//@babel/core", - "@npm//babel-loader", "@npm//tslib", - "@npm//typescript", - "@npm//@types/enzyme", "@npm//@types/jest", "@npm//@types/lodash", "@npm//@types/node", - "@npm//@types/react", "@npm//@types/react-beautiful-dnd", ] diff --git a/packages/kbn-securitysolution-t-grid/react/package.json b/packages/kbn-securitysolution-t-grid/react/package.json deleted file mode 100644 index c29ddd45f084d..0000000000000 --- a/packages/kbn-securitysolution-t-grid/react/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "browser": "../target_web/react", - "main": "../target_node/react", - "types": "../target_types/react/index.d.ts" -} \ No newline at end of file diff --git a/packages/kbn-securitysolution-t-grid/tsconfig.json b/packages/kbn-securitysolution-t-grid/tsconfig.json index b23bf77cbc115..3c701d149ab2e 100644 --- a/packages/kbn-securitysolution-t-grid/tsconfig.json +++ b/packages/kbn-securitysolution-t-grid/tsconfig.json @@ -15,8 +15,5 @@ }, "include": [ "src/**/*" - ], - "exclude": [ - "**/__fixtures__/**/*" ] }