180 lines
3.6 KiB
Python
180 lines
3.6 KiB
Python
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
|
|
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")
|
|
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
|
|
|
|
PKG_BASE_NAME = "kbn-ui-shared-deps-npm"
|
|
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps-npm"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*",
|
|
],
|
|
exclude = [
|
|
"**/*.md",
|
|
],
|
|
)
|
|
|
|
SRCS = SOURCE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"eui_theme_vars/package.json",
|
|
"package.json",
|
|
"README.md"
|
|
]
|
|
|
|
RUNTIME_DEPS = [
|
|
"//packages/elastic-datemath",
|
|
"//packages/kbn-utils",
|
|
"@npm//@babel/runtime",
|
|
"@npm//@elastic/charts",
|
|
"@npm//@elastic/eui",
|
|
"@npm//@elastic/numeral",
|
|
"@npm//@emotion/react",
|
|
"@npm//abortcontroller-polyfill",
|
|
"@npm//angular",
|
|
"@npm//babel-loader",
|
|
"@npm//babel-plugin-transform-react-remove-prop-types",
|
|
"@npm//core-js",
|
|
"@npm//css-loader",
|
|
"@npm//fflate",
|
|
"@npm//jquery",
|
|
"@npm//loader-utils",
|
|
"@npm//mini-css-extract-plugin",
|
|
"@npm//moment-timezone",
|
|
"@npm//moment",
|
|
"@npm//raw-loader",
|
|
"@npm//react-dom",
|
|
"@npm//react-intl",
|
|
"@npm//react-is",
|
|
"@npm//react-router-dom",
|
|
"@npm//react-router",
|
|
"@npm//react",
|
|
"@npm//regenerator-runtime",
|
|
"@npm//resize-observer-polyfill",
|
|
"@npm//rison-node",
|
|
"@npm//rxjs",
|
|
"@npm//styled-components",
|
|
"@npm//symbol-observable",
|
|
"@npm//url-loader",
|
|
"@npm//val-loader",
|
|
"@npm//whatwg-fetch",
|
|
]
|
|
|
|
WEBPACK_DEPS = [
|
|
"@npm//clean-webpack-plugin",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"//packages/elastic-datemath",
|
|
"//packages/kbn-utils",
|
|
"@npm//@elastic/charts",
|
|
"@npm//@elastic/eui",
|
|
"@npm//@elastic/numeral",
|
|
"@npm//@emotion/react",
|
|
"@npm//abortcontroller-polyfill",
|
|
"@npm//angular",
|
|
"@npm//babel-loader",
|
|
"@npm//core-js",
|
|
"@npm//css-loader",
|
|
"@npm//fflate",
|
|
"@npm//jquery",
|
|
"@npm//loader-utils",
|
|
"@npm//mini-css-extract-plugin",
|
|
"@npm//moment",
|
|
"@npm//moment-timezone",
|
|
"@npm//raw-loader",
|
|
"@npm//react",
|
|
"@npm//react-dom",
|
|
"@npm//react-intl",
|
|
"@npm//react-is",
|
|
"@npm//react-router",
|
|
"@npm//react-router-dom",
|
|
"@npm//regenerator-runtime",
|
|
"@npm//resize-observer-polyfill",
|
|
"@npm//rison-node",
|
|
"@npm//rxjs",
|
|
"@npm//styled-components",
|
|
"@npm//symbol-observable",
|
|
"@npm//url-loader",
|
|
"@npm//val-loader",
|
|
"@npm//whatwg-fetch",
|
|
"@npm//@types/node",
|
|
]
|
|
|
|
jsts_transpiler(
|
|
name = "target_node",
|
|
srcs = SRCS,
|
|
build_pkg_name = 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",
|
|
root_dir = "src",
|
|
source_map = True,
|
|
tsconfig = ":tsconfig",
|
|
)
|
|
|
|
webpack(
|
|
name = "shared_built_assets",
|
|
data = RUNTIME_DEPS + WEBPACK_DEPS + [
|
|
"//:package.json",
|
|
":srcs",
|
|
":tsconfig",
|
|
":webpack.config.js",
|
|
],
|
|
output_dir = True,
|
|
args = [
|
|
"--config",
|
|
"$(location webpack.config.js)",
|
|
"--output-path",
|
|
"$(@D)",
|
|
"--display=minimal"
|
|
],
|
|
)
|
|
|
|
js_library(
|
|
name = PKG_BASE_NAME,
|
|
srcs = NPM_MODULE_EXTRA_FILES,
|
|
deps = RUNTIME_DEPS + [":target_node", ":tsc_types", ":shared_built_assets"],
|
|
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"],
|
|
)
|