Skip to content

Commit

Permalink
chore(NA): moving @kbn/analytics into bazel (elastic#98917)
Browse files Browse the repository at this point in the history
* chore(NA): moving @kbn/analytics into bazel

* chore(NA): fix type check for package migration

* chore(NA): fix type check for package migration

* chore(NA): fix type check for package migration

* chore(NA): separate type generating from server code

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mistic and kibanamachine authored May 3, 2021
1 parent 58b3c1b commit 4af6e9c
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 119 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports_files(
[
"tsconfig.base.json",
"tsconfig.browser.json",
"tsconfig.json",
"package.json"
],
Expand Down
1 change: 1 addition & 0 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ yarn kbn watch-bazel
- @elastic/datemath
- @elastic/eslint-config-kibana
- @elastic/safer-lodash-set
- @kbn/analytics
- @kbn/apm-config-loader
- @kbn/apm-utils
- @kbn/babel-code-parser
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"@hapi/podium": "^4.1.1",
"@hapi/wreck": "^17.1.0",
"@kbn/ace": "link:packages/kbn-ace",
"@kbn/analytics": "link:packages/kbn-analytics",
"@kbn/analytics": "link:bazel-bin/packages/kbn-analytics/npm_module",
"@kbn/apm-config-loader": "link:bazel-bin/packages/kbn-apm-config-loader/npm_module",
"@kbn/apm-utils": "link:bazel-bin/packages/kbn-apm-utils/npm_module",
"@kbn/config": "link:packages/kbn-config",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ filegroup(
"//packages/elastic-datemath:build",
"//packages/elastic-eslint-config-kibana:build",
"//packages/elastic-safer-lodash-set:build",
"//packages/kbn-analytics:build",
"//packages/kbn-apm-config-loader:build",
"//packages/kbn-apm-utils:build",
"//packages/kbn-babel-code-parser:build",
Expand Down
124 changes: 124 additions & 0 deletions packages/kbn-analytics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
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-analytics"
PKG_REQUIRE_NAME = "@kbn/analytics"

SOURCE_FILES = glob(
[
"src/**/*.ts",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json"
]

SRC_DEPS = [
"@npm//moment-timezone",
"@npm//tslib",
]

TYPES_DEPS = [
"@npm//@types/moment-timezone",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)

ts_config(
name = "tsconfig_browser",
src = "tsconfig.browser.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.browser.json",
],
)

ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_dir = "types",
declaration_map = True,
incremental = True,
out_dir = "node",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)

ts_project(
name = "tsc_browser",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = False,
incremental = True,
out_dir = "web",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig_browser",
)

filegroup(
name = "tsc_types",
srcs = [":tsc"],
output_group = "types",
)

filegroup(
name = "target_files",
srcs = [
":tsc",
":tsc_browser",
":tsc_types",
],
)

pkg_npm(
name = "target",
deps = [
":target_files",
],
)

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":target"] + 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"],
)
21 changes: 0 additions & 21 deletions packages/kbn-analytics/babel.config.js

This file was deleted.

9 changes: 2 additions & 7 deletions packages/kbn-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
"version": "1.0.0",
"description": "Kibana Analytics tool",
"main": "target/node/index.js",
"browser": "target/web/index.js",
"types": "target/types/index.d.ts",
"browser": "target/web/index.js",
"author": "Ahmad Bamieh <[email protected]>",
"license": "SSPL-1.0 OR Elastic License 2.0",
"scripts": {
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build --source-maps",
"kbn:watch": "node scripts/build --source-maps --watch"
}
"license": "SSPL-1.0 OR Elastic License 2.0"
}
85 changes: 0 additions & 85 deletions packages/kbn-analytics/scripts/build.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/kbn-analytics/tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.browser.json",
"compilerOptions": {
"incremental": true,
"outDir": "./target/web",
"stripInternal": true,
"declaration": false,
"isolatedModules": true,
"sourceMap": true,
"sourceRoot": "../../../../../packages/kbn-analytics/src",
"types": [
"node"
]
},
"include": [
"src/**/*"
]
}
6 changes: 3 additions & 3 deletions packages/kbn-analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"outDir": "./target/types",
"incremental": true,
"declarationDir": "./target/types",
"outDir": "./target/node",
"stripInternal": true,
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true,
"isolatedModules": true,
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"kbn:watch": "node scripts/build --dev --watch"
},
"dependencies": {
"@kbn/analytics": "link:../kbn-analytics",
"@kbn/i18n": "link:../kbn-i18n",
"@kbn/monaco": "link:../kbn-monaco"
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2587,7 +2587,7 @@
version "0.0.0"
uid ""

"@kbn/analytics@link:packages/kbn-analytics":
"@kbn/analytics@link:bazel-bin/packages/kbn-analytics/npm_module":
version "0.0.0"
uid ""

Expand Down

0 comments on commit 4af6e9c

Please sign in to comment.