mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
chore(NA): moving @kbn/io-ts-utils to babel transpiler (#108517)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
560bd0b57b
commit
79f1e18686
7 changed files with 35 additions and 13 deletions
3
packages/kbn-io-ts-utils/.babelrc
Normal file
3
packages/kbn-io-ts-utils/.babelrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"presets": ["@kbn/babel-preset/node_preset"]
|
||||
}
|
|
@ -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-io-ts-utils"
|
||||
PKG_REQUIRE_NAME = "@kbn/io-ts-utils"
|
||||
|
@ -24,7 +25,7 @@ NPM_MODULE_EXTRA_FILES = [
|
|||
"package.json",
|
||||
]
|
||||
|
||||
SRC_DEPS = [
|
||||
RUNTIME_DEPS = [
|
||||
"//packages/kbn-config-schema",
|
||||
"@npm//fp-ts",
|
||||
"@npm//io-ts",
|
||||
|
@ -33,12 +34,20 @@ SRC_DEPS = [
|
|||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"//packages/kbn-config-schema",
|
||||
"@npm//fp-ts",
|
||||
"@npm//io-ts",
|
||||
"@npm//tslib",
|
||||
"@npm//@types/jest",
|
||||
"@npm//@types/lodash",
|
||||
"@npm//@types/node",
|
||||
]
|
||||
|
||||
DEPS = SRC_DEPS + TYPES_DEPS
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
|
@ -50,13 +59,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",
|
||||
|
@ -65,7 +75,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"],
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@kbn/io-ts-utils",
|
||||
"main": "./target/index.js",
|
||||
"types": "./target/index.d.ts",
|
||||
"main": "./target_node/index.js",
|
||||
"types": "./target_types/index.d.ts",
|
||||
"version": "1.0.0",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0",
|
||||
"private": true
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export { deepExactRt } from './deep_exact_rt';
|
||||
export { jsonRt } from './json_rt';
|
||||
export { mergeRt } from './merge_rt';
|
||||
export { strictKeysRt } from './strict_keys_rt';
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{
|
||||
"extends": "../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./target/types",
|
||||
"stripInternal": false,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "./target_types",
|
||||
"rootDir": "src",
|
||||
"sourceMap": true,
|
||||
"sourceRoot": "../../../../packages/kbn-io-ts-utils/src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import * as t from 'io-ts';
|
||||
import { toNumberRt } from '@kbn/io-ts-utils/target/to_number_rt';
|
||||
import { toNumberRt } from '@kbn/io-ts-utils';
|
||||
import { createRouter } from './create_router';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { route } from './route';
|
||||
|
|
|
@ -14,10 +14,16 @@ import {
|
|||
} from 'react-router-config';
|
||||
import qs from 'query-string';
|
||||
import { findLastIndex, merge, compact } from 'lodash';
|
||||
import { deepExactRt } from '@kbn/io-ts-utils/target/deep_exact_rt';
|
||||
import { mergeRt } from '@kbn/io-ts-utils/target/merge_rt';
|
||||
import type { deepExactRt as deepExactRtTyped, mergeRt as mergeRtTyped } from '@kbn/io-ts-utils';
|
||||
// @ts-expect-error
|
||||
import { deepExactRt as deepExactRtNonTyped } from '@kbn/io-ts-utils/target_node/deep_exact_rt';
|
||||
// @ts-expect-error
|
||||
import { mergeRt as mergeRtNonTyped } from '@kbn/io-ts-utils/target_node/merge_rt';
|
||||
import { Route, Router } from './types';
|
||||
|
||||
const deepExactRt: typeof deepExactRtTyped = deepExactRtNonTyped;
|
||||
const mergeRt: typeof mergeRtTyped = mergeRtNonTyped;
|
||||
|
||||
export function createRouter<TRoutes extends Route[]>(routes: TRoutes): Router<TRoutes> {
|
||||
const routesByReactRouterConfig = new Map<ReactRouterConfig, Route>();
|
||||
const reactRouterConfigsByRoute = new Map<Route, ReactRouterConfig>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue