Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.15] chore(NA): moving @kbn/optimizer to babel transpiler (#109231) #109315

Merged
merged 4 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/kbn-optimizer/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@kbn/babel-preset/node_preset"],
"ignore": ["**/*.test.js"]
}
34 changes: 28 additions & 6 deletions packages/kbn-optimizer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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-optimizer"
PKG_REQUIRE_NAME = "@kbn/optimizer"
Expand Down Expand Up @@ -29,7 +30,7 @@ NPM_MODULE_EXTRA_FILES = [
"README.md"
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-config",
"//packages/kbn-dev-utils",
"//packages/kbn-std",
Expand Down Expand Up @@ -59,6 +60,22 @@ SRC_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-config",
"//packages/kbn-dev-utils",
"//packages/kbn-std",
"//packages/kbn-ui-shared-deps",
"//packages/kbn-utils",
"@npm//chalk",
"@npm//clean-webpack-plugin",
"@npm//cpy",
"@npm//del",
"@npm//execa",
"@npm//jest-diff",
"@npm//lmdb-store",
"@npm//pirates",
"@npm//resize-observer-polyfill",
"@npm//rxjs",
"@npm//zlib",
"@npm//@types/compression-webpack-plugin",
"@npm//@types/jest",
"@npm//@types/json-stable-stringify",
Expand All @@ -72,7 +89,11 @@ TYPES_DEPS = [
"@npm//@types/webpack-sources",
]

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

ts_config(
name = "tsconfig",
Expand All @@ -84,13 +105,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 @@ -99,7 +121,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
12 changes: 0 additions & 12 deletions packages/kbn-optimizer/babel.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/kbn-optimizer/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"
}
3 changes: 2 additions & 1 deletion packages/kbn-optimizer/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-optimizer/src",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/src/jest/setup/babel_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
// Note: In theory importing the polyfill should not be needed, as Babel should
// include the necessary polyfills when using `@babel/preset-env`, but for some
// reason it did not work. See https://github.com/elastic/kibana/issues/14506
import '@kbn/optimizer/target/node/polyfill';
import '@kbn/optimizer/target_node/node/polyfill';