Skip to content

Commit 356861d

Browse files
authored
chore(NA): splits types from code on @kbn/ui-shared-deps-src (elastic#123313)
* chore(NA): splits types from code on @kbn/ui-shared-deps-src * chore(NA): break flot-charts into another package * chore(NA): skip failing tests * chore(NA): remove skip and add correct value * chore(NA): fix new ui-theme import * chore(NA): adding fleet cloned test * chore(NA): remove cloned test * chore(NA): remove added typo
1 parent 94e2e9a commit 356861d

File tree

143 files changed

+417
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+417
-193
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ snapshots.js
3535
/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/
3636
/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/
3737
/packages/kbn-ui-framework/dist
38-
/packages/kbn-ui-shared-deps-src/src/flot_charts
38+
/packages/kbn-flot-charts/lib
3939
/packages/kbn-monaco/src/painless/antlr
4040

4141
# Bazel

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ module.exports = {
15691569
},
15701570
},
15711571
{
1572-
files: ['packages/kbn-ui-shared-deps-src/src/flot_charts/**/*.js'],
1572+
files: ['packages/kbn-flot-charts/lib/**/*.js'],
15731573
env: {
15741574
jquery: true,
15751575
},

.i18nrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"expressionShape": "src/plugins/expression_shape",
3333
"expressionTagcloud": "src/plugins/chart_expressions/expression_tagcloud",
3434
"fieldFormats": "src/plugins/field_formats",
35-
"flot": "packages/kbn-ui-shared-deps-src/src/flot_charts",
35+
"flot": "packages/kbn-flot-charts/lib",
3636
"home": "src/plugins/home",
3737
"indexPatternEditor": "src/plugins/data_view_editor",
3838
"indexPatternFieldEditor": "src/plugins/data_view_field_editor",

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"@kbn/crypto": "link:bazel-bin/packages/kbn-crypto",
138138
"@kbn/es-query": "link:bazel-bin/packages/kbn-es-query",
139139
"@kbn/field-types": "link:bazel-bin/packages/kbn-field-types",
140+
"@kbn/flot-charts": "link:bazel-bin/packages/kbn-flot-charts",
140141
"@kbn/i18n": "link:bazel-bin/packages/kbn-i18n",
141142
"@kbn/i18n-react": "link:bazel-bin/packages/kbn-i18n-react",
142143
"@kbn/interpreter": "link:bazel-bin/packages/kbn-interpreter",
@@ -169,6 +170,7 @@
169170
"@kbn/ui-framework": "link:bazel-bin/packages/kbn-ui-framework",
170171
"@kbn/ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm",
171172
"@kbn/ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src",
173+
"@kbn/ui-theme": "link:bazel-bin/packages/kbn-ui-theme",
172174
"@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types",
173175
"@kbn/utils": "link:bazel-bin/packages/kbn-utils",
174176
"@loaders.gl/core": "^2.3.1",
@@ -602,6 +604,8 @@
602604
"@types/kbn__std": "link:bazel-bin/packages/kbn-std/npm_module_types",
603605
"@types/kbn__telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools/npm_module_types",
604606
"@types/kbn__ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm/npm_module_types",
607+
"@types/kbn__ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src/npm_module_types",
608+
"@types/kbn__ui-theme": "link:bazel-bin/packages/kbn-ui-theme/npm_module_types",
605609
"@types/kbn__utility-types": "link:bazel-bin/packages/kbn-utility-types/npm_module_types",
606610
"@types/kbn__utils": "link:bazel-bin/packages/kbn-utils/npm_module_types",
607611
"@types/license-checker": "15.0.0",

packages/BUILD.bazel

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ filegroup(
2626
"//packages/kbn-eslint-plugin-eslint:build",
2727
"//packages/kbn-expect:build",
2828
"//packages/kbn-field-types:build",
29+
"//packages/kbn-flot-charts:build",
2930
"//packages/kbn-i18n:build",
3031
"//packages/kbn-i18n-react:build",
3132
"//packages/kbn-interpreter:build",
@@ -66,6 +67,7 @@ filegroup(
6667
"//packages/kbn-ui-framework:build",
6768
"//packages/kbn-ui-shared-deps-npm:build",
6869
"//packages/kbn-ui-shared-deps-src:build",
70+
"//packages/kbn-ui-theme:build",
6971
"//packages/kbn-utility-types:build",
7072
"//packages/kbn-utils:build",
7173
],
@@ -121,6 +123,8 @@ filegroup(
121123
"//packages/kbn-std:build_types",
122124
"//packages/kbn-telemetry-tools:build_types",
123125
"//packages/kbn-ui-shared-deps-npm:build_types",
126+
"//packages/kbn-ui-shared-deps-src:build_types",
127+
"//packages/kbn-ui-theme:build_types",
124128
"//packages/kbn-utility-types:build_types",
125129
"//packages/kbn-utils:build_types",
126130
],

packages/elastic-eslint-config-kibana/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports = {
9494
].map(from => ({
9595
from,
9696
to: false,
97-
disallowedMessage: `Use "@kbn/ui-shared-deps-src/theme" to access theme vars.`
97+
disallowedMessage: `Use "@kbn/ui-theme" to access theme vars.`
9898
})),
9999
],
100100
],

