From dc65b7929a59f0c7bd2eaacae1619ce5b719d1e6 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 5 Apr 2021 17:14:40 +0100 Subject: [PATCH 1/6] chore(NA): moving @kbn/apm-utils into bazel --- packages/BUILD.bazel | 3 +- packages/kbn-apm-utils/BUILD.bazel | 75 ++++++++++++++++++++++++++++ packages/kbn-apm-utils/package.json | 7 +-- packages/kbn-apm-utils/tsconfig.json | 5 +- 4 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 packages/kbn-apm-utils/BUILD.bazel diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 31894fcb1bb5d..3944c2356badc 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -3,6 +3,7 @@ filegroup( name = "build", srcs = [ - "//packages/elastic-datemath:build" + "//packages/elastic-datemath:build", + "//packages/kbn-apm-utils:build" ], ) diff --git a/packages/kbn-apm-utils/BUILD.bazel b/packages/kbn-apm-utils/BUILD.bazel new file mode 100644 index 0000000000000..3fa5582565bd4 --- /dev/null +++ b/packages/kbn-apm-utils/BUILD.bazel @@ -0,0 +1,75 @@ +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-apm-utils" +PKG_REQUIRE_NAME = "@kbn/apm-utils" + +SOURCE_FILES = [ + "src/index.ts", +] + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = glob(SOURCE_FILES), +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +SRC_DEPS = [ + "@npm//elastic-apm-node", +] + +TYPES_DEPS = [ + "@npm//@types/node", +] + +DEPS = SRC_DEPS + TYPES_DEPS + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + ], +) + +ts_project( + name = "tsc", + 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 = [], + deps = [":tsc"] + DEPS, + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + srcs = NPM_MODULE_EXTRA_FILES, + deps = [ + ":%s" % PKG_BASE_NAME, + ] +) + +filegroup( + name = "build", + srcs = [ + ":npm_module", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-apm-utils/package.json b/packages/kbn-apm-utils/package.json index d414b94cb3978..04b8e2ed831b3 100644 --- a/packages/kbn-apm-utils/package.json +++ b/packages/kbn-apm-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": "../../node_modules/.bin/tsc", - "kbn:bootstrap": "yarn build", - "kbn:watch": "yarn build --watch" - } + "private": true } diff --git a/packages/kbn-apm-utils/tsconfig.json b/packages/kbn-apm-utils/tsconfig.json index e08769aab6543..5aaba2d6e379c 100644 --- a/packages/kbn-apm-utils/tsconfig.json +++ b/packages/kbn-apm-utils/tsconfig.json @@ -1,11 +1,10 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": false, - "outDir": "./target", - "stripInternal": false, "declaration": true, "declarationMap": true, + "outDir": "target", + "rootDir": "src", "sourceMap": true, "sourceRoot": "../../../../packages/kbn-apm-utils/src", "types": [ From 20cd7712b8e2545467877b367ec3d556fd2602e3 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 5 Apr 2021 17:50:05 +0100 Subject: [PATCH 2/6] chore(NA): add kbn/apm-utils into package.json --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 34e044140d297..1903506ff4c20 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "@kbn/ace": "link:packages/kbn-ace", "@kbn/analytics": "link:packages/kbn-analytics", "@kbn/apm-config-loader": "link:packages/kbn-apm-config-loader", - "@kbn/apm-utils": "link:packages/kbn-apm-utils", + "@kbn/apm-utils": "link:bazel-bin/packages/kbn-apm-utils/npm_module", "@kbn/config": "link:packages/kbn-config", "@kbn/config-schema": "link:packages/kbn-config-schema", "@kbn/crypto": "link:packages/kbn-crypto", diff --git a/yarn.lock b/yarn.lock index 832a8561bd71c..6e1664e764af1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2616,7 +2616,7 @@ version "0.0.0" uid "" -"@kbn/apm-utils@link:packages/kbn-apm-utils": +"@kbn/apm-utils@link:bazel-bin/packages/kbn-apm-utils/npm_module": version "0.0.0" uid "" From c4a5c60f4d30ad08af7bed64916d9ec2bc56b1fc Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 5 Apr 2021 18:02:47 +0100 Subject: [PATCH 3/6] chore(NA): missing standard on build file globs --- packages/elastic-datemath/BUILD.bazel | 6 +++--- packages/kbn-apm-utils/BUILD.bazel | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/elastic-datemath/BUILD.bazel b/packages/elastic-datemath/BUILD.bazel index 6a80556d4eed5..237754610cf15 100644 --- a/packages/elastic-datemath/BUILD.bazel +++ b/packages/elastic-datemath/BUILD.bazel @@ -4,15 +4,15 @@ load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") PKG_BASE_NAME = "elastic-datemath" PKG_REQUIRE_NAME = "@elastic/datemath" -SOURCE_FILES = [ +SOURCE_FILES = glob([ "src/index.ts", -] +]) SRCS = SOURCE_FILES filegroup( name = "srcs", - srcs = glob(SOURCE_FILES), + srcs = SRCS, ) NPM_MODULE_EXTRA_FILES = [ diff --git a/packages/kbn-apm-utils/BUILD.bazel b/packages/kbn-apm-utils/BUILD.bazel index 3fa5582565bd4..50ec385558909 100644 --- a/packages/kbn-apm-utils/BUILD.bazel +++ b/packages/kbn-apm-utils/BUILD.bazel @@ -4,15 +4,15 @@ load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") PKG_BASE_NAME = "kbn-apm-utils" PKG_REQUIRE_NAME = "@kbn/apm-utils" -SOURCE_FILES = [ +SOURCE_FILES = glob([ "src/index.ts", -] +]) SRCS = SOURCE_FILES filegroup( name = "srcs", - srcs = glob(SOURCE_FILES), + srcs = SRCS, ) NPM_MODULE_EXTRA_FILES = [ From afcc6535f01c4af015075aae0b42380426cff350 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 8 Apr 2021 19:32:34 +0100 Subject: [PATCH 4/6] chore(NA): be more explicit about incremental setting --- packages/elastic-datemath/tsconfig.json | 1 + packages/kbn-apm-utils/tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/elastic-datemath/tsconfig.json b/packages/elastic-datemath/tsconfig.json index d0fa806ed411b..6e7219c7a8245 100644 --- a/packages/elastic-datemath/tsconfig.json +++ b/packages/elastic-datemath/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "declaration": true, "declarationMap": true, + "incremental": true, "outDir": "target", "rootDir": "src", "sourceMap": true, diff --git a/packages/kbn-apm-utils/tsconfig.json b/packages/kbn-apm-utils/tsconfig.json index 5aaba2d6e379c..3ce240059486a 100644 --- a/packages/kbn-apm-utils/tsconfig.json +++ b/packages/kbn-apm-utils/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "declaration": true, "declarationMap": true, + "incremental": true, "outDir": "target", "rootDir": "src", "sourceMap": true, From 2e47c3e8114b0dbbe4601e407cbab887d5806df5 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 12 Apr 2021 19:35:11 +0100 Subject: [PATCH 5/6] chore(NA): include pretty in the args for ts_project rule --- packages/kbn-apm-utils/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/kbn-apm-utils/BUILD.bazel b/packages/kbn-apm-utils/BUILD.bazel index 50ec385558909..63adf2b77b516 100644 --- a/packages/kbn-apm-utils/BUILD.bazel +++ b/packages/kbn-apm-utils/BUILD.bazel @@ -39,6 +39,7 @@ ts_config( ts_project( name = "tsc", + args = ['--pretty'], srcs = SRCS, deps = DEPS, declaration = True, From a1c23e111a82a3bd4df2864d85172721579625bf Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 13 Apr 2021 02:14:33 +0100 Subject: [PATCH 6/6] docs(NA): include package migration completion in the developer getting started --- docs/developer/getting-started/monorepo-packages.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/developer/getting-started/monorepo-packages.asciidoc b/docs/developer/getting-started/monorepo-packages.asciidoc index a95b357570278..655a491f8b3ca 100644 --- a/docs/developer/getting-started/monorepo-packages.asciidoc +++ b/docs/developer/getting-started/monorepo-packages.asciidoc @@ -62,5 +62,6 @@ yarn kbn watch-bazel === List of Already Migrated Packages to Bazel - @elastic/datemath +- @kbn/apm-utils