Skip to content

Commit

Permalink
chore(NA): splits types from code on @elastic/apm-synthtrace (elastic…
Browse files Browse the repository at this point in the history
…#118786)

* chore(NA): auto creation of the package.json for the new types pkg rule

* chore(NA): first alpha api extractor working version

* chore(NA): support kbn-analytics

* chore(NA): correctly read tsconfig files and deps from ts_config rule

* chore(NA): layed out pkg_npm_types tree artifact custom rule

* chore(NA): missing todos

* chore(NA): node modules link mapping

* chore(NA): fully working pkg_npm_types rule

* chore(NA): fix changes on new packages using elastic datemath pkgs

* docs(NA): remove todo

* docs(NA): last todo text correction

* chore(NA): removed commented lines

* fix(NA): include missing package version

* chore(NA): include license keys

* chore(NA): change mock types package into private

* chore(NA): split types_pkg from code_pkg on @elastic/apm-synthtrace

* chore(NA): disable validator on ts_project rule

* chore(NA): move into ts_project wrapper

* chore(NA): complete types exports

* chore(NA): export types as type only

* chore(NA): fix type exports

* chore(NA): only include exception type

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mistic and kibanamachine committed Nov 18, 2021
1 parent 76f073f commit ac95934
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@
"@types/deep-freeze-strict": "^1.1.0",
"@types/delete-empty": "^2.0.0",
"@types/ejs": "^3.0.6",
"@types/elastic__apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types",
"@types/elastic__datemath": "link:bazel-bin/packages/elastic-datemath/npm_module_types",
"@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.10.8",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ filegroup(
filegroup(
name = "build_pkg_types",
srcs = [
"//packages/elastic-apm-synthtrace:build_types",
"//packages/elastic-datemath:build_types",
],
)
Expand Down
34 changes: 25 additions & 9 deletions packages/elastic-apm-synthtrace/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
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")
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "elastic-apm-synthtrace"
PKG_REQUIRE_NAME = "@elastic/apm-synthtrace"
TYPES_PKG_REQUIRE_NAME = "@types/elastic__apm-synthtrace"

SOURCE_FILES = glob(
[
Expand Down Expand Up @@ -31,21 +32,18 @@ RUNTIME_DEPS = [
"@npm//moment",
"@npm//object-hash",
"@npm//p-limit",
"@npm//utility-types",
"@npm//uuid",
"@npm//yargs",
]

TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"@npm//@elastic/elasticsearch",
"@npm//moment",
"@npm//p-limit",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/uuid",
"@npm//@types/object-hash",
"@npm//moment",
"@npm//p-limit",
]

jsts_transpiler(
Expand Down Expand Up @@ -75,12 +73,13 @@ ts_project(
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
validate = False,
)

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand All @@ -99,3 +98,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)
1 change: 0 additions & 1 deletion packages/elastic-apm-synthtrace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"description": "Elastic APM trace data generator",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"private": true
}
1 change: 1 addition & 0 deletions packages/elastic-apm-synthtrace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

export type { Exception } from './lib/entity';
export { service } from './lib/service';
export { browser } from './lib/browser';
export { timerange } from './lib/timerange';
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5361,6 +5361,10 @@
resolved "https://registry.yarnpkg.com/@types/ejs/-/ejs-3.0.6.tgz#aca442289df623bfa8e47c23961f0357847b83fe"
integrity sha512-fj1hi+ZSW0xPLrJJD+YNwIh9GZbyaIepG26E/gXvp8nCa2pYokxUYO1sK9qjGxp2g8ryZYuon7wmjpwE2cyASQ==

"@types/elastic__apm-synthtrace@link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types":
version "0.0.0"
uid ""

"@types/elastic__datemath@link:bazel-bin/packages/elastic-datemath/npm_module_types":
version "0.0.0"
uid ""
Expand Down

0 comments on commit ac95934

Please sign in to comment.