packages/kbn-flot-charts/BUILD.bazel

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
2+
load("//src/dev/bazel:index.bzl", "pkg_npm")
3+
4+
PKG_BASE_NAME = "kbn-flot-charts"
5+
PKG_REQUIRE_NAME = "@kbn/flot-charts"
6+
7+
SOURCE_FILES = glob([
8+
"lib/**/*.js",
9+
"index.js",
10+
])
11+
12+
SRCS = SOURCE_FILES
13+
14+
filegroup(
15+
name = "srcs",
16+
srcs = SRCS,
17+
)
18+
19+
NPM_MODULE_EXTRA_FILES = [
20+
"package.json",
21+
"API.md",
22+
]
23+
24+
RUNTIME_DEPS = [
25+
"//packages/kbn-i18n",
26+
]
27+
28+
js_library(
29+
name = PKG_BASE_NAME,
30+
srcs = NPM_MODULE_EXTRA_FILES + [
31+
":srcs",
32+
],
33+
deps = RUNTIME_DEPS,
34+
package_name = PKG_REQUIRE_NAME,
35+
visibility = ["//visibility:public"],
36+
)
37+
38+
pkg_npm(
39+
name = "npm_module",
40+
deps = [
41+
":%s" % PKG_BASE_NAME,
42+
]
43+
)
44+
45+
filegroup(
46+
name = "build",
47+
srcs = [
48+
":npm_module",
49+
],
50+
visibility = ["//visibility:public"],
51+
)

packages/kbn-ui-shared-deps-src/src/flot_charts/index.js packages/kbn-flot-charts/index.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
19
/* @notice
210
*
311
* This product includes code that is based on flot-charts, which was available
@@ -26,15 +34,15 @@
2634
* THE SOFTWARE.
2735
*/
2836

29-
import './jquery_flot';
30-
import './jquery_flot_canvas';
31-
import './jquery_flot_time';
32-
import './jquery_flot_symbol';
33-
import './jquery_flot_crosshair';
34-
import './jquery_flot_selection';
35-
import './jquery_flot_pie';
36-
import './jquery_flot_stack';
37-
import './jquery_flot_threshold';
38-
import './jquery_flot_fillbetween';
39-
import './jquery_flot_log';
40-
import './jquery_flot_axislabels';
37+
import './lib/jquery_flot';
38+
import './lib/jquery_flot_canvas';
39+
import './lib/jquery_flot_time';
40+
import './lib/jquery_flot_symbol';
41+
import './lib/jquery_flot_crosshair';
42+
import './lib/jquery_flot_selection';
43+
import './lib/jquery_flot_pie';
44+
import './lib/jquery_flot_stack';
45+
import './lib/jquery_flot_threshold';
46+
import './lib/jquery_flot_fillbetween';
47+
import './lib/jquery_flot_log';
48+
import './lib/jquery_flot_axislabels';

packages/kbn-flot-charts/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "@kbn/flot-charts",
3+
"version": "1.0.0",
4+
"private": true,
5+
"main": "./index.js",
6+
"license": "SSPL-1.0 OR Elastic License 2.0"
7+
}

