* chore(NA): moving @kbn/interpreter to babel transpiler * chore(NA): fix imports Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
105 lines
1.8 KiB
Python
105 lines
1.8 KiB
Python
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
|
|
load("@npm//peggy:index.bzl", "peggy")
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
|
|
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
|
|
|
|
PKG_BASE_NAME = "kbn-interpreter"
|
|
PKG_REQUIRE_NAME = "@kbn/interpreter"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*",
|
|
]
|
|
)
|
|
|
|
TYPE_FILES = []
|
|
|
|
SRCS = SOURCE_FILES + TYPE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"common/package.json",
|
|
"package.json",
|
|
]
|
|
|
|
RUNTIME_DEPS = [
|
|
"@npm//lodash",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"@npm//@types/jest",
|
|
"@npm//@types/lodash",
|
|
"@npm//@types/node",
|
|
]
|
|
|
|
jsts_transpiler(
|
|
name = "target_node",
|
|
srcs = SRCS,
|
|
build_pkg_name = package_name(),
|
|
)
|
|
|
|
peggy(
|
|
name = "grammar",
|
|
data = [
|
|
":grammar/grammar.peggy"
|
|
],
|
|
output_dir = True,
|
|
args = [
|
|
"--allowed-start-rules",
|
|
"expression,argument",
|
|
"-o",
|
|
"$(@D)/index.js",
|
|
"./%s/grammar/grammar.peggy" % package_name()
|
|
],
|
|
)
|
|
|
|
ts_config(
|
|
name = "tsconfig",
|
|
src = "tsconfig.json",
|
|
deps = [
|
|
"//:tsconfig.base.json",
|
|
"//:tsconfig.bazel.json",
|
|
],
|
|
)
|
|
|
|
ts_project(
|
|
name = "tsc_types",
|
|
args = ['--pretty'],
|
|
srcs = SRCS,
|
|
deps = TYPES_DEPS,
|
|
allow_js = True,
|
|
declaration = True,
|
|
declaration_map = True,
|
|
emit_declaration_only = True,
|
|
out_dir = "target_types",
|
|
source_map = True,
|
|
root_dir = "src",
|
|
tsconfig = ":tsconfig",
|
|
)
|
|
|
|
js_library(
|
|
name = PKG_BASE_NAME,
|
|
srcs = NPM_MODULE_EXTRA_FILES + [":grammar"],
|
|
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
|
|
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"],
|
|
)
|