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

chore(NA): splits types from code on @kbn/ui-shared-deps-src #123074

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@
"@types/kbn__std": "link:bazel-bin/packages/kbn-std/npm_module_types",
"@types/kbn__telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools/npm_module_types",
"@types/kbn__ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm/npm_module_types",
"@types/kbn__ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src/npm_module_types",
"@types/kbn__utility-types": "link:bazel-bin/packages/kbn-utility-types/npm_module_types",
"@types/kbn__utils": "link:bazel-bin/packages/kbn-utils/npm_module_types",
"@types/license-checker": "15.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ filegroup(
"//packages/kbn-std:build_types",
"//packages/kbn-telemetry-tools:build_types",
"//packages/kbn-ui-shared-deps-npm:build_types",
"//packages/kbn-ui-shared-deps-src:build_types",
"//packages/kbn-utility-types:build_types",
"//packages/kbn-utils:build_types",
],
Expand Down
2 changes: 1 addition & 1 deletion packages/elastic-eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = {
].map(from => ({
from,
to: false,
disallowedMessage: `Use "@kbn/ui-shared-deps-src/theme" to access theme vars.`
disallowedMessage: `Use "@kbn/ui-shared-deps-src" to access theme vars.`
})),
],
],
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TYPES_DEPS = [
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-std:npm_module_types",
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
"//packages/kbn-ui-shared-deps-src",
"//packages/kbn-ui-shared-deps-src:npm_module_types",
"//packages/kbn-utils:npm_module_types",
"@npm//chalk",
"@npm//clean-webpack-plugin",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import TerserPlugin from 'terser-webpack-plugin';
import webpackMerge from 'webpack-merge';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CompressionPlugin from 'compression-webpack-plugin';
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';

import { Bundle, BundleRefs, WorkerConfig } from '../common';
import { BundleRefsPlugin } from './bundle_refs_plugin';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-storybook/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
"//packages/kbn-ui-shared-deps-src",
"//packages/kbn-ui-shared-deps-src:npm_module_types",
"//packages/kbn-utils:npm_module_types",
"@npm//@storybook/addons",
"@npm//@storybook/api",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-storybook/src/lib/run_storybook_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { logger } from '@storybook/node-logger';
import buildStandalone from '@storybook/react/standalone';
import { Flags, run } from '@kbn/dev-utils';
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as constants from './constants';

// Convert the flags to a Storybook loglevel
Expand Down
27 changes: 22 additions & 5 deletions packages/kbn-ui-shared-deps-src/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "kbn-ui-shared-deps-src"
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps-src"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__ui-shared-deps-src"

SOURCE_FILES = glob(
[
Expand All @@ -24,7 +25,6 @@ filegroup(

NPM_MODULE_EXTRA_FILES = [
"flot_charts/package.json",
"theme/package.json",
"package.json",
"README.md"
]
Expand Down Expand Up @@ -105,7 +105,7 @@ webpack(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types", ":shared_built_assets"],
deps = RUNTIME_DEPS + [":target_node", ":shared_built_assets"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand All @@ -124,3 +124,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)
3 changes: 1 addition & 2 deletions packages/kbn-ui-shared-deps-src/flot_charts/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"main": "../target_node/flot_charts/index.js",
"types": "../target_types/flot_charts/index.d.ts"
"main": "../target_node/flot_charts/index.js"
}
3 changes: 1 addition & 2 deletions packages/kbn-ui-shared-deps-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "target_node/index.js",
"types": "target_types/index.d.ts"
"main": "target_node/index.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,11 @@

const Path = require('path');

/**
* Absolute path to the distributable directory
*/
exports.distDir = Path.resolve(__dirname, '../shared_built_assets');

/**
* Filename of the main bundle file in the distributable directory
*/
exports.jsFilename = 'kbn-ui-shared-deps-src.js';

/**
* Filename of the main bundle file in the distributable directory
*/
exports.cssDistFilename = 'kbn-ui-shared-deps-src.css';

/**
* Externals mapping inteded to be used in a webpack config
*/
exports.externals = {
// extracted const vars
const distDir = Path.resolve(__dirname, '../shared_built_assets');
const jsFilename = 'kbn-ui-shared-deps-src.js';
const cssDistFilename = 'kbn-ui-shared-deps-src.css';
const externals = {
/**
* stateful deps
*/
Expand All @@ -43,7 +29,6 @@ exports.externals = {
'react-router-dom': '__kbnSharedDeps__.ReactRouterDom',
'styled-components': '__kbnSharedDeps__.StyledComponents',
'@kbn/monaco': '__kbnSharedDeps__.KbnMonaco',
'@kbn/ui-shared-deps-src/theme': '__kbnSharedDeps__.Theme',
// this is how plugins/consumers from npm load monaco
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',

Expand Down Expand Up @@ -77,3 +62,5 @@ exports.externals = {
history: '__kbnSharedDeps__.History',
classnames: '__kbnSharedDeps__.Classnames',
};

module.exports = { distDir, jsFilename, cssDistFilename, externals };
34 changes: 34 additions & 0 deletions packages/kbn-ui-shared-deps-src/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { distDir, jsFilename, cssDistFilename, externals } from './definitions';

/**
* Absolute path to the distributable directory
*/
export { distDir };

/**
* Filename of the main bundle file in the distributable directory
*/
export { jsFilename };

/**
* Filename of the main bundle file in the distributable directory
*/
export { cssDistFilename };

/**
* Externals mapping inteded to be used in a webpack config
*/
export { externals };

/**
* EUI Theme vars
*/
export * from './theme';
4 changes: 0 additions & 4 deletions packages/kbn-ui-shared-deps-src/theme/package.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/kbn-ui-shared-deps-src/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UiSharedDepsNpm = require('@kbn/ui-shared-deps-npm');

const UiSharedDepsSrc = require('./src');
const { distDir: UiSharedDepsSrcDistDir } = require('./src/definitions');

const MOMENT_SRC = require.resolve('moment/min/moment-with-locales.js');

Expand All @@ -33,7 +33,7 @@ module.exports = {
context: __dirname,
devtool: 'cheap-source-map',
output: {
path: UiSharedDepsSrc.distDir,
path: UiSharedDepsSrcDistDir,
filename: '[name].js',
chunkFilename: 'kbn-ui-shared-deps-src.chunk.[id].js',
sourceMapFilename: '[file].map',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { join } from 'path';
import { PackageInfo } from '@kbn/config';
import { fromRoot } from '@kbn/utils';
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import { IRouter } from '../../http';
import { UiPlugins } from '../../plugins';
import { FileHashCache } from './file_hash_cache';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import type { PluginInfo } from './get_plugin_bundle_paths';

export const getJsDependencyPaths = (
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/rendering/render_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import { PublicUiSettingsParams, UserProvidedValues } from '../ui_settings';

export const getSettingValue = <T>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { LineAnnotation, AnnotationDomainType, LineAnnotationStyle } from '@elas
import {
euiLightVars as lightEuiTheme,
euiDarkVars as darkEuiTheme,
} from '@kbn/ui-shared-deps-src/theme';
} from '@kbn/ui-shared-deps-src';

interface CurrentTimeProps {
isDarkMode: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/charts/public/static/components/endzones.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiSpacer } from '@elastic/eui';
import {
euiLightVars as lightEuiTheme,
euiDarkVars as darkEuiTheme,
} from '@kbn/ui-shared-deps-src/theme';
} from '@kbn/ui-shared-deps-src';

interface EndzonesProps {
isDarkMode: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { euiLightVars } from '@kbn/ui-shared-deps-src/theme';
import { euiLightVars } from '@kbn/ui-shared-deps-src';
import { FormattedMessage } from '@kbn/i18n-react';

import {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dev_tools/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom'
import { EuiTab, EuiTabs, EuiToolTip, EuiBetaBadge } from '@elastic/eui';
import { I18nProvider } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { euiThemeVars } from '@kbn/ui-shared-deps-src';

import { ApplicationStart, ChromeStart, ScopedHistory, CoreTheme } from 'src/core/public';
import { KibanaThemeProvider } from '../../kibana_react/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
EuiDataGridCellValueElementProps,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import {
euiLightVars as themeLight,
euiDarkVars as themeDark,
} from '@kbn/ui-shared-deps-src/theme';
import { euiLightVars as themeLight, euiDarkVars as themeDark } from '@kbn/ui-shared-deps-src';
import { DiscoverGridContext } from './discover_grid_context';
import { ElasticSearchHit } from '../../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

import React, { useContext, useEffect } from 'react';
import { EuiButtonIcon, EuiDataGridCellValueElementProps, EuiToolTip } from '@elastic/eui';
import {
euiLightVars as themeLight,
euiDarkVars as themeDark,
} from '@kbn/ui-shared-deps-src/theme';
import { euiLightVars as themeLight, euiDarkVars as themeDark } from '@kbn/ui-shared-deps-src';
import { i18n } from '@kbn/i18n';
import { DiscoverGridContext } from './discover_grid_context';
import { EsHitRecord } from '../../application/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
*/

import React, { Fragment, useContext, useEffect } from 'react';
import {
euiLightVars as themeLight,
euiDarkVars as themeDark,
} from '@kbn/ui-shared-deps-src/theme';
import { euiLightVars as themeLight, euiDarkVars as themeDark } from '@kbn/ui-shared-deps-src';
import type { DataView } from 'src/plugins/data/common';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { euiLightVars } from '@kbn/ui-shared-deps-src/theme';
import { euiLightVars } from '@kbn/ui-shared-deps-src';

interface ToolBarPaginationProps {
pageSize: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Observable, Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import useShallowCompareEffect from 'react-use/lib/useShallowCompareEffect';
import { EuiLoadingChart, EuiProgress } from '@elastic/eui';
import { euiLightVars as theme } from '@kbn/ui-shared-deps-src/theme';
import { euiLightVars as theme } from '@kbn/ui-shared-deps-src';
import { IExpressionLoaderParams, ExpressionRenderError, ExpressionRendererEvent } from './types';
import { ExpressionAstExpression, IInterpreterRenderHandlers } from '../common';
import { ExpressionLoader } from './loader';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import * as StatusCheckStates from './status_check_states';

import { injectI18n, FormattedMessage } from '@kbn/i18n-react';
import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { euiThemeVars } from '@kbn/ui-shared-deps-src';

class InstructionSetUi extends React.Component {
constructor(props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import useUpdateEffect from 'react-use/lib/useUpdateEffect';

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { euiThemeVars } from '@kbn/ui-shared-deps-src';

import type { Certificate } from '../common';
import { DocLink } from './doc_link';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import useList from 'react-use/lib/useList';
import useUpdateEffect from 'react-use/lib/useUpdateEffect';

import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { euiThemeVars } from '@kbn/ui-shared-deps-src';

export interface SingleCharsFieldProps {
defaultValue: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import constate from 'constate';
import type { FunctionComponent } from 'react';
import React, { useEffect, useRef, useState } from 'react';

import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { euiThemeVars } from '@kbn/ui-shared-deps-src';

import { useKibana } from './use_kibana';
import { VerificationCodeForm } from './verification_code_form';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { DecoratorFn } from '@storybook/react';
import React from 'react';
import * as styledComponents from 'styled-components';
import { ThemedStyledComponentsModule, ThemeProvider, ThemeProviderProps } from 'styled-components';
import { euiThemeVars, euiLightVars, euiDarkVars } from '@kbn/ui-shared-deps-src/theme';
import { euiThemeVars, euiLightVars, euiDarkVars } from '@kbn/ui-shared-deps-src';

export interface EuiTheme {
eui: typeof euiThemeVars;
Expand Down
Loading