Skip to content

Commit

Permalink
chore(NA): moving @kbn/mapbox-gl to babel transpiler (elastic#109082)
Browse files Browse the repository at this point in the history
* chore(NA): moving @kbn/mapbox-gl to babel transpiler

* chore(NA): structure exports

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mistic and kibanamachine authored Aug 18, 2021
1 parent dd9dd52 commit 51c1594
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions packages/kbn-mapbox-gl/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
20 changes: 14 additions & 6 deletions packages/kbn-mapbox-gl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

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")

PKG_BASE_NAME = "kbn-mapbox-gl"
PKG_REQUIRE_NAME = "@kbn/mapbox-gl"
Expand All @@ -26,17 +27,23 @@ NPM_MODULE_EXTRA_FILES = [
"README.md"
]

SRC_DEPS = [
RUNTIME_DEPS = [
"@npm//@mapbox/mapbox-gl-rtl-text",
"@npm//file-loader",
"@npm//mapbox-gl",
]

TYPES_DEPS = [
"@npm//@mapbox/mapbox-gl-rtl-text",
"@npm//file-loader",
"@npm//@types/mapbox-gl",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
Expand All @@ -48,13 +55,14 @@ ts_config(
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
out_dir = "target",
emit_declaration_only = True,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
Expand All @@ -63,7 +71,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-mapbox-gl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts"
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts"
}
5 changes: 3 additions & 2 deletions packages/kbn-mapbox-gl/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ import 'mapbox-gl/dist/mapbox-gl.css';
mapboxgl.workerUrl = mbWorkerUrl;
mapboxgl.setRTLTextPlugin(mbRtlPlugin);

export {
mapboxgl,
export { mapboxgl };

export type {
Map,
GeoJSONSource,
VectorSource,
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-mapbox-gl/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"outDir": "./target/types",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-mapbox-gl/src",
Expand Down

0 comments on commit 51c1594

Please sign in to comment.