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 diff --git a/package.json b/package.json index 9bddca4665467..c1f2a3b3cf132 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,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/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/elastic-datemath/BUILD.bazel b/packages/elastic-datemath/BUILD.bazel index 6b9a725e91bd4..bc0c1412ef5f1 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/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/BUILD.bazel b/packages/kbn-apm-utils/BUILD.bazel new file mode 100644 index 0000000000000..63adf2b77b516 --- /dev/null +++ b/packages/kbn-apm-utils/BUILD.bazel @@ -0,0 +1,76 @@ +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 = glob([ + "src/index.ts", +]) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +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", + 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 = [], + 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..3ce240059486a 100644 --- a/packages/kbn-apm-utils/tsconfig.json +++ b/packages/kbn-apm-utils/tsconfig.json @@ -1,11 +1,11 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": false, - "outDir": "./target", - "stripInternal": false, "declaration": true, "declarationMap": true, + "incremental": true, + "outDir": "target", + "rootDir": "src", "sourceMap": true, "sourceRoot": "../../../../packages/kbn-apm-utils/src", "types": [ diff --git a/yarn.lock b/yarn.lock index 0e6427d2e265e..559ad6e7f62f8 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 ""