packages/kbn-optimizer/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ TYPES_DEPS = [
7070
"//packages/kbn-dev-utils:npm_module_types",
7171
"//packages/kbn-std:npm_module_types",
7272
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
73-
"//packages/kbn-ui-shared-deps-src",
73+
"//packages/kbn-ui-shared-deps-src:npm_module_types",
7474
"//packages/kbn-utils:npm_module_types",
7575
"@npm//chalk",
7676
"@npm//clean-webpack-plugin",

packages/kbn-optimizer/src/worker/webpack.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import webpackMerge from 'webpack-merge';
1616
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
1717
import CompressionPlugin from 'compression-webpack-plugin';
1818
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
19-
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
19+
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
2020

2121
import { Bundle, BundleRefs, WorkerConfig } from '../common';
2222
import { BundleRefsPlugin } from './bundle_refs_plugin';

packages/kbn-storybook/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUNTIME_DEPS = [
5252
TYPES_DEPS = [
5353
"//packages/kbn-dev-utils:npm_module_types",
5454
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
55-
"//packages/kbn-ui-shared-deps-src",
55+
"//packages/kbn-ui-shared-deps-src:npm_module_types",
5656
"//packages/kbn-utils:npm_module_types",
5757
"@npm//@elastic/eui",
5858
"@npm//@emotion/cache",

packages/kbn-storybook/src/lib/run_storybook_cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { logger } from '@storybook/node-logger';
1111
import buildStandalone from '@storybook/react/standalone';
1212
import { Flags, run } from '@kbn/dev-utils';
1313
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
14-
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
14+
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
1515
import * as constants from './constants';
1616

1717
// Convert the flags to a Storybook loglevel

packages/kbn-ui-shared-deps-src/BUILD.bazel

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
2-
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
1+
load("@npm//@bazel/typescript:index.bzl", "ts_config")
2+
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
33
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")
4-
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
4+
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
55

66
PKG_BASE_NAME = "kbn-ui-shared-deps-src"
77
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps-src"
8+
TYPES_PKG_REQUIRE_NAME = "@types/kbn__ui-shared-deps-src"
89

910
SOURCE_FILES = glob(
1011
[
@@ -23,8 +24,6 @@ filegroup(
2324
)
2425

2526
NPM_MODULE_EXTRA_FILES = [
26-
"flot_charts/package.json",
27-
"theme/package.json",
2827
"package.json",
2928
"README.md"
3029
]
@@ -34,11 +33,13 @@ RUNTIME_DEPS = [
3433
"//packages/elastic-safer-lodash-set",
3534
"//packages/kbn-analytics",
3635
"//packages/kbn-babel-preset",
36+
"//packages/kbn-flot-charts",
3737
"//packages/kbn-i18n",
3838
"//packages/kbn-i18n-react",
3939
"//packages/kbn-monaco",
4040
"//packages/kbn-std",
4141
"//packages/kbn-ui-shared-deps-npm",
42+
"//packages/kbn-ui-theme",
4243
]
4344

4445
TYPES_DEPS = [
@@ -50,7 +51,7 @@ TYPES_DEPS = [
5051
"//packages/kbn-monaco:npm_module_types",
5152
"//packages/kbn-std:npm_module_types",
5253
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
53-
"@npm//@elastic/eui",
54+
"//packages/kbn-ui-theme:npm_module_types",
5455
"@npm//webpack",
5556
]
5657

@@ -105,7 +106,7 @@ webpack(
105106
js_library(
106107
name = PKG_BASE_NAME,
107108
srcs = NPM_MODULE_EXTRA_FILES,
108-
deps = RUNTIME_DEPS + [":target_node", ":tsc_types", ":shared_built_assets"],
109+
deps = RUNTIME_DEPS + [":target_node", ":shared_built_assets"],
109110
package_name = PKG_REQUIRE_NAME,
110111
visibility = ["//visibility:public"],
111112
)
@@ -124,3 +125,20 @@ filegroup(
124125
],
125126
visibility = ["//visibility:public"],
126127
)
128+
129+
pkg_npm_types(
130+
name = "npm_module_types",
131+
srcs = SRCS,
132+
deps = [":tsc_types"],
133+
package_name = TYPES_PKG_REQUIRE_NAME,
134+
tsconfig = ":tsconfig",
135+
visibility = ["//visibility:public"],
136+
)
137+
138+
filegroup(
139+
name = "build_types",
140+
srcs = [
141+
":npm_module_types",
142+
],
143+
visibility = ["//visibility:public"],
144+
)

packages/kbn-ui-shared-deps-src/flot_charts/package.json

-4
This file was deleted.

packages/kbn-ui-shared-deps-src/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
"version": "1.0.0",
44
"private": true,
55
"license": "SSPL-1.0 OR Elastic License 2.0",
6-
"main": "target_node/index.js",
7-
"types": "target_types/index.d.ts"
6+
"main": "target_node/index.js"
87
}

packages/kbn-ui-shared-deps-src/src/index.js packages/kbn-ui-shared-deps-src/src/definitions.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,30 @@
88

99
const Path = require('path');
1010

11+
// extracted const vars
1112
/**
1213
* Absolute path to the distributable directory
1314
*/
14-
exports.distDir = Path.resolve(__dirname, '../shared_built_assets');
15+
const distDir = Path.resolve(__dirname, '../shared_built_assets');
1516

1617
/**
1718
* Filename of the main bundle file in the distributable directory
1819
*/
19-
exports.jsFilename = 'kbn-ui-shared-deps-src.js';
20+
const jsFilename = 'kbn-ui-shared-deps-src.js';
2021

2122
/**
2223
* Filename of the main bundle file in the distributable directory
2324
*/
24-
exports.cssDistFilename = 'kbn-ui-shared-deps-src.css';
25+
const cssDistFilename = 'kbn-ui-shared-deps-src.css';
2526

2627
/**
2728
* Externals mapping inteded to be used in a webpack config
2829
*/
29-
exports.externals = {
30+
const externals = {
3031
/**
3132
* stateful deps
3233
*/
34+
'@kbn/ui-theme': '__kbnSharedDeps__.KbnUiTheme',
3335
'@kbn/i18n': '__kbnSharedDeps__.KbnI18n',
3436
'@kbn/i18n-react': '__kbnSharedDeps__.KbnI18nReact',
3537
'@emotion/react': '__kbnSharedDeps__.EmotionReact',
@@ -43,7 +45,6 @@ exports.externals = {
4345
'react-router-dom': '__kbnSharedDeps__.ReactRouterDom',
4446
'styled-components': '__kbnSharedDeps__.StyledComponents',
4547
'@kbn/monaco': '__kbnSharedDeps__.KbnMonaco',
46-
'@kbn/ui-shared-deps-src/theme': '__kbnSharedDeps__.Theme',
4748
// this is how plugins/consumers from npm load monaco
4849
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',
4950

@@ -77,3 +78,5 @@ exports.externals = {
7778
history: '__kbnSharedDeps__.History',
7879
classnames: '__kbnSharedDeps__.Classnames',
7980
};
81+
82+
module.exports = { distDir, jsFilename, cssDistFilename, externals };

packages/kbn-ui-shared-deps-src/src/entry.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ require('./polyfills');
1111
export const Jquery = require('jquery');
1212
window.$ = window.jQuery = Jquery;
1313
// mutates window.jQuery and window.$
14-
require('./flot_charts');
14+
require('@kbn/flot-charts');
1515

1616
// stateful deps
17+
export const KbnUiTheme = require('@kbn/ui-theme');
1718
export const KbnI18n = require('@kbn/i18n');
1819
export const KbnI18nReact = require('@kbn/i18n-react');
1920
export const EmotionReact = require('@emotion/react');
@@ -43,7 +44,6 @@ export const ElasticEuiChartsTheme = require('@elastic/eui/dist/eui_charts_theme
4344
export const ElasticDatemath = require('@elastic/datemath');
4445
export const ReactBeautifulDnD = require('react-beautiful-dnd');
4546

46-
export const Theme = require('./theme.ts');
4747
export const Lodash = require('lodash');
4848
export const LodashFp = require('lodash/fp');
4949

0 commit comments

Comments
 (0)