load("@npm//@bazel/typescript:index.bzl", "ts_config") load("@npm//@babel/cli:index.bzl", "babel") 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 = "kbn-test" PKG_REQUIRE_NAME = "@kbn/test" SOURCE_FILES = glob( [ "src/failed_tests_reporter/es_config", "**/*.html", "**/*.js", "**/*.ts", ], exclude = [ "types/**/*", "**/*.config.js", "**/*.mock.*", "**/*.test.*", "**/*.stories.*", "**/*.snap", "**/__fixture__/**", "**/__fixtures__/**", "**/__snapshots__/**", "**/integration_tests/**", "**/scripts/**", "**/storybook/**", "**/test_fixtures/**", "**/test_helpers/**", ], ) SRCS = SOURCE_FILES filegroup( name = "srcs", srcs = SRCS, ) NPM_MODULE_EXTRA_FILES = [ "jest-preset.js", "jest_integration/jest-preset.js", "jest_integration_node/jest-preset.js", "jest_node/jest-preset.js", "jest.config.js", "package.json", ] RUNTIME_DEPS = [ "//packages/kbn-dev-utils", "//packages/kbn-i18n-react", "//packages/kbn-std", "//packages/kbn-utils", "//packages/kbn-bazel-packages", "@npm//@elastic/elasticsearch", "@npm//@babel/traverse", "@npm//@jest/console", "@npm//@jest/reporters", "@npm//axios", "@npm//chance", "@npm//dedent", "@npm//del", "@npm//enzyme", "@npm//execa", "@npm//exit-hook", "@npm//form-data", "@npm//get-port", "@npm//getopts", "@npm//globby", "@npm//he", "@npm//history", "@npm//jest", "@npm//jest-cli", "@npm//jest-snapshot", "@npm//jest-styled-components", "@npm//joi", "@npm//js-yaml", "@npm//minimatch", "@npm//mustache", "@npm//normalize-path", "@npm//prettier", "@npm//react-dom", "@npm//react-redux", "@npm//react-router-dom", "@npm//redux", "@npm//rxjs", "@npm//semver", "@npm//strip-ansi", "@npm//supertest", "@npm//xmlbuilder", "@npm//xml2js", ] TYPES_DEPS = [ "//packages/kbn-dev-utils:npm_module_types", "//packages/kbn-std:npm_module_types", "//packages/kbn-utils:npm_module_types", "//packages/kbn-tooling-log:npm_module_types", "//packages/kbn-bazel-packages:npm_module_types", "//packages/kbn-get-repo-files:npm_module_types", "@npm//@elastic/elasticsearch", "@npm//@jest/console", "@npm//@jest/reporters", "@npm//axe-core", "@npm//axios", "@npm//elastic-apm-node", "@npm//del", "@npm//exit-hook", "@npm//form-data", "@npm//get-port", "@npm//getopts", "@npm//globby", "@npm//jest", "@npm//jest-cli", "@npm//jest-snapshot", "@npm//redux", "@npm//rxjs", "@npm//xmlbuilder", "@npm//@types/archiver", "@npm//@types/chance", "@npm//@types/dedent", "@npm//@types/enzyme", "@npm//@types/he", "@npm//@types/history", "@npm//@types/jest", "@npm//@types/js-yaml", "@npm//joi", "@npm//@types/lodash", "@npm//@types/minimatch", "@npm//@types/mustache", "@npm//@types/normalize-path", "@npm//@types/node", "@npm//@types/prettier", "@npm//@types/react-dom", "@npm//@types/react-router-dom", "@npm//@types/semver", "@npm//@types/supertest", "@npm//@types/uuid", "@npm//@types/xml2js", ] 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, declaration = True, declaration_map = True, emit_declaration_only = True, out_dir = "target_types", tsconfig = ":tsconfig", ) js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES, deps = RUNTIME_DEPS + [":target_node"], 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"], ) pkg_npm_types( name = "npm_module_types", srcs = SRCS, deps = [":tsc_types"], package_name = PKG_REQUIRE_NAME, tsconfig = ":tsconfig", visibility = ["//visibility:public"], ) filegroup( name = "build_types", srcs = [ ":npm_module_types", ], visibility = ["//visibility:public"], )