[kbn/ui-shared-deps] split into two packages (#110558)

* [kbn/ui-shared-deps] split into two packages

* fix asset categorizer

* update snapshots

* reference npm dll from optimizer

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer 2021-09-16 12:06:46 -07:00 committed by GitHub
parent ea3bb98004
commit eaf70a0b4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 763 additions and 378 deletions

View file

@ -6,7 +6,7 @@ if [[ ! "${DISABLE_CI_STATS_SHIPPING:-}" ]]; then
echo "--- Ship Kibana Distribution Metrics to CI Stats" echo "--- Ship Kibana Distribution Metrics to CI Stats"
node scripts/ship_ci_stats \ node scripts/ship_ci_stats \
--metrics target/optimizer_bundle_metrics.json \ --metrics target/optimizer_bundle_metrics.json \
--metrics build/kibana/node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json --metrics build/kibana/node_modules/@kbn/ui-shared-deps-src/shared_built_assets/metrics.json
fi fi
echo "--- Upload Build Artifacts" echo "--- Upload Build Artifacts"

View file

@ -34,7 +34,7 @@ snapshots.js
/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/ /packages/kbn-test/src/functional_test_runner/__tests__/fixtures/
/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/ /packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/
/packages/kbn-ui-framework/dist /packages/kbn-ui-framework/dist
/packages/kbn-ui-shared-deps/src/flot_charts /packages/kbn-ui-shared-deps-src/src/flot_charts
/packages/kbn-monaco/src/painless/antlr /packages/kbn-monaco/src/painless/antlr
# Bazel # Bazel

View file

@ -1492,7 +1492,7 @@ module.exports = {
}, },
}, },
{ {
files: ['packages/kbn-ui-shared-deps/src/flot_charts/**/*.js'], files: ['packages/kbn-ui-shared-deps-src/src/flot_charts/**/*.js'],
env: { env: {
jquery: true, jquery: true,
}, },

3
.github/CODEOWNERS vendored
View file

@ -198,7 +198,8 @@
/packages/kbn-optimizer/ @elastic/kibana-operations /packages/kbn-optimizer/ @elastic/kibana-operations
/packages/kbn-pm/ @elastic/kibana-operations /packages/kbn-pm/ @elastic/kibana-operations
/packages/kbn-test/ @elastic/kibana-operations /packages/kbn-test/ @elastic/kibana-operations
/packages/kbn-ui-shared-deps/ @elastic/kibana-operations /packages/kbn-ui-shared-deps-npm/ @elastic/kibana-operations
/packages/kbn-ui-shared-deps-src/ @elastic/kibana-operations
/packages/kbn-es-archiver/ @elastic/kibana-operations /packages/kbn-es-archiver/ @elastic/kibana-operations
/packages/kbn-utils/ @elastic/kibana-operations /packages/kbn-utils/ @elastic/kibana-operations
/packages/kbn-cli-dev-mode/ @elastic/kibana-operations /packages/kbn-cli-dev-mode/ @elastic/kibana-operations

View file

@ -15,7 +15,7 @@
"uiActionsExamples": "examples/ui_action_examples", "uiActionsExamples": "examples/ui_action_examples",
"share": "src/plugins/share", "share": "src/plugins/share",
"home": "src/plugins/home", "home": "src/plugins/home",
"flot": "packages/kbn-ui-shared-deps/src/flot_charts", "flot": "packages/kbn-ui-shared-deps-src/src/flot_charts",
"charts": "src/plugins/charts", "charts": "src/plugins/charts",
"esUi": "src/plugins/es_ui_shared", "esUi": "src/plugins/es_ui_shared",
"devTools": "src/plugins/dev_tools", "devTools": "src/plugins/dev_tools",

View file

@ -66,9 +66,10 @@ longer necessary for us to include the `optimizer` in the
distributable version of Kibana Every plugin artifact contains all distributable version of Kibana Every plugin artifact contains all
plugin dependencies required to run the plugin, except some plugin dependencies required to run the plugin, except some
stateful dependencies shared across plugin bundles via stateful dependencies shared across plugin bundles via
`@kbn/ui-shared-deps`. This means that plugin artifacts _tend to `@kbn/ui-shared-deps-npm` and `@kbn/ui-shared-deps-src`. This means
be larger_ than they were in the legacy platform. To understand the that plugin artifacts _tend to be larger_ than they were in the
current size of your plugin artifact, run `@kbn/optimizer` with: legacy platform. To understand the current size of your plugin
artifact, run `@kbn/optimizer` with:
```bash ```bash
node scripts/build_kibana_platform_plugins.js --dist --profile --focus=my_plugin node scripts/build_kibana_platform_plugins.js --dist --profile --focus=my_plugin

View file

@ -59,9 +59,10 @@ longer necessary for us to include the `optimizer` in the
distributable version of {kib}. Every plugin artifact contains all distributable version of {kib}. Every plugin artifact contains all
plugin dependencies required to run the plugin, except some plugin dependencies required to run the plugin, except some
stateful dependencies shared across plugin bundles via stateful dependencies shared across plugin bundles via
`@kbn/ui-shared-deps`. This means that plugin artifacts _tend to `@kbn/ui-shared-deps-npm` and `@kbn/ui-shared-deps-src`. This means
be larger_ than they were in the legacy platform. To understand the that plugin artifacts _tend to be larger_ than they were in the
current size of your plugin artifact, run `@kbn/optimizer` with: legacy platform. To understand the current size of your plugin
artifact, run `@kbn/optimizer` with:
[source,bash] [source,bash]
---- ----

View file

@ -103,6 +103,7 @@ yarn kbn watch
- @kbn/test-subj-selector - @kbn/test-subj-selector
- @kbn/tinymath - @kbn/tinymath
- @kbn/ui-framework - @kbn/ui-framework
- @kbn/ui-shared-deps - @kbn/ui-shared-deps-npm
- @kbn/ui-shared-deps-src
- @kbn/utility-types - @kbn/utility-types
- @kbn/utils - @kbn/utils

View file

@ -158,7 +158,8 @@
"@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath", "@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath",
"@kbn/typed-react-router-config": "link:bazel-bin/packages/kbn-typed-react-router-config", "@kbn/typed-react-router-config": "link:bazel-bin/packages/kbn-typed-react-router-config",
"@kbn/ui-framework": "link:bazel-bin/packages/kbn-ui-framework", "@kbn/ui-framework": "link:bazel-bin/packages/kbn-ui-framework",
"@kbn/ui-shared-deps": "link:bazel-bin/packages/kbn-ui-shared-deps", "@kbn/ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm",
"@kbn/ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src",
"@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types", "@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types",
"@kbn/utils": "link:bazel-bin/packages/kbn-utils", "@kbn/utils": "link:bazel-bin/packages/kbn-utils",
"@loaders.gl/core": "^2.3.1", "@loaders.gl/core": "^2.3.1",

View file

@ -62,7 +62,8 @@ filegroup(
"//packages/kbn-tinymath:build", "//packages/kbn-tinymath:build",
"//packages/kbn-typed-react-router-config:build", "//packages/kbn-typed-react-router-config:build",
"//packages/kbn-ui-framework:build", "//packages/kbn-ui-framework:build",
"//packages/kbn-ui-shared-deps:build", "//packages/kbn-ui-shared-deps-npm:build",
"//packages/kbn-ui-shared-deps-src:build",
"//packages/kbn-utility-types:build", "//packages/kbn-utility-types:build",
"//packages/kbn-utils:build", "//packages/kbn-utils:build",
], ],

View file

@ -12,7 +12,7 @@ module.exports = {
* Used by `kbn-babel-preset` and `elastic-eslint-config-kibana`. * Used by `kbn-babel-preset` and `elastic-eslint-config-kibana`.
*/ */
USES_STYLED_COMPONENTS: [ USES_STYLED_COMPONENTS: [
/packages[\/\\]kbn-ui-shared-deps[\/\\]/, /packages[\/\\]kbn-ui-shared-deps-(npm|src)[\/\\]/,
/src[\/\\]plugins[\/\\](data|kibana_react)[\/\\]/, /src[\/\\]plugins[\/\\](data|kibana_react)[\/\\]/,
/x-pack[\/\\]plugins[\/\\](apm|beats_management|cases|fleet|infra|lists|observability|osquery|security_solution|timelines|uptime)[\/\\]/, /x-pack[\/\\]plugins[\/\\](apm|beats_management|cases|fleet|infra|lists|observability|osquery|security_solution|timelines|uptime)[\/\\]/,
/x-pack[\/\\]test[\/\\]plugin_functional[\/\\]plugins[\/\\]resolver_test[\/\\]/, /x-pack[\/\\]test[\/\\]plugin_functional[\/\\]plugins[\/\\]resolver_test[\/\\]/,

View file

@ -1,5 +1,5 @@
# @kbn/monaco # @kbn/monaco
A customized version of monaco that is automatically configured the way we want it to be when imported as `@kbn/monaco`. Additionally, imports to this package are automatically shared with all plugins using `@kbn/ui-shared-deps`. A customized version of monaco that is automatically configured the way we want it to be when imported as `@kbn/monaco`. Additionally, imports to this package are automatically shared with all plugins using `@kbn/ui-shared-deps-npm` and `@kbn/ui-shared-deps-src`.
Includes custom xjson language support. The `es_ui_shared` plugin has an example of how to use it, in the future we will likely expose helpers from this package to make using it everywhere a little more seamless. Includes custom xjson language support. The `es_ui_shared` plugin has an example of how to use it, in the future we will likely expose helpers from this package to make using it everywhere a little more seamless.

View file

@ -34,7 +34,8 @@ RUNTIME_DEPS = [
"//packages/kbn-config", "//packages/kbn-config",
"//packages/kbn-dev-utils", "//packages/kbn-dev-utils",
"//packages/kbn-std", "//packages/kbn-std",
"//packages/kbn-ui-shared-deps", "//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"//packages/kbn-utils", "//packages/kbn-utils",
"@npm//chalk", "@npm//chalk",
"@npm//clean-webpack-plugin", "@npm//clean-webpack-plugin",
@ -63,7 +64,8 @@ TYPES_DEPS = [
"//packages/kbn-config", "//packages/kbn-config",
"//packages/kbn-dev-utils", "//packages/kbn-dev-utils",
"//packages/kbn-std", "//packages/kbn-std",
"//packages/kbn-ui-shared-deps", "//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"//packages/kbn-utils", "//packages/kbn-utils",
"@npm//chalk", "@npm//chalk",
"@npm//clean-webpack-plugin", "@npm//clean-webpack-plugin",

File diff suppressed because one or more lines are too long

View file

@ -132,7 +132,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
expect(foo.cache.getModuleCount()).toBe(6); expect(foo.cache.getModuleCount()).toBe(6);
expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(` expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [ Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target_node/public_path_module_creator.js, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps-npm/target_node/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/kibana.json, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
@ -155,7 +155,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
<absolute path>/node_modules/@kbn/optimizer/postcss.config.js, <absolute path>/node_modules/@kbn/optimizer/postcss.config.js,
<absolute path>/node_modules/css-loader/package.json, <absolute path>/node_modules/css-loader/package.json,
<absolute path>/node_modules/style-loader/package.json, <absolute path>/node_modules/style-loader/package.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target_node/public_path_module_creator.js, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps-npm/target_node/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/kibana.json, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.scss, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.scss,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts,
@ -175,7 +175,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
expect(baz.cache.getReferencedFiles()).toMatchInlineSnapshot(` expect(baz.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [ Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target_node/public_path_module_creator.js, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps-npm/target_node/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/kibana.json, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/public/index.ts, <absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts, <absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,

View file

@ -19,6 +19,7 @@ import {
isNormalModule, isNormalModule,
isIgnoredModule, isIgnoredModule,
isConcatenatedModule, isConcatenatedModule,
isDelegatedModule,
getModulePath, getModulePath,
} from './webpack_helpers'; } from './webpack_helpers';
@ -118,7 +119,7 @@ export class PopulateBundleCachePlugin {
continue; continue;
} }
if (isExternalModule(module) || isIgnoredModule(module)) { if (isExternalModule(module) || isIgnoredModule(module) || isDelegatedModule(module)) {
continue; continue;
} }

View file

@ -15,7 +15,8 @@ import TerserPlugin from 'terser-webpack-plugin';
import webpackMerge from 'webpack-merge'; import webpackMerge from 'webpack-merge';
import { CleanWebpackPlugin } from 'clean-webpack-plugin'; import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CompressionPlugin from 'compression-webpack-plugin'; import CompressionPlugin from 'compression-webpack-plugin';
import * as UiSharedDeps from '@kbn/ui-shared-deps'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import { Bundle, BundleRefs, WorkerConfig } from '../common'; import { Bundle, BundleRefs, WorkerConfig } from '../common';
import { BundleRefsPlugin } from './bundle_refs_plugin'; import { BundleRefsPlugin } from './bundle_refs_plugin';
@ -65,7 +66,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
}, },
}, },
externals: [UiSharedDeps.externals], externals: [UiSharedDepsSrc.externals],
plugins: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
@ -90,7 +91,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
include: [ENTRY_CREATOR], include: [ENTRY_CREATOR],
use: [ use: [
{ {
loader: UiSharedDeps.publicPathLoader, loader: UiSharedDepsNpm.publicPathLoader,
options: { options: {
key: bundle.id, key: bundle.id,
}, },
@ -260,6 +261,10 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
test: /\.(js|css)$/, test: /\.(js|css)$/,
cache: false, cache: false,
}), }),
new webpack.DllReferencePlugin({
context: worker.repoRoot,
manifest: require(UiSharedDepsNpm.dllManifestPath),
}),
], ],
optimization: { optimization: {

View file

@ -151,6 +151,17 @@ export function isConcatenatedModule(module: any): module is WebpackConcatenated
return module?.constructor?.name === 'ConcatenatedModule'; return module?.constructor?.name === 'ConcatenatedModule';
} }
/** module replacing imports for DLL referenced */
export interface WebpackDelegatedModule {
type: string;
id: number;
dependencies: unknown[];
}
export function isDelegatedModule(module: any): module is WebpackDelegatedModule {
return module?.constructor?.name === 'DelegatedModule';
}
export function getModulePath(module: WebpackNormalModule) { export function getModulePath(module: WebpackNormalModule) {
const queryIndex = module.resource.indexOf('?'); const queryIndex = module.resource.indexOf('?');
return queryIndex === -1 ? module.resource : module.resource.slice(0, queryIndex); return queryIndex === -1 ? module.resource : module.resource.slice(0, queryIndex);

View file

@ -30,7 +30,8 @@ NPM_MODULE_EXTRA_FILES = [
RUNTIME_DEPS = [ RUNTIME_DEPS = [
"//packages/kbn-dev-utils", "//packages/kbn-dev-utils",
"//packages/kbn-ui-shared-deps", "//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"@npm//@storybook/addons", "@npm//@storybook/addons",
"@npm//@storybook/api", "@npm//@storybook/api",
"@npm//@storybook/components", "@npm//@storybook/components",
@ -46,7 +47,8 @@ RUNTIME_DEPS = [
TYPES_DEPS = [ TYPES_DEPS = [
"//packages/kbn-dev-utils", "//packages/kbn-dev-utils",
"//packages/kbn-ui-shared-deps", "//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"@npm//@storybook/addons", "@npm//@storybook/addons",
"@npm//@storybook/api", "@npm//@storybook/api",
"@npm//@storybook/components", "@npm//@storybook/components",

View file

@ -22,7 +22,7 @@ export function registerThemeSwitcherAddon() {
) as HTMLLinkElement | null; ) as HTMLLinkElement | null;
if (stylesheet) { if (stylesheet) {
stylesheet.href = `kbn-ui-shared-deps.${globals.euiTheme}.css`; stylesheet.href = `kbn-ui-shared-deps-npm.${globals.euiTheme}.css`;
} }
}); });

View file

@ -10,7 +10,8 @@ import { join } from 'path';
import { logger } from '@storybook/node-logger'; import { logger } from '@storybook/node-logger';
import buildStandalone from '@storybook/react/standalone'; import buildStandalone from '@storybook/react/standalone';
import { Flags, run } from '@kbn/dev-utils'; import { Flags, run } from '@kbn/dev-utils';
import { distDir } from '@kbn/ui-shared-deps'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import * as constants from './constants'; import * as constants from './constants';
// Convert the flags to a Storybook loglevel // Convert the flags to a Storybook loglevel
@ -35,7 +36,7 @@ export function runStorybookCli({ configDir, name }: { configDir: string; name:
async ({ flags, log }) => { async ({ flags, log }) => {
log.debug('Global config:\n', constants); log.debug('Global config:\n', constants);
const staticDir = [distDir]; const staticDir = [UiSharedDepsNpm.distDir, UiSharedDepsSrc.distDir];
const config: Record<string, any> = { const config: Record<string, any> = {
configDir, configDir,
mode: flags.site ? 'static' : 'dev', mode: flags.site ? 'static' : 'dev',

View file

@ -6,7 +6,7 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import { externals } from '@kbn/ui-shared-deps'; import { externals } from '@kbn/ui-shared-deps-src';
import { stringifyRequest } from 'loader-utils'; import { stringifyRequest } from 'loader-utils';
import { resolve } from 'path'; import { resolve } from 'path';
import { Configuration, Stats } from 'webpack'; import { Configuration, Stats } from 'webpack';

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- This is a copy of the <!-- This is a copy of the
[Storybook IFrame template](https://github.com/storybookjs/storybook/blob/7874ca357c6cb54f3f258dc61f6becae6783fba6/lib/core/src/server/templates/index.ejs). [Storybook IFrame template](https://github.com/storybookjs/storybook/blob/7874ca357c6cb54f3f258dc61f6becae6783fba6/lib/core/src/server/templates/index.ejs).
We use this one instead because we want to add the @kbn/ui-shared-deps tags here. We use this one instead because we want to add the @kbn/ui-shared-deps-* tags here.
--> -->
<html lang="en"> <html lang="en">
<head> <head>
@ -16,12 +16,13 @@
<!-- Added for Kibana shared dependencies --> <!-- Added for Kibana shared dependencies -->
<script> <script>
window.__kbnPublicPath__ = { 'kbn-ui-shared-deps': '.' }; window.__kbnPublicPath__ = { 'kbn-ui-shared-deps-npm': '.', 'kbn-ui-shared-deps-src': '.' };
</script> </script>
<script src="kbn-ui-shared-deps.@elastic.js"></script> <script src="kbn-ui-shared-deps-npm.@elastic.js"></script>
<script src="kbn-ui-shared-deps.js"></script> <script src="kbn-ui-shared-deps-npm.js"></script>
<link href="kbn-ui-shared-deps.css" rel="stylesheet" /> <script src="kbn-ui-shared-deps-src.js"></script>
<link id="eui-theme-css" href="kbn-ui-shared-deps.v8.light.css" rel="stylesheet" /> <link href="kbn-ui-shared-deps-npm.css" rel="stylesheet" />
<link id="eui-theme-css" href="kbn-ui-shared-deps-npm.v8.light.css" rel="stylesheet" />
<!-- --> <!-- -->
<% if (typeof headHtmlSnippet !== 'undefined') { %> <%= headHtmlSnippet %> <% } %> <% <% if (typeof headHtmlSnippet !== 'undefined') { %> <%= headHtmlSnippet %> <% } %> <%

View file

@ -3,8 +3,8 @@ load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli") 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_BASE_NAME = "kbn-ui-shared-deps" PKG_BASE_NAME = "kbn-ui-shared-deps-npm"
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps" PKG_REQUIRE_NAME = "@kbn/ui-shared-deps-npm"
SOURCE_FILES = glob( SOURCE_FILES = glob(
[ [
@ -23,20 +23,13 @@ filegroup(
) )
NPM_MODULE_EXTRA_FILES = [ NPM_MODULE_EXTRA_FILES = [
"flot_charts/package.json", "eui_theme_vars/package.json",
"theme/package.json",
"package.json", "package.json",
"README.md" "README.md"
] ]
RUNTIME_DEPS = [ RUNTIME_DEPS = [
"//packages/elastic-datemath", "//packages/elastic-datemath",
"//packages/elastic-safer-lodash-set",
"//packages/kbn-analytics",
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"//packages/kbn-monaco",
"//packages/kbn-std",
"//packages/kbn-utils", "//packages/kbn-utils",
"@npm//@elastic/charts", "@npm//@elastic/charts",
"@npm//@elastic/eui", "@npm//@elastic/eui",
@ -45,6 +38,7 @@ RUNTIME_DEPS = [
"@npm//abortcontroller-polyfill", "@npm//abortcontroller-polyfill",
"@npm//angular", "@npm//angular",
"@npm//babel-loader", "@npm//babel-loader",
"@npm//babel-plugin-transform-react-remove-prop-types",
"@npm//core-js", "@npm//core-js",
"@npm//css-loader", "@npm//css-loader",
"@npm//fflate", "@npm//fflate",
@ -71,14 +65,12 @@ RUNTIME_DEPS = [
"@npm//whatwg-fetch" "@npm//whatwg-fetch"
] ]
WEBPACK_DEPS = [
"@npm//clean-webpack-plugin",
]
TYPES_DEPS = [ TYPES_DEPS = [
"//packages/elastic-datemath", "//packages/elastic-datemath",
"//packages/elastic-safer-lodash-set",
"//packages/kbn-analytics",
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"//packages/kbn-monaco",
"//packages/kbn-std",
"//packages/kbn-utils", "//packages/kbn-utils",
"@npm//@elastic/charts", "@npm//@elastic/charts",
"@npm//@elastic/eui", "@npm//@elastic/eui",
@ -146,7 +138,7 @@ ts_project(
webpack( webpack(
name = "shared_built_assets", name = "shared_built_assets",
data = RUNTIME_DEPS + [ data = RUNTIME_DEPS + WEBPACK_DEPS + [
"//:package.json", "//:package.json",
":srcs", ":srcs",
":tsconfig", ":tsconfig",

View file

@ -0,0 +1,3 @@
# `@kbn/ui-shared-deps-npm`
Shared dependencies that must only have a single instance and also come from NPM are installed and re-exported from here. To consume them, import the package and merge the `externals` export into your webpack config so that all references to the supported modules will be remapped to use the global versions.

View file

@ -0,0 +1,4 @@
{
"main": "../target_node/eui_theme_vars.js",
"types": "../target_types/eui_theme_vars.d.ts"
}

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/ui-shared-deps-npm",
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "target_node/index.js",
"browser": "target_node/entry.js",
"types": "target_types/index.d.ts"
}

View file

@ -0,0 +1,49 @@
/*
* 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.
*/
const Path = require('path');
/**
* Absolute path to the distributable directory
*/
exports.distDir = Path.resolve(__dirname, '../shared_built_assets');
/**
* Path to dll manifest of modules included in this bundle
*/
exports.dllManifestPath = Path.resolve(exports.distDir, 'kbn-ui-shared-deps-npm-manifest.json');
/**
* Filename of the main bundle file in the distributable directory
*/
exports.dllFilename = 'kbn-ui-shared-deps-npm.dll.js';
/**
* Filename of the light-theme css file in the distributable directory
*/
exports.lightCssDistFilename = 'kbn-ui-shared-deps-npm.v7.light.css';
/**
* Filename of the light-theme css file in the distributable directory
*/
exports.lightV8CssDistFilename = 'kbn-ui-shared-deps-npm.v8.light.css';
/**
* Filename of the dark-theme css file in the distributable directory
*/
exports.darkCssDistFilename = 'kbn-ui-shared-deps-npm.v7.dark.css';
/**
* Filename of the dark-theme css file in the distributable directory
*/
exports.darkV8CssDistFilename = 'kbn-ui-shared-deps-npm.v8.dark.css';
/**
* Webpack loader for configuring the public path lookup from `window.__kbnPublicPath__`.
*/
exports.publicPathLoader = require.resolve('./public_path_loader');

View file

@ -16,5 +16,5 @@ module.exports = function (source) {
const options = this.query; const options = this.query;
const valOpts = Qs.stringify({ key: options.key }); const valOpts = Qs.stringify({ key: options.key });
const req = `${VAL_LOADER}?${valOpts}!${MODULE_CREATOR}`; const req = `${VAL_LOADER}?${valOpts}!${MODULE_CREATOR}`;
return `import ${stringifyRequest(this, req)};${source}`; return `require(${stringifyRequest(this, req)});${source}`;
}; };

View file

@ -8,7 +8,7 @@
"outDir": "./target_types", "outDir": "./target_types",
"rootDir": "src", "rootDir": "src",
"sourceMap": true, "sourceMap": true,
"sourceRoot": "../../../../packages/kbn-ui-shared-deps/src", "sourceRoot": "../../../../packages/kbn-ui-shared-deps-npm/src",
"types": [ "types": [
"node", "node",
"resize-observer-polyfill" "resize-observer-polyfill"

View file

@ -0,0 +1,175 @@
/*
* 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.
*/
const Path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { REPO_ROOT } = require('@kbn/utils');
const UiSharedDepsNpm = require('./src/index');
const MOMENT_SRC = require.resolve('moment/min/moment-with-locales.js');
const WEBPACK_SRC = require.resolve('webpack');
module.exports = (_, argv) => {
const outputPath = argv.outputPath ? Path.resolve(argv.outputPath) : UiSharedDepsNpm.distDir;
return {
node: {
child_process: 'empty',
fs: 'empty',
},
externals: {
module: 'module',
},
mode: 'production',
entry: {
'kbn-ui-shared-deps-npm': [
// polyfill code
'core-js/stable',
'regenerator-runtime/runtime',
'whatwg-fetch',
'symbol-observable',
// modules from npm
'@elastic/charts',
'@elastic/datemath',
'@elastic/eui',
'@elastic/eui/dist/eui_charts_theme',
'@elastic/eui/lib/services',
'@elastic/eui/lib/services/format',
'@elastic/eui/dist/eui_theme_light.json',
'@elastic/eui/dist/eui_theme_dark.json',
'@elastic/eui/dist/eui_theme_amsterdam_light.json',
'@elastic/eui/dist/eui_theme_amsterdam_dark.json',
'@elastic/numeral',
'@emotion/react',
'angular',
'classnames',
'fflate',
'history',
'jquery',
'lodash',
'lodash/fp',
'moment-timezone/moment-timezone',
'moment-timezone/data/packed/latest.json',
'moment',
'react-beautiful-dnd',
'react-dom',
'react-dom/server',
'react-router-dom',
'react-router',
'react',
'rison-node',
'rxjs',
'rxjs/operators',
'styled-components',
'tslib',
],
'kbn-ui-shared-deps-npm.v7.dark': ['@elastic/eui/dist/eui_theme_dark.css'],
'kbn-ui-shared-deps-npm.v7.light': ['@elastic/eui/dist/eui_theme_light.css'],
'kbn-ui-shared-deps-npm.v8.dark': ['@elastic/eui/dist/eui_theme_amsterdam_dark.css'],
'kbn-ui-shared-deps-npm.v8.light': ['@elastic/eui/dist/eui_theme_amsterdam_light.css'],
},
context: __dirname,
devtool: 'cheap-source-map',
output: {
path: outputPath,
filename: '[name].dll.js',
chunkFilename: 'kbn-ui-shared-deps-npm.chunk.[id].js',
devtoolModuleFilenameTemplate: (info) =>
`kbn-ui-shared-deps-npm/${Path.relative(REPO_ROOT, info.absoluteResourcePath)}`,
library: '__kbnSharedDeps_npm__',
futureEmitAssets: true,
},
module: {
noParse: [MOMENT_SRC, WEBPACK_SRC],
rules: [
{
include: [require.resolve('jquery')],
use: [
{
loader: UiSharedDepsNpm.publicPathLoader,
options: {
key: 'kbn-ui-shared-deps-npm',
},
},
],
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /[\\\/]@elastic[\\\/]eui[\\\/].*\.js$/,
use: [
{
loader: 'babel-loader',
options: {
plugins: [
[
require.resolve('babel-plugin-transform-react-remove-prop-types'),
{
mode: 'remove',
removeImport: true,
},
],
],
},
},
],
},
],
},
resolve: {
alias: {
moment: MOMENT_SRC,
// NOTE: Used to include react profiling on bundles
// https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977#webpack-4
'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',
},
extensions: ['.js', '.ts'],
symlinks: false,
},
optimization: {
minimize: false,
noEmitOnErrors: true,
},
performance: {
// NOTE: we are disabling this as those hints
// are more tailored for the final bundles result
// and not for the webpack compilations performance itself
hints: false,
},
plugins: [
new CleanWebpackPlugin({
protectWebpackAssets: false,
cleanAfterEveryBuildPatterns: [
'kbn-ui-shared-deps-npm.{v7,v8}.{dark,light}.{dll.js,dll.js.map}',
'kbn-ui-shared-deps-npm.{v7,v8}.{dark,light}-manifest.json',
],
}),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new webpack.DllPlugin({
context: REPO_ROOT,
path: Path.resolve(outputPath, '[name]-manifest.json'),
name: '__kbnSharedDeps_npm__',
}),
],
};
};

View file

@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}

View file

@ -0,0 +1,128 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
PKG_BASE_NAME = "kbn-ui-shared-deps-src"
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps-src"
SOURCE_FILES = glob(
[
"src/**/*",
],
exclude = [
"**/*.md",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"flot_charts/package.json",
"theme/package.json",
"package.json",
"README.md"
]
RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/elastic-safer-lodash-set",
"//packages/kbn-analytics",
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"//packages/kbn-monaco",
"//packages/kbn-std",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-utils",
]
TYPES_DEPS = [
"//packages/elastic-datemath",
"//packages/elastic-safer-lodash-set",
"//packages/kbn-analytics",
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"//packages/kbn-monaco",
"//packages/kbn-std",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-utils",
"@npm//@elastic/eui",
"@npm//resize-observer-polyfill",
"@npm//webpack",
]
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,
allow_js = True,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
)
webpack(
name = "shared_built_assets",
data = RUNTIME_DEPS + [
"//:package.json",
":srcs",
":tsconfig",
":webpack.config.js",
],
output_dir = True,
args = [
"--config",
"$(location webpack.config.js)",
"--output-path",
"$(@D)",
"--display=minimal"
],
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types", ":shared_built_assets"],
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"],
)

View file

@ -0,0 +1,3 @@
# `@kbn/ui-shared-deps-src`
Shared dependencies that must only have a single instance and are built from the repository are installed and re-exported from here. To consume them, import the package and merge the `externals` export into your webpack config so that all references to the supported modules will be remapped to use the global versions.

View file

@ -1,5 +1,5 @@
{ {
"name": "@kbn/ui-shared-deps", "name": "@kbn/ui-shared-deps-src",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"license": "SSPL-1.0 OR Elastic License 2.0", "license": "SSPL-1.0 OR Elastic License 2.0",

View file

@ -8,9 +8,9 @@
require('./polyfills'); require('./polyfills');
// must load before angular
export const Jquery = require('jquery'); export const Jquery = require('jquery');
window.$ = window.jQuery = Jquery; window.$ = window.jQuery = Jquery;
// mutates window.jQuery and window.$
require('./flot_charts'); require('./flot_charts');
// stateful deps // stateful deps
@ -26,7 +26,8 @@ export const MonacoBarePluginApi = require('@kbn/monaco').BarePluginApi;
export const React = require('react'); export const React = require('react');
export const ReactDom = require('react-dom'); export const ReactDom = require('react-dom');
export const ReactDomServer = require('react-dom/server'); export const ReactDomServer = require('react-dom/server');
export const ReactRouter = require('react-router'); // eslint-disable-line // eslint-disable-next-line @kbn/eslint/module_migration
export const ReactRouter = require('react-router');
export const ReactRouterDom = require('react-router-dom'); export const ReactRouterDom = require('react-router-dom');
export const StyledComponents = require('styled-components'); export const StyledComponents = require('styled-components');
@ -41,12 +42,14 @@ export const ElasticEui = require('@elastic/eui');
export const ElasticEuiLibServices = require('@elastic/eui/lib/services'); export const ElasticEuiLibServices = require('@elastic/eui/lib/services');
export const ElasticEuiLibServicesFormat = require('@elastic/eui/lib/services/format'); export const ElasticEuiLibServicesFormat = require('@elastic/eui/lib/services/format');
export const ElasticEuiChartsTheme = require('@elastic/eui/dist/eui_charts_theme'); export const ElasticEuiChartsTheme = require('@elastic/eui/dist/eui_charts_theme');
export const ElasticDatemath = require('@elastic/datemath');
export const ReactBeautifulDnD = require('react-beautiful-dnd'); export const ReactBeautifulDnD = require('react-beautiful-dnd');
export const Theme = require('./theme.ts'); export const Theme = require('./theme.ts');
export const Lodash = require('lodash'); export const Lodash = require('lodash');
export const LodashFp = require('lodash/fp'); export const LodashFp = require('lodash/fp');
import { unzlibSync, strFromU8 } from 'fflate'; const { unzlibSync, strFromU8 } = require('fflate');
export const Fflate = { unzlibSync, strFromU8 }; export const Fflate = { unzlibSync, strFromU8 };
// runtime deps which don't need to be copied across all bundles // runtime deps which don't need to be copied across all bundles

View file

@ -11,48 +11,25 @@ const Path = require('path');
/** /**
* Absolute path to the distributable directory * Absolute path to the distributable directory
*/ */
exports.distDir = Path.resolve(__dirname, '..', 'shared_built_assets'); exports.distDir = Path.resolve(__dirname, '../shared_built_assets');
/**
* Filename of files that must be loaded before the jsFilename
*/
exports.jsDepFilenames = ['kbn-ui-shared-deps.@elastic.js'];
/** /**
* Filename of the main bundle file in the distributable directory * Filename of the main bundle file in the distributable directory
*/ */
exports.jsFilename = 'kbn-ui-shared-deps.js'; exports.jsFilename = 'kbn-ui-shared-deps-src.js';
/** /**
* Filename of the unthemed css file in the distributable directory * Filename of the main bundle file in the distributable directory
*/ */
exports.baseCssDistFilename = 'kbn-ui-shared-deps.css'; exports.cssDistFilename = 'kbn-ui-shared-deps-src.css';
/**
* Filename of the light-theme css file in the distributable directory
*/
exports.lightCssDistFilename = 'kbn-ui-shared-deps.v7.light.css';
/**
* Filename of the light-theme css file in the distributable directory
*/
exports.lightV8CssDistFilename = 'kbn-ui-shared-deps.v8.light.css';
/**
* Filename of the dark-theme css file in the distributable directory
*/
exports.darkCssDistFilename = 'kbn-ui-shared-deps.v7.dark.css';
/**
* Filename of the dark-theme css file in the distributable directory
*/
exports.darkV8CssDistFilename = 'kbn-ui-shared-deps.v8.dark.css';
/** /**
* Externals mapping inteded to be used in a webpack config * Externals mapping inteded to be used in a webpack config
*/ */
exports.externals = { exports.externals = {
// stateful deps /**
* stateful deps
*/
angular: '__kbnSharedDeps__.Angular', angular: '__kbnSharedDeps__.Angular',
'@kbn/i18n': '__kbnSharedDeps__.KbnI18n', '@kbn/i18n': '__kbnSharedDeps__.KbnI18n',
'@kbn/i18n/angular': '__kbnSharedDeps__.KbnI18nAngular', '@kbn/i18n/angular': '__kbnSharedDeps__.KbnI18nAngular',
@ -68,7 +45,7 @@ exports.externals = {
'react-router-dom': '__kbnSharedDeps__.ReactRouterDom', 'react-router-dom': '__kbnSharedDeps__.ReactRouterDom',
'styled-components': '__kbnSharedDeps__.StyledComponents', 'styled-components': '__kbnSharedDeps__.StyledComponents',
'@kbn/monaco': '__kbnSharedDeps__.KbnMonaco', '@kbn/monaco': '__kbnSharedDeps__.KbnMonaco',
'@kbn/ui-shared-deps/theme': '__kbnSharedDeps__.Theme', '@kbn/ui-shared-deps-src/theme': '__kbnSharedDeps__.Theme',
// this is how plugins/consumers from npm load monaco // this is how plugins/consumers from npm load monaco
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi', 'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',
@ -103,8 +80,3 @@ exports.externals = {
history: '__kbnSharedDeps__.History', history: '__kbnSharedDeps__.History',
classnames: '__kbnSharedDeps__.Classnames', classnames: '__kbnSharedDeps__.Classnames',
}; };
/**
* Webpack loader for configuring the public path lookup from `window.__kbnPublicPath__`.
*/
exports.publicPathLoader = require.resolve('./public_path_loader');

View file

@ -6,11 +6,14 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import LightTheme from '@elastic/eui/dist/eui_theme_light.json'; import { default as v7Light } from '@elastic/eui/dist/eui_theme_light.json';
import { default as v7Dark } from '@elastic/eui/dist/eui_theme_dark.json';
import { default as v8Light } from '@elastic/eui/dist/eui_theme_amsterdam_light.json';
import { default as v8Dark } from '@elastic/eui/dist/eui_theme_amsterdam_dark.json';
const globals: any = typeof window === 'undefined' ? {} : window; const globals: any = typeof window === 'undefined' ? {} : window;
export type Theme = typeof LightTheme; export type Theme = typeof v7Light | typeof v8Light;
// in the Kibana app we can rely on this global being defined, but in // in the Kibana app we can rely on this global being defined, but in
// some cases (like jest) the global is undefined // some cases (like jest) the global is undefined
@ -21,11 +24,11 @@ export const darkMode = tag.endsWith('dark');
export let euiLightVars: Theme; export let euiLightVars: Theme;
export let euiDarkVars: Theme; export let euiDarkVars: Theme;
if (version === 7) { if (version === 7) {
euiLightVars = require('@elastic/eui/dist/eui_theme_light.json'); euiLightVars = v7Light;
euiDarkVars = require('@elastic/eui/dist/eui_theme_dark.json'); euiDarkVars = v7Dark;
} else { } else {
euiLightVars = require('@elastic/eui/dist/eui_theme_amsterdam_light.json'); euiLightVars = v8Light;
euiDarkVars = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json'); euiDarkVars = v8Dark;
} }
/** /**

View file

@ -0,0 +1,20 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"allowJs": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "./target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-ui-shared-deps-src/src",
"types": [
"node",
"resize-observer-polyfill"
]
},
"include": [
"src/**/*",
]
}

View file

@ -7,14 +7,15 @@
*/ */
const Path = require('path'); const Path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { REPO_ROOT } = require('@kbn/utils'); const { REPO_ROOT } = require('@kbn/utils');
const UiSharedDepsNpm = require('@kbn/ui-shared-deps-npm');
const UiSharedDeps = require('./src/index'); const UiSharedDepsSrc = require('./src');
const MOMENT_SRC = require.resolve('moment/min/moment-with-locales.js'); const MOMENT_SRC = require.resolve('moment/min/moment-with-locales.js');
const WEBPACK_SRC = require.resolve('webpack');
module.exports = { module.exports = {
node: { node: {
@ -26,42 +27,34 @@ module.exports = {
}, },
mode: 'production', mode: 'production',
entry: { entry: {
'kbn-ui-shared-deps': './src/entry.js', 'kbn-ui-shared-deps-src': './src/entry.js',
'kbn-ui-shared-deps.v7.dark': ['@elastic/eui/dist/eui_theme_dark.css'],
'kbn-ui-shared-deps.v7.light': ['@elastic/eui/dist/eui_theme_light.css'],
'kbn-ui-shared-deps.v8.dark': ['@elastic/eui/dist/eui_theme_amsterdam_dark.css'],
'kbn-ui-shared-deps.v8.light': ['@elastic/eui/dist/eui_theme_amsterdam_light.css'],
}, },
context: __dirname, context: __dirname,
devtool: 'cheap-source-map', devtool: 'cheap-source-map',
output: { output: {
path: UiSharedDeps.distDir, path: UiSharedDepsSrc.distDir,
filename: '[name].js', filename: '[name].js',
chunkFilename: 'kbn-ui-shared-deps-src.chunk.[id].js',
sourceMapFilename: '[file].map', sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: (info) => devtoolModuleFilenameTemplate: (info) =>
`kbn-ui-shared-deps/${Path.relative(REPO_ROOT, info.absoluteResourcePath)}`, `kbn-ui-shared-deps-src/${Path.relative(REPO_ROOT, info.absoluteResourcePath)}`,
library: '__kbnSharedDeps__', library: '__kbnSharedDeps__',
futureEmitAssets: true, futureEmitAssets: true,
}, },
module: { module: {
noParse: [MOMENT_SRC, WEBPACK_SRC],
rules: [ rules: [
{ {
include: [require.resolve('./src/entry.js')], include: [require.resolve('./src/entry.js')],
use: [ use: [
{ {
loader: UiSharedDeps.publicPathLoader, loader: UiSharedDepsNpm.publicPathLoader,
options: { options: {
key: 'kbn-ui-shared-deps', key: 'kbn-ui-shared-deps-src',
}, },
}, },
], ],
}, },
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{ {
include: [require.resolve('./src/theme.ts')], include: [require.resolve('./src/theme.ts')],
use: [ use: [
@ -74,23 +67,8 @@ module.exports = {
], ],
}, },
{ {
test: /[\\\/]@elastic[\\\/]eui[\\\/].*\.js$/, test: /\.css$/,
use: [ use: [MiniCssExtractPlugin.loader, 'css-loader'],
{
loader: 'babel-loader',
options: {
plugins: [
[
require.resolve('babel-plugin-transform-react-remove-prop-types'),
{
mode: 'remove',
removeImport: true,
},
],
],
},
},
],
}, },
{ {
test: /\.(ttf)(\?|$)/, test: /\.(ttf)(\?|$)/,
@ -103,6 +81,8 @@ module.exports = {
}, },
resolve: { resolve: {
extensions: ['.js', '.ts'],
symlinks: false,
alias: { alias: {
moment: MOMENT_SRC, moment: MOMENT_SRC,
// NOTE: Used to include react profiling on bundles // NOTE: Used to include react profiling on bundles
@ -110,23 +90,11 @@ module.exports = {
'react-dom$': 'react-dom/profiling', 'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling', 'scheduler/tracing': 'scheduler/tracing-profiling',
}, },
extensions: ['.js', '.ts'],
symlinks: false,
}, },
optimization: { optimization: {
minimize: false, minimize: false,
noEmitOnErrors: true, noEmitOnErrors: true,
splitChunks: {
cacheGroups: {
'kbn-ui-shared-deps.@elastic': {
name: 'kbn-ui-shared-deps.@elastic',
test: (m) => m.resource && m.resource.includes('@elastic'),
chunks: 'all',
enforce: true,
},
},
},
}, },
performance: { performance: {
@ -140,5 +108,10 @@ module.exports = {
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: '[name].css', filename: '[name].css',
}), }),
new webpack.DllReferencePlugin({
context: REPO_ROOT,
manifest: require(UiSharedDepsNpm.dllManifestPath), // eslint-disable-line
}),
], ],
}; };

View file

@ -1,3 +0,0 @@
# `@kbn/ui-shared-deps`
Shared dependencies that must only have a single instance are installed and re-exported from here. To consume them, import the package and merge the `externals` export into your webpack config so that all references to the supported modules will be remapped to use the global versions.

View file

@ -11,6 +11,10 @@ jest.doMock('./bundles_route', () => ({
registerRouteForBundle: registerRouteForBundleMock, registerRouteForBundle: registerRouteForBundleMock,
})); }));
jest.doMock('@kbn/ui-shared-deps', () => ({ jest.doMock('@kbn/ui-shared-deps-src', () => ({
distDir: 'uiSharedDepsDistDir', distDir: 'uiSharedDepsSrcDistDir',
}));
jest.doMock('@kbn/ui-shared-deps-npm', () => ({
distDir: 'uiSharedDepsNpmDistDir',
})); }));

View file

@ -56,14 +56,22 @@ describe('registerBundleRoutes', () => {
uiPlugins: createUiPlugins(), uiPlugins: createUiPlugins(),
}); });
expect(registerRouteForBundleMock).toHaveBeenCalledTimes(2); expect(registerRouteForBundleMock).toHaveBeenCalledTimes(3);
expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, { expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, {
fileHashCache: expect.any(FileHashCache), fileHashCache: expect.any(FileHashCache),
isDist: true, isDist: true,
bundlesPath: 'uiSharedDepsDistDir', bundlesPath: 'uiSharedDepsSrcDistDir',
publicPath: '/server-base-path/42/bundles/kbn-ui-shared-deps/', publicPath: '/server-base-path/42/bundles/kbn-ui-shared-deps-src/',
routePath: '/42/bundles/kbn-ui-shared-deps/', routePath: '/42/bundles/kbn-ui-shared-deps-src/',
});
expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, {
fileHashCache: expect.any(FileHashCache),
isDist: true,
bundlesPath: 'uiSharedDepsNpmDistDir',
publicPath: '/server-base-path/42/bundles/kbn-ui-shared-deps-npm/',
routePath: '/42/bundles/kbn-ui-shared-deps-npm/',
}); });
expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, { expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, {
@ -83,7 +91,7 @@ describe('registerBundleRoutes', () => {
uiPlugins: createUiPlugins('plugin-a', 'plugin-b'), uiPlugins: createUiPlugins('plugin-a', 'plugin-b'),
}); });
expect(registerRouteForBundleMock).toHaveBeenCalledTimes(4); expect(registerRouteForBundleMock).toHaveBeenCalledTimes(5);
expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, { expect(registerRouteForBundleMock).toHaveBeenCalledWith(router, {
fileHashCache: expect.any(FileHashCache), fileHashCache: expect.any(FileHashCache),

View file

@ -9,7 +9,8 @@
import { join } from 'path'; import { join } from 'path';
import { PackageInfo } from '@kbn/config'; import { PackageInfo } from '@kbn/config';
import { fromRoot } from '@kbn/utils'; import { fromRoot } from '@kbn/utils';
import { distDir as uiSharedDepsDistDir } from '@kbn/ui-shared-deps'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import { IRouter } from '../../http'; import { IRouter } from '../../http';
import { UiPlugins } from '../../plugins'; import { UiPlugins } from '../../plugins';
import { FileHashCache } from './file_hash_cache'; import { FileHashCache } from './file_hash_cache';
@ -43,9 +44,16 @@ export function registerBundleRoutes({
const fileHashCache = new FileHashCache(); const fileHashCache = new FileHashCache();
registerRouteForBundle(router, { registerRouteForBundle(router, {
publicPath: `${serverBasePath}/${buildNum}/bundles/kbn-ui-shared-deps/`, publicPath: `${serverBasePath}/${buildNum}/bundles/kbn-ui-shared-deps-npm/`,
routePath: `/${buildNum}/bundles/kbn-ui-shared-deps/`, routePath: `/${buildNum}/bundles/kbn-ui-shared-deps-npm/`,
bundlesPath: uiSharedDepsDistDir, bundlesPath: UiSharedDepsNpm.distDir,
fileHashCache,
isDist,
});
registerRouteForBundle(router, {
publicPath: `${serverBasePath}/${buildNum}/bundles/kbn-ui-shared-deps-src/`,
routePath: `/${buildNum}/bundles/kbn-ui-shared-deps-src/`,
bundlesPath: UiSharedDepsSrc.distDir,
fileHashCache, fileHashCache,
isDist, isDist,
}); });

View file

@ -78,7 +78,8 @@ export const bootstrapRendererFactory: BootstrapRendererFactory = ({
// src/optimize/bundles_route/bundles_route.ts // src/optimize/bundles_route/bundles_route.ts
const publicPathMap = JSON.stringify({ const publicPathMap = JSON.stringify({
core: `${regularBundlePath}/core/`, core: `${regularBundlePath}/core/`,
'kbn-ui-shared-deps': `${regularBundlePath}/kbn-ui-shared-deps/`, 'kbn-ui-shared-deps-src': `${regularBundlePath}/kbn-ui-shared-deps-src/`,
'kbn-ui-shared-deps-npm': `${regularBundlePath}/kbn-ui-shared-deps-npm/`,
...Object.fromEntries( ...Object.fromEntries(
[...bundlePaths.entries()].map(([pluginId, plugin]) => [pluginId, plugin.publicPath]) [...bundlePaths.entries()].map(([pluginId, plugin]) => [pluginId, plugin.publicPath])
), ),

View file

@ -21,12 +21,14 @@ describe('getJsDependencyPaths', () => {
publicPath: 'plugin2/public-path', publicPath: 'plugin2/public-path',
}); });
expect(getJsDependencyPaths('/regular-bundle-path', bundlePaths)).toEqual([ expect(getJsDependencyPaths('/regular-bundle-path', bundlePaths)).toMatchInlineSnapshot(`
'/regular-bundle-path/kbn-ui-shared-deps/kbn-ui-shared-deps.@elastic.js', Array [
'/regular-bundle-path/kbn-ui-shared-deps/kbn-ui-shared-deps.js', "/regular-bundle-path/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js",
'/regular-bundle-path/core/core.entry.js', "/regular-bundle-path/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.js",
'plugin1/bundle-path.js', "/regular-bundle-path/core/core.entry.js",
'plugin2/bundle-path.js', "plugin1/bundle-path.js",
]); "plugin2/bundle-path.js",
]
`);
}); });
}); });

View file

@ -6,7 +6,8 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import * as UiSharedDeps from '@kbn/ui-shared-deps'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import type { PluginInfo } from './get_plugin_bundle_paths'; import type { PluginInfo } from './get_plugin_bundle_paths';
export const getJsDependencyPaths = ( export const getJsDependencyPaths = (
@ -14,10 +15,8 @@ export const getJsDependencyPaths = (
bundlePaths: Map<string, PluginInfo> bundlePaths: Map<string, PluginInfo>
) => { ) => {
return [ return [
...UiSharedDeps.jsDepFilenames.map( `${regularBundlePath}/kbn-ui-shared-deps-npm/${UiSharedDepsNpm.dllFilename}`,
(filename) => `${regularBundlePath}/kbn-ui-shared-deps/${filename}` `${regularBundlePath}/kbn-ui-shared-deps-src/${UiSharedDepsSrc.jsFilename}`,
),
`${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.jsFilename}`,
`${regularBundlePath}/core/core.entry.js`, `${regularBundlePath}/core/core.entry.js`,
...[...bundlePaths.values()].map((plugin) => plugin.bundlePath), ...[...bundlePaths.values()].map((plugin) => plugin.bundlePath),
]; ];

View file

@ -8,7 +8,7 @@
/** /**
* Computes the themeTag that will be used on the client-side as `__kbnThemeTag__` * Computes the themeTag that will be used on the client-side as `__kbnThemeTag__`
* @see `packages/kbn-ui-shared-deps/theme.ts` * @see `packages/kbn-ui-shared-deps-src/theme.ts`
*/ */
export const getThemeTag = ({ export const getThemeTag = ({
themeVersion, themeVersion,

View file

@ -21,8 +21,8 @@ describe('getStylesheetPaths', () => {
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ Array [
"/base-path/9000/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css", "/base-path/9000/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v7.dark.css",
"/base-path/9000/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v7.dark.css", "/base-path/9000/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css",
"/base-path/node_modules/@kbn/ui-framework/dist/kui_dark.css", "/base-path/node_modules/@kbn/ui-framework/dist/kui_dark.css",
"/base-path/ui/legacy_dark_theme.css", "/base-path/ui/legacy_dark_theme.css",
] ]
@ -40,8 +40,8 @@ describe('getStylesheetPaths', () => {
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ Array [
"/base-path/17/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css", "/base-path/17/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v8.dark.css",
"/base-path/17/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v8.dark.css", "/base-path/17/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css",
"/base-path/node_modules/@kbn/ui-framework/dist/kui_dark.css", "/base-path/node_modules/@kbn/ui-framework/dist/kui_dark.css",
"/base-path/ui/legacy_dark_theme.css", "/base-path/ui/legacy_dark_theme.css",
] ]
@ -61,8 +61,8 @@ describe('getStylesheetPaths', () => {
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ Array [
"/base-path/42/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css", "/base-path/42/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v7.light.css",
"/base-path/42/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v7.light.css", "/base-path/42/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css",
"/base-path/node_modules/@kbn/ui-framework/dist/kui_light.css", "/base-path/node_modules/@kbn/ui-framework/dist/kui_light.css",
"/base-path/ui/legacy_light_theme.css", "/base-path/ui/legacy_light_theme.css",
] ]
@ -80,8 +80,8 @@ describe('getStylesheetPaths', () => {
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ Array [
"/base-path/69/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css", "/base-path/69/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v8.light.css",
"/base-path/69/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v8.light.css", "/base-path/69/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css",
"/base-path/node_modules/@kbn/ui-framework/dist/kui_light.css", "/base-path/node_modules/@kbn/ui-framework/dist/kui_light.css",
"/base-path/ui/legacy_light_theme.css", "/base-path/ui/legacy_light_theme.css",
] ]

View file

@ -6,7 +6,8 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import * as UiSharedDeps from '@kbn/ui-shared-deps'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import { PublicUiSettingsParams, UserProvidedValues } from '../ui_settings'; import { PublicUiSettingsParams, UserProvidedValues } from '../ui_settings';
export const getSettingValue = <T>( export const getSettingValue = <T>(
@ -34,19 +35,20 @@ export const getStylesheetPaths = ({
}) => { }) => {
const regularBundlePath = `${basePath}/${buildNum}/bundles`; const regularBundlePath = `${basePath}/${buildNum}/bundles`;
return [ return [
`${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.baseCssDistFilename}`,
...(darkMode ...(darkMode
? [ ? [
themeVersion === 'v7' themeVersion === 'v7'
? `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.darkCssDistFilename}` ? `${regularBundlePath}/kbn-ui-shared-deps-npm/${UiSharedDepsNpm.darkCssDistFilename}`
: `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.darkV8CssDistFilename}`, : `${regularBundlePath}/kbn-ui-shared-deps-npm/${UiSharedDepsNpm.darkV8CssDistFilename}`,
`${regularBundlePath}/kbn-ui-shared-deps-src/${UiSharedDepsSrc.cssDistFilename}`,
`${basePath}/node_modules/@kbn/ui-framework/dist/kui_dark.css`, `${basePath}/node_modules/@kbn/ui-framework/dist/kui_dark.css`,
`${basePath}/ui/legacy_dark_theme.css`, `${basePath}/ui/legacy_dark_theme.css`,
] ]
: [ : [
themeVersion === 'v7' themeVersion === 'v7'
? `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.lightCssDistFilename}` ? `${regularBundlePath}/kbn-ui-shared-deps-npm/${UiSharedDepsNpm.lightCssDistFilename}`
: `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.lightV8CssDistFilename}`, : `${regularBundlePath}/kbn-ui-shared-deps-npm/${UiSharedDepsNpm.lightV8CssDistFilename}`,
`${regularBundlePath}/kbn-ui-shared-deps-src/${UiSharedDepsSrc.cssDistFilename}`,
`${basePath}/node_modules/@kbn/ui-framework/dist/kui_light.css`, `${basePath}/node_modules/@kbn/ui-framework/dist/kui_light.css`,
`${basePath}/ui/legacy_light_theme.css`, `${basePath}/ui/legacy_light_theme.css`,
]), ]),

View file

@ -6,10 +6,12 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import Path from 'path';
import { pipeline } from 'stream'; import { pipeline } from 'stream';
import { promisify } from 'util'; import { promisify } from 'util';
import fs from 'fs'; import fs from 'fs';
import gulpBrotli from 'gulp-brotli'; import gulpBrotli from 'gulp-brotli';
// @ts-expect-error // @ts-expect-error
import gulpGzip from 'gulp-gzip'; import gulpGzip from 'gulp-gzip';
@ -17,184 +19,175 @@ import gulpGzip from 'gulp-gzip';
import gulpPostCSS from 'gulp-postcss'; import gulpPostCSS from 'gulp-postcss';
// @ts-expect-error // @ts-expect-error
import gulpTerser from 'gulp-terser'; import gulpTerser from 'gulp-terser';
import { ToolingLog } from '@kbn/dev-utils';
import terser from 'terser'; import terser from 'terser';
import vfs from 'vinyl-fs'; import vfs from 'vinyl-fs';
import globby from 'globby';
import del from 'del';
import { ToolingLog } from '@kbn/dev-utils'; import { Task, write } from '../lib';
import { Task, Build, write, deleteAll } from '../lib';
const EUI_THEME_RE = /\.v\d\.(light|dark)\.css$/;
const ASYNC_CHUNK_RE = /\.chunk\.\d+\.js$/;
const asyncPipeline = promisify(pipeline); const asyncPipeline = promisify(pipeline);
const asyncStat = promisify(fs.stat);
const removePreMinifySourceMaps = async (log: ToolingLog, build: Build) => { const getSize = (paths: string[]) => paths.reduce((acc, path) => acc + fs.statSync(path).size, 0);
log.debug('Remove Pre Minify Sourcemaps');
await deleteAll( async function optimizeAssets(log: ToolingLog, assetDir: string) {
[build.resolvePath('node_modules/@kbn/ui-shared-deps/shared_built_assets', '**', '*.map')], log.info('Creating optimized assets for', assetDir);
log log.indent(4);
); try {
log.debug('Remove Pre Minify Sourcemaps');
await del(['**/*.map'], { cwd: assetDir });
log.debug('Minify CSS');
await asyncPipeline(
vfs.src(['**/*.css'], { cwd: assetDir }),
gulpPostCSS([
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('cssnano')({
preset: ['default', { discardComments: false }],
}),
]),
vfs.dest(assetDir)
);
log.debug('Minify JS');
await asyncPipeline(
vfs.src(['**/*.js'], { cwd: assetDir }),
gulpTerser({ compress: true, mangle: true }, terser.minify),
vfs.dest(assetDir)
);
log.debug('Brotli compress');
await asyncPipeline(
vfs.src(['**/*.{js,css}'], { cwd: assetDir }),
gulpBrotli(),
vfs.dest(assetDir)
);
log.debug('GZip compress');
await asyncPipeline(
vfs.src(['**/*.{js,css}'], { cwd: assetDir }),
gulpGzip(),
vfs.dest(assetDir)
);
} finally {
log.indent(-4);
}
}
type Category = ReturnType<typeof getCategory>;
const getCategory = (relative: string) => {
if (EUI_THEME_RE.test(relative)) {
return 'euiTheme';
}
if (relative.endsWith('.css')) {
return 'css';
}
if (relative.endsWith('.ttf')) {
return 'font';
}
if (ASYNC_CHUNK_RE.test(relative)) {
return 'asyncChunk';
}
if (relative.includes('kbn-ui-shared-deps-npm')) {
return 'npm';
}
if (relative.includes('kbn-ui-shared-deps-src')) {
return 'src';
}
throw new Error(`unable to categorize file [${relative}]`);
}; };
const minifyKbnUiSharedDepsCSS = async (log: ToolingLog, build: Build) => { function categorizeAssets(assetDirs: string[]) {
const buildRoot = build.resolvePath(); const assets = assetDirs.flatMap((assetDir) =>
globby
log.debug('Minify CSS'); .sync(['**/*'], {
cwd: assetDir,
await asyncPipeline( ignore: ['*-manifest.json', '*.gz', '*.br'],
vfs.src(['node_modules/@kbn/ui-shared-deps/shared_built_assets/**/*.css'], { absolute: true,
cwd: buildRoot, })
}), .map((path): { path: string; category: Category } => ({
path,
gulpPostCSS([ category: getCategory(Path.relative(assetDir, path)),
// eslint-disable-next-line @typescript-eslint/no-var-requires }))
require('cssnano')({
preset: [
'default',
{
discardComments: false,
},
],
}),
]),
vfs.dest('node_modules/@kbn/ui-shared-deps/shared_built_assets', { cwd: buildRoot })
);
};
const minifyKbnUiSharedDepsJS = async (log: ToolingLog, build: Build) => {
const buildRoot = build.resolvePath();
log.debug('Minify JS');
await asyncPipeline(
vfs.src(['node_modules/@kbn/ui-shared-deps/shared_built_assets/**/*.js'], {
cwd: buildRoot,
}),
gulpTerser(
{
compress: true,
mangle: true,
},
terser.minify
),
vfs.dest('node_modules/@kbn/ui-shared-deps/shared_built_assets', { cwd: buildRoot })
);
};
const brotliCompressKbnUiSharedDeps = async (log: ToolingLog, build: Build) => {
const buildRoot = build.resolvePath();
log.debug('Brotli compress');
await asyncPipeline(
vfs.src(['node_modules/@kbn/ui-shared-deps/shared_built_assets/**/*.{js,css}'], {
cwd: buildRoot,
}),
gulpBrotli(),
vfs.dest('node_modules/@kbn/ui-shared-deps/shared_built_assets', { cwd: buildRoot })
);
};
const gzipCompressKbnUiSharedDeps = async (log: ToolingLog, build: Build) => {
const buildRoot = build.resolvePath();
log.debug('GZip compress');
await asyncPipeline(
vfs.src(['node_modules/@kbn/ui-shared-deps/shared_built_assets/**/*.{js,css}'], {
cwd: buildRoot,
}),
gulpGzip(),
vfs.dest('node_modules/@kbn/ui-shared-deps/shared_built_assets', { cwd: buildRoot })
);
};
const createKbnUiSharedDepsBundleMetrics = async (log: ToolingLog, build: Build) => {
const bundleMetricsFilePath = build.resolvePath(
'node_modules/@kbn/ui-shared-deps/shared_built_assets',
'metrics.json'
); );
const kbnUISharedDepsJSFileSize = ( const groups = new Map<Category, string[]>();
await asyncStat( const add = (cat: Category, path: string) => {
build.resolvePath( const group = groups.get(cat) ?? [];
'node_modules/@kbn/ui-shared-deps/shared_built_assets', group.push(path);
'kbn-ui-shared-deps.js' groups.set(cat, group);
) };
)
).size;
const kbnUISharedDepsCSSFileSize = for (const { path, category } of assets) {
( if (category === 'euiTheme') {
await asyncStat( // only track v8.light theme
build.resolvePath( if (path.includes('v8.light')) {
'node_modules/@kbn/ui-shared-deps/shared_built_assets', add('css', path);
'kbn-ui-shared-deps.css' }
) continue;
) }
).size +
(
await asyncStat(
build.resolvePath(
'node_modules/@kbn/ui-shared-deps/shared_built_assets',
'kbn-ui-shared-deps.v7.light.css'
)
)
).size;
const kbnUISharedDepsElasticJSFileSize = ( add(category, path);
await asyncStat( }
build.resolvePath(
'node_modules/@kbn/ui-shared-deps/shared_built_assets',
'kbn-ui-shared-deps.@elastic.js'
)
)
).size;
log.debug('Create metrics.json'); return groups;
}
const metrics = [
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-js',
value: kbnUISharedDepsJSFileSize,
},
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-css',
value: kbnUISharedDepsCSSFileSize,
},
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-elastic',
value: kbnUISharedDepsElasticJSFileSize,
},
];
await write(bundleMetricsFilePath, JSON.stringify(metrics, null, 2));
};
const generateKbnUiSharedDepsOptimizedAssets = async (log: ToolingLog, build: Build) => {
log.info('Creating optimized assets for @kbn/ui-shared-deps');
await removePreMinifySourceMaps(log, build);
await minifyKbnUiSharedDepsCSS(log, build);
await minifyKbnUiSharedDepsJS(log, build);
await createKbnUiSharedDepsBundleMetrics(log, build);
await brotliCompressKbnUiSharedDeps(log, build);
await gzipCompressKbnUiSharedDeps(log, build);
};
export const GeneratePackagesOptimizedAssets: Task = { export const GeneratePackagesOptimizedAssets: Task = {
description: 'Generates Optimized Assets for Packages', description: 'Generates Optimized Assets for Packages',
async run(config, log, build) { async run(config, log, build) {
// Create optimized assets for @kbn/ui-shared-deps const npmAssetDir = build.resolvePath(
await generateKbnUiSharedDepsOptimizedAssets(log, build); `node_modules/@kbn/ui-shared-deps-npm/shared_built_assets`
);
const srcAssetDir = build.resolvePath(
`node_modules/@kbn/ui-shared-deps-src/shared_built_assets`
);
const assetDirs = [npmAssetDir, srcAssetDir];
// process assets in each ui-shared-deps package
for (const assetDir of assetDirs) {
await optimizeAssets(log, assetDir);
}
// analyze assets to produce metrics.json file
const groups = categorizeAssets(assetDirs);
log.verbose('categorized assets', groups);
const metrics = [
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-npmDll',
value: getSize(groups.get('npm') ?? []),
},
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-srcJs',
value: getSize(groups.get('src') ?? []),
},
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-css',
value: getSize(groups.get('css') ?? []),
},
{
group: 'page load bundle size',
id: 'kbnUiSharedDeps-fonts',
value: getSize(groups.get('font') ?? []),
},
];
log.verbose('metrics:', metrics);
// write unified metrics to the @kbn/ui-shared-deps-src asset dir
log.debug('Create metrics.json');
await write(Path.resolve(srcAssetDir, 'metrics.json'), JSON.stringify(metrics, null, 2));
}, },
}; };

View file

@ -13,7 +13,7 @@ import useList from 'react-use/lib/useList';
import useUpdateEffect from 'react-use/lib/useUpdateEffect'; import useUpdateEffect from 'react-use/lib/useUpdateEffect';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
export interface SingleCharsFieldProps { export interface SingleCharsFieldProps {
defaultValue: string; defaultValue: string;

View file

@ -10,7 +10,7 @@ import type { DecoratorFn } from '@storybook/react';
import React from 'react'; import React from 'react';
import * as styledComponents from 'styled-components'; import * as styledComponents from 'styled-components';
import { ThemedStyledComponentsModule, ThemeProvider, ThemeProviderProps } from 'styled-components'; import { ThemedStyledComponentsModule, ThemeProvider, ThemeProviderProps } from 'styled-components';
import { euiThemeVars, euiLightVars, euiDarkVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars, euiLightVars, euiDarkVars } from '@kbn/ui-shared-deps-src/theme';
export interface EuiTheme { export interface EuiTheme {
eui: typeof euiThemeVars; eui: typeof euiThemeVars;

View file

@ -7,7 +7,7 @@
*/ */
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import { euiThemeVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { VegaParser } from './vega_parser'; import { VegaParser } from './vega_parser';
import { bypassExternalUrlCheck } from '../vega_view/vega_base_view'; import { bypassExternalUrlCheck } from '../vega_view/vega_base_view';

View file

@ -11,7 +11,7 @@ import schemaParser from 'vega-schema-url-parser';
import versionCompare from 'compare-versions'; import versionCompare from 'compare-versions';
import hjson from 'hjson'; import hjson from 'hjson';
import { euiPaletteColorBlind } from '@elastic/eui'; import { euiPaletteColorBlind } from '@elastic/eui';
import { euiThemeVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { logger, Warn, None, version as vegaVersion } from 'vega'; import { logger, Warn, None, version as vegaVersion } from 'vega';

View file

@ -26,28 +26,28 @@ export default function ({ getService }) {
supertest supertest
// We use the kbn-ui-shared-deps for these tests since they are always built with br compressed outputs, // We use the kbn-ui-shared-deps for these tests since they are always built with br compressed outputs,
// even in dev. Bundles built by @kbn/optimizer are only built with br compression in dist mode. // even in dev. Bundles built by @kbn/optimizer are only built with br compression in dist mode.
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) .get(`/${buildNum}/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js`)
.set('Accept-Encoding', 'gzip') .set('Accept-Encoding', 'gzip')
.expect(200) .expect(200)
.expect('Content-Encoding', 'gzip')); .expect('Content-Encoding', 'gzip'));
it('returns br files when client only supports br', () => it('returns br files when client only supports br', () =>
supertest supertest
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) .get(`/${buildNum}/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js`)
.set('Accept-Encoding', 'br') .set('Accept-Encoding', 'br')
.expect(200) .expect(200)
.expect('Content-Encoding', 'br')); .expect('Content-Encoding', 'br'));
it('returns br files when client only supports gzip and br', () => it('returns br files when client only supports gzip and br', () =>
supertest supertest
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) .get(`/${buildNum}/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js`)
.set('Accept-Encoding', 'gzip, br') .set('Accept-Encoding', 'gzip, br')
.expect(200) .expect(200)
.expect('Content-Encoding', 'br')); .expect('Content-Encoding', 'br'));
it('returns gzip files when client prefers gzip', () => it('returns gzip files when client prefers gzip', () =>
supertest supertest
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) .get(`/${buildNum}/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js`)
.set('Accept-Encoding', 'gzip;q=1.0, br;q=0.5') .set('Accept-Encoding', 'gzip;q=1.0, br;q=0.5')
.expect(200) .expect(200)
.expect('Content-Encoding', 'gzip')); .expect('Content-Encoding', 'gzip'));

View file

@ -21,7 +21,7 @@ if [[ -z "$CODE_COVERAGE" ]] ; then
echo " -> shipping metrics from build to ci-stats" echo " -> shipping metrics from build to ci-stats"
node scripts/ship_ci_stats \ node scripts/ship_ci_stats \
--metrics target/optimizer_bundle_metrics.json \ --metrics target/optimizer_bundle_metrics.json \
--metrics build/kibana/node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json --metrics build/kibana/node_modules/@kbn/ui-shared-deps-src/shared_built_assets/metrics.json
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
installDir="$KIBANA_DIR/install/kibana" installDir="$KIBANA_DIR/install/kibana"

View file

@ -10,7 +10,7 @@ node scripts/build --debug
echo " -> shipping metrics from build to ci-stats" echo " -> shipping metrics from build to ci-stats"
node scripts/ship_ci_stats \ node scripts/ship_ci_stats \
--metrics target/optimizer_bundle_metrics.json \ --metrics target/optimizer_bundle_metrics.json \
--metrics build/kibana/node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json --metrics build/kibana/node_modules/@kbn/ui-shared-deps-src/shared_built_assets/metrics.json
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
installDir="$KIBANA_DIR/install/kibana" installDir="$KIBANA_DIR/install/kibana"

View file

@ -9,6 +9,6 @@ import 'core-js/stable';
import 'regenerator-runtime/runtime'; import 'regenerator-runtime/runtime';
import 'whatwg-fetch'; import 'whatwg-fetch';
import 'jquery'; import 'jquery';
import '@kbn/ui-shared-deps/flot_charts'; import '@kbn/ui-shared-deps-src/flot_charts';
export * from './shareable'; export * from './shareable';

View file

@ -7,7 +7,7 @@
import chroma from 'chroma-js'; import chroma from 'chroma-js';
import { PaletteOutput, PaletteRegistry } from 'src/plugins/charts/public'; import { PaletteOutput, PaletteRegistry } from 'src/plugins/charts/public';
import { euiLightVars, euiDarkVars } from '@kbn/ui-shared-deps/theme'; import { euiLightVars, euiDarkVars } from '@kbn/ui-shared-deps-src/theme';
import { isColorDark } from '@elastic/eui'; import { isColorDark } from '@elastic/eui';
import type { Datatable } from 'src/plugins/expressions/public'; import type { Datatable } from 'src/plugins/expressions/public';
import { import {

View file

@ -5,7 +5,7 @@
* 2.0. * 2.0.
*/ */
import { euiThemeVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { INITIAL_LOCATION, MAX_ZOOM, MIN_ZOOM } from '../../../common/constants'; import { INITIAL_LOCATION, MAX_ZOOM, MIN_ZOOM } from '../../../common/constants';
import { MapSettings } from './types'; import { MapSettings } from './types';

View file

@ -22,7 +22,7 @@ import type { FunctionComponent, ReactElement } from 'react';
import React from 'react'; import React from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
export interface TokenFieldProps extends Omit<EuiFieldTextProps, 'append'> { export interface TokenFieldProps extends Omit<EuiFieldTextProps, 'append'> {
value: string; value: string;

View file

@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`PromptPage renders as expected with additional scripts 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><script src=\\"/mock-basepath/some/script1.js\\"></script><script src=\\"/mock-basepath/some/script2.js\\"></script><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">Some Title</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><div>Some Body</div></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#1</span></div><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#2</span></div></div></div></div></div></div></body></html>"`; exports[`PromptPage renders as expected with additional scripts 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><script src=\\"/mock-basepath/some/script1.js\\"></script><script src=\\"/mock-basepath/some/script2.js\\"></script><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">Some Title</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><div>Some Body</div></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#1</span></div><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#2</span></div></div></div></div></div></div></body></html>"`;
exports[`PromptPage renders as expected without additional scripts 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">Some Title</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><div>Some Body</div></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#1</span></div><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#2</span></div></div></div></div></div></div></body></html>"`; exports[`PromptPage renders as expected without additional scripts 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">Some Title</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><div>Some Body</div></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#1</span></div><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><span>Action#2</span></div></div></div></div></div></div></body></html>"`;

View file

@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UnauthenticatedPage renders as expected 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">We couldn&#x27;t log you in</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><p>We hit an authentication error. Please check your credentials and try again. If you still can&#x27;t log in, contact your system administrator.</p></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><a class=\\"euiButton euiButton--primary euiButton--fill\\" href=\\"/some/url?some-query=some-value#some-hash\\" rel=\\"noreferrer\\" data-test-subj=\\"logInButton\\"><span class=\\"euiButtonContent euiButton__content\\"><span class=\\"euiButton__text\\">Log in</span></span></a></div></div></div></div></div></div></body></html>"`; exports[`UnauthenticatedPage renders as expected 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">We couldn&#x27;t log you in</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><p>We hit an authentication error. Please check your credentials and try again. If you still can&#x27;t log in, contact your system administrator.</p></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><a class=\\"euiButton euiButton--primary euiButton--fill\\" href=\\"/some/url?some-query=some-value#some-hash\\" rel=\\"noreferrer\\" data-test-subj=\\"logInButton\\"><span class=\\"euiButtonContent euiButton__content\\"><span class=\\"euiButton__text\\">Log in</span></span></a></div></div></div></div></div></div></body></html>"`;

View file

@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ResetSessionPage renders as expected 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><script src=\\"/mock-basepath/internal/security/reset_session_page.js\\"></script><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">You do not have permission to access the requested page</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><p>Either go back to the previous page or log in as a different user.</p></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><a class=\\"euiButton euiButton--primary euiButton--fill\\" href=\\"/path/to/logout\\" rel=\\"noreferrer\\" data-test-subj=\\"ResetSessionButton\\"><span class=\\"euiButtonContent euiButton__content\\"><span class=\\"euiButton__text\\">Log in as different user</span></span></a></div><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><button class=\\"euiButtonEmpty euiButtonEmpty--primary\\" type=\\"button\\" id=\\"goBackButton\\"><span class=\\"euiButtonContent euiButtonEmpty__content\\"><span class=\\"euiButtonEmpty__text\\">Go back</span></span></button></div></div></div></div></div></div></body></html>"`; exports[`ResetSessionPage renders as expected 1`] = `"<html lang=\\"en\\"><head><title>Elastic</title><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-src/kbn-ui-shared-deps-src.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/100500/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.v7.light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/node_modules/@kbn/ui-framework/dist/kui_light.css\\" rel=\\"stylesheet\\"/><link href=\\"/mock-server-basepath/ui/legacy_light_theme.css\\" rel=\\"stylesheet\\"/>MockedFonts<link rel=\\"alternate icon\\" type=\\"image/png\\" href=\\"/mock-server-basepath/ui/favicons/favicon.png\\"/><link rel=\\"icon\\" type=\\"image/svg+xml\\" href=\\"/mock-server-basepath/ui/favicons/favicon.svg\\"/><script src=\\"/mock-basepath/internal/security/reset_session_page.js\\"></script><meta name=\\"theme-color\\" content=\\"#ffffff\\"/><meta name=\\"color-scheme\\" content=\\"light dark\\"/></head><body><div class=\\"euiPage euiPage--grow\\" style=\\"min-height:100vh\\" data-test-subj=\\"promptPage\\"><div class=\\"euiPageBody euiPageBody--borderRadiusNone\\"><div class=\\"euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter\\" role=\\"main\\"><div class=\\"euiEmptyPrompt\\"><span data-euiicon-type=\\"alert\\" color=\\"danger\\"></span><div class=\\"euiSpacer euiSpacer--m\\"></div><h2 class=\\"euiTitle euiTitle--medium\\">You do not have permission to access the requested page</h2><span class=\\"euiTextColor euiTextColor--subdued\\"><div class=\\"euiSpacer euiSpacer--m\\"></div><div class=\\"euiText euiText--medium\\"><p>Either go back to the previous page or log in as a different user.</p></div></span><div class=\\"euiSpacer euiSpacer--l\\"></div><div class=\\"euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentCenter euiFlexGroup--directionColumn euiFlexGroup--responsive\\"><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><a class=\\"euiButton euiButton--primary euiButton--fill\\" href=\\"/path/to/logout\\" rel=\\"noreferrer\\" data-test-subj=\\"ResetSessionButton\\"><span class=\\"euiButtonContent euiButton__content\\"><span class=\\"euiButton__text\\">Log in as different user</span></span></a></div><div class=\\"euiFlexItem euiFlexItem--flexGrowZero\\"><button class=\\"euiButtonEmpty euiButtonEmpty--primary\\" type=\\"button\\" id=\\"goBackButton\\"><span class=\\"euiButtonContent euiButtonEmpty__content\\"><span class=\\"euiButtonEmpty__text\\">Go back</span></span></button></div></div></div></div></div></div></body></html>"`;

View file

@ -18,7 +18,8 @@ import React from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react'; import { I18nProvider } from '@kbn/i18n/react';
import * as UiSharedDeps from '@kbn/ui-shared-deps'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
import UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import type { IBasePath } from 'src/core/server'; import type { IBasePath } from 'src/core/server';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths // eslint-disable-next-line @kbn/eslint/no-restricted-paths
@ -51,8 +52,8 @@ export function PromptPage({
const uiPublicURL = `${basePath.serverBasePath}/ui`; const uiPublicURL = `${basePath.serverBasePath}/ui`;
const regularBundlePath = `${basePath.serverBasePath}/${buildNumber}/bundles`; const regularBundlePath = `${basePath.serverBasePath}/${buildNumber}/bundles`;
const styleSheetPaths = [ const styleSheetPaths = [
`${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.baseCssDistFilename}`, `${regularBundlePath}/kbn-ui-shared-deps-src/${UiSharedDepsSrc.cssDistFilename}`,
`${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.lightCssDistFilename}`, `${regularBundlePath}/kbn-ui-shared-deps-npm/${UiSharedDepsNpm.lightCssDistFilename}`,
`${basePath.serverBasePath}/node_modules/@kbn/ui-framework/dist/kui_light.css`, `${basePath.serverBasePath}/node_modules/@kbn/ui-framework/dist/kui_light.css`,
`${basePath.serverBasePath}/ui/legacy_light_theme.css`, `${basePath.serverBasePath}/ui/legacy_light_theme.css`,
]; ];

View file

@ -17,7 +17,7 @@ import {
addBuildingBlockStyle, addBuildingBlockStyle,
} from './helpers'; } from './helpers';
import { euiThemeVars } from '@kbn/ui-shared-deps/theme'; import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { mockDnsEvent } from '../../../mock'; import { mockDnsEvent } from '../../../mock';
describe('helpers', () => { describe('helpers', () => {

View file

@ -2925,7 +2925,11 @@
version "0.0.0" version "0.0.0"
uid "" uid ""
"@kbn/ui-shared-deps@link:bazel-bin/packages/kbn-ui-shared-deps": "@kbn/ui-shared-deps-npm@link:bazel-bin/packages/kbn-ui-shared-deps-npm":
version "0.0.0"
uid ""
"@kbn/ui-shared-deps-src@link:bazel-bin/packages/kbn-ui-shared-deps-src":
version "0.0.0" version "0.0.0"
uid "" uid ""