From 119ceaccbef556efa491afdc57977ddd759af534 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 21 Apr 2021 15:57:12 +0100 Subject: [PATCH 1/2] chore(NA): chore(NA): moving @kbn/utils into bazel --- .../monorepo-packages.asciidoc | 1 + package.json | 2 +- packages/BUILD.bazel | 1 + packages/kbn-apm-config-loader/package.json | 3 +- packages/kbn-cli-dev-mode/package.json | 3 +- packages/kbn-config-schema/BUILD.bazel | 3 +- packages/kbn-dev-utils/package.json | 3 - packages/kbn-docs-utils/package.json | 1 - packages/kbn-es-archiver/package.json | 3 +- packages/kbn-legacy-logging/package.json | 3 - packages/kbn-pm/package.json | 3 - packages/kbn-test/package.json | 3 +- packages/kbn-utils/BUILD.bazel | 82 +++++++++++++++++++ packages/kbn-utils/package.json | 7 +- packages/kbn-utils/tsconfig.json | 2 +- yarn.lock | 2 +- 16 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 packages/kbn-utils/BUILD.bazel diff --git a/docs/developer/getting-started/monorepo-packages.asciidoc b/docs/developer/getting-started/monorepo-packages.asciidoc index 9564087dabefe..dfe5b8c2811ce 100644 --- a/docs/developer/getting-started/monorepo-packages.asciidoc +++ b/docs/developer/getting-started/monorepo-packages.asciidoc @@ -67,4 +67,5 @@ yarn kbn watch-bazel - @kbn/config-schema - @kbn/tinymath - @kbn/utility-types +- @kbn/utils diff --git a/package.json b/package.json index 047dd38d92cd8..121ea0380231b 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "@kbn/ui-framework": "link:packages/kbn-ui-framework", "@kbn/ui-shared-deps": "link:packages/kbn-ui-shared-deps", "@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types/npm_module", - "@kbn/utils": "link:packages/kbn-utils", + "@kbn/utils": "link:bazel-bin/packages/kbn-utils/npm_module", "@loaders.gl/core": "^2.3.1", "@loaders.gl/json": "^2.3.1", "@mapbox/geojson-rewind": "^0.5.0", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index e1a85e926f049..112c2944d1242 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -9,5 +9,6 @@ filegroup( "//packages/kbn-config-schema:build", "//packages/kbn-tinymath:build", "//packages/kbn-utility-types:build", + "//packages/kbn-utils:build", ], ) diff --git a/packages/kbn-apm-config-loader/package.json b/packages/kbn-apm-config-loader/package.json index 214b8510ba69c..d198ee57c619d 100644 --- a/packages/kbn-apm-config-loader/package.json +++ b/packages/kbn-apm-config-loader/package.json @@ -11,7 +11,6 @@ "kbn:watch": "yarn build --watch" }, "dependencies": { - "@elastic/safer-lodash-set": "link:../elastic-safer-lodash-set", - "@kbn/utils": "link:../kbn-utils" + "@elastic/safer-lodash-set": "link:../elastic-safer-lodash-set" } } \ No newline at end of file diff --git a/packages/kbn-cli-dev-mode/package.json b/packages/kbn-cli-dev-mode/package.json index 1ea319ef3601c..35722b5e0b651 100644 --- a/packages/kbn-cli-dev-mode/package.json +++ b/packages/kbn-cli-dev-mode/package.json @@ -19,7 +19,6 @@ "@kbn/server-http-tools": "link:../kbn-server-http-tools", "@kbn/optimizer": "link:../kbn-optimizer", "@kbn/std": "link:../kbn-std", - "@kbn/dev-utils": "link:../kbn-dev-utils", - "@kbn/utils": "link:../kbn-utils" + "@kbn/dev-utils": "link:../kbn-dev-utils" } } \ No newline at end of file diff --git a/packages/kbn-config-schema/BUILD.bazel b/packages/kbn-config-schema/BUILD.bazel index 5dcbd9e5a802a..0c6b3c10db4fd 100644 --- a/packages/kbn-config-schema/BUILD.bazel +++ b/packages/kbn-config-schema/BUILD.bazel @@ -63,7 +63,7 @@ ts_project( js_library( name = PKG_BASE_NAME, - srcs = [], + srcs = NPM_MODULE_EXTRA_FILES, deps = [":tsc"] + DEPS, package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], @@ -71,7 +71,6 @@ js_library( pkg_npm( name = "npm_module", - srcs = NPM_MODULE_EXTRA_FILES, deps = [ ":%s" % PKG_BASE_NAME, ] diff --git a/packages/kbn-dev-utils/package.json b/packages/kbn-dev-utils/package.json index 87e142c3bece7..4ce2880afbbda 100644 --- a/packages/kbn-dev-utils/package.json +++ b/packages/kbn-dev-utils/package.json @@ -13,9 +13,6 @@ "kibana": { "devOnly": true }, - "dependencies": { - "@kbn/utils": "link:../kbn-utils" - }, "devDependencies": { "@kbn/expect": "link:../kbn-expect" } diff --git a/packages/kbn-docs-utils/package.json b/packages/kbn-docs-utils/package.json index 26a7fa0e8c957..e2db07001b543 100644 --- a/packages/kbn-docs-utils/package.json +++ b/packages/kbn-docs-utils/package.json @@ -13,7 +13,6 @@ "kbn:watch": "../../node_modules/.bin/tsc --watch" }, "dependencies": { - "@kbn/utils": "link:../kbn-utils", "@kbn/config": "link:../kbn-config", "@kbn/dev-utils": "link:../kbn-dev-utils" } diff --git a/packages/kbn-es-archiver/package.json b/packages/kbn-es-archiver/package.json index 047d1dd675d26..0e4c9884d2c39 100644 --- a/packages/kbn-es-archiver/package.json +++ b/packages/kbn-es-archiver/package.json @@ -14,7 +14,6 @@ }, "dependencies": { "@kbn/dev-utils": "link:../kbn-dev-utils", - "@kbn/test": "link:../kbn-test", - "@kbn/utils": "link:../kbn-utils" + "@kbn/test": "link:../kbn-test" } } \ No newline at end of file diff --git a/packages/kbn-legacy-logging/package.json b/packages/kbn-legacy-logging/package.json index 9450fd39607ea..8c26535b9b48f 100644 --- a/packages/kbn-legacy-logging/package.json +++ b/packages/kbn-legacy-logging/package.json @@ -9,8 +9,5 @@ "build": "tsc", "kbn:bootstrap": "yarn build", "kbn:watch": "yarn build --watch" - }, - "dependencies": { - "@kbn/utils": "link:../kbn-utils" } } diff --git a/packages/kbn-pm/package.json b/packages/kbn-pm/package.json index 050aadd402d8a..c46906112b2e2 100644 --- a/packages/kbn-pm/package.json +++ b/packages/kbn-pm/package.json @@ -14,8 +14,5 @@ }, "devDependencies": { "@kbn/dev-utils": "link:../kbn-dev-utils" - }, - "dependencies": { - "@kbn/utils": "link:../kbn-utils" } } \ No newline at end of file diff --git a/packages/kbn-test/package.json b/packages/kbn-test/package.json index 2afbe41e0e00e..9bf8a01e031cc 100644 --- a/packages/kbn-test/package.json +++ b/packages/kbn-test/package.json @@ -20,7 +20,6 @@ }, "devDependencies": { "@kbn/dev-utils": "link:../kbn-dev-utils", - "@kbn/expect": "link:../kbn-expect", - "@kbn/utils": "link:../kbn-utils" + "@kbn/expect": "link:../kbn-expect" } } \ No newline at end of file diff --git a/packages/kbn-utils/BUILD.bazel b/packages/kbn-utils/BUILD.bazel new file mode 100644 index 0000000000000..57aee048746b4 --- /dev/null +++ b/packages/kbn-utils/BUILD.bazel @@ -0,0 +1,82 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") + +PKG_BASE_NAME = "kbn-utils" +PKG_REQUIRE_NAME = "@kbn/utils" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = ["**/*.test.*"], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", + "README.md" +] + +SRC_DEPS = [ + "//packages/kbn-config-schema", + "@npm//load-json-file", + "@npm//tslib", +] + +TYPES_DEPS = [ + "@npm//@types/jest", + "@npm//@types/node", +] + +DEPS = SRC_DEPS + TYPES_DEPS + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + ], +) + +ts_project( + name = "tsc", + args = ['--pretty'], + srcs = SRCS, + deps = DEPS, + declaration = True, + declaration_map = True, + incremental = True, + out_dir = "target", + source_map = True, + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_BASE_NAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = [":tsc"] + DEPS, + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [ + ":%s" % PKG_BASE_NAME, + ] +) + +filegroup( + name = "build", + srcs = [ + ":npm_module", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-utils/package.json b/packages/kbn-utils/package.json index 2c3c0c11b65ab..c404613d2c8e1 100644 --- a/packages/kbn-utils/package.json +++ b/packages/kbn-utils/package.json @@ -4,10 +4,5 @@ "types": "./target/index.d.ts", "version": "1.0.0", "license": "SSPL-1.0 OR Elastic License 2.0", - "private": true, - "scripts": { - "build": "rm -rf target && ../../node_modules/.bin/tsc", - "kbn:bootstrap": "yarn build", - "kbn:watch": "yarn build --watch" - } + "private": true } \ No newline at end of file diff --git a/packages/kbn-utils/tsconfig.json b/packages/kbn-utils/tsconfig.json index e6c83767c30dc..0c7657ba55ee6 100644 --- a/packages/kbn-utils/tsconfig.json +++ b/packages/kbn-utils/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": false, + "incremental": true, "outDir": "target", "declaration": true, "declarationMap": true, diff --git a/yarn.lock b/yarn.lock index f8549853b4781..a0d0b3fa1c5f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2762,7 +2762,7 @@ version "0.0.0" uid "" -"@kbn/utils@link:packages/kbn-utils": +"@kbn/utils@link:bazel-bin/packages/kbn-utils/npm_module": version "0.0.0" uid "" From 32e586f8e673077e7edc7b436e396db6a912ece7 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 22 Apr 2021 02:41:26 +0100 Subject: [PATCH 2/2] chore(NA): run kbn-test integration test with preserve-symlinks --- .../src/jest/integration_tests/junit_reporter.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts b/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts index 9a94ff41eb6b9..f2bf25067a9bd 100644 --- a/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts +++ b/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts @@ -30,8 +30,13 @@ it( 'produces a valid junit report for failures', async () => { const result = await execa( - './node_modules/.bin/jest', - ['--config', 'packages/kbn-test/src/jest/integration_tests/__fixtures__/jest.config.js'], + 'node', + [ + '--preserve-symlinks', + './node_modules/.bin/jest', + '--config', + 'packages/kbn-test/src/jest/integration_tests/__fixtures__/jest.config.js', + ], { cwd: REPO_ROOT, env: {