mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
chore(NA): moving @kbn/ui-shared-deps into bazel (#101669)
* chore(NA): moving @kbn/io-ts-utils into bazel
* chore(NA): moving @kbn/ui-shared-deps into bazel
* chore(NA): compelte working build for @kbn/ui-shared-deps
* chore(NA): solve eslint problems
* chore(NA): solve typechecking
* chore(NA): debugger changes
* chore(NA): update optimizer basic integration tests
* chore(NA): ship kbn/ui-shared-deps metrics.json from new location at shared_built_assets
* chore(NA): use correct ui-shared-deps metrics file location
* chore(NA): remove webpack bazel config
* chore(NA): implement improvements on webpack config
* chore(NA): remove extra comment
* chore(NA): try esbuild-loader minimizer
* Revert "chore(NA): try esbuild-loader minimizer"
This reverts commit bffc49aaae
.
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
853de830c2
commit
cee33b004c
50 changed files with 289 additions and 244 deletions
|
@ -6,7 +6,7 @@ if [[ ! "${DISABLE_CI_STATS_SHIPPING:-}" ]]; then
|
|||
echo "--- Ship Kibana Distribution Metrics to CI Stats"
|
||||
node scripts/ship_ci_stats \
|
||||
--metrics target/optimizer_bundle_metrics.json \
|
||||
--metrics packages/kbn-ui-shared-deps/target/metrics.json
|
||||
--metrics node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json
|
||||
fi
|
||||
|
||||
echo "--- Upload Build Artifacts"
|
||||
|
|
|
@ -37,7 +37,7 @@ snapshots.js
|
|||
/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/
|
||||
/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/
|
||||
/packages/kbn-ui-framework/dist
|
||||
/packages/kbn-ui-shared-deps/flot_charts
|
||||
/packages/kbn-ui-shared-deps/src/flot_charts
|
||||
/packages/kbn-monaco/src/painless/antlr
|
||||
|
||||
# Bazel
|
||||
|
|
|
@ -1471,7 +1471,7 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
{
|
||||
files: ['packages/kbn-ui-shared-deps/flot_charts/**/*.js'],
|
||||
files: ['packages/kbn-ui-shared-deps/src/flot_charts/**/*.js'],
|
||||
env: {
|
||||
jquery: true,
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"uiActionsExamples": "examples/ui_action_examples",
|
||||
"share": "src/plugins/share",
|
||||
"home": "src/plugins/home",
|
||||
"flot": "packages/kbn-ui-shared-deps/flot_charts",
|
||||
"flot": "packages/kbn-ui-shared-deps/src/flot_charts",
|
||||
"charts": "src/plugins/charts",
|
||||
"esUi": "src/plugins/es_ui_shared",
|
||||
"devTools": "src/plugins/dev_tools",
|
||||
|
|
|
@ -102,5 +102,6 @@ yarn kbn watch-bazel
|
|||
- @kbn/std
|
||||
- @kbn/telemetry-utils
|
||||
- @kbn/tinymath
|
||||
- @kbn/ui-shared-deps
|
||||
- @kbn/utility-types
|
||||
- @kbn/utils
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
"@kbn/std": "link:bazel-bin/packages/kbn-std",
|
||||
"@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath",
|
||||
"@kbn/ui-framework": "link:packages/kbn-ui-framework",
|
||||
"@kbn/ui-shared-deps": "link:packages/kbn-ui-shared-deps",
|
||||
"@kbn/ui-shared-deps": "link:bazel-bin/packages/kbn-ui-shared-deps",
|
||||
"@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types",
|
||||
"@kbn/common-utils": "link:bazel-bin/packages/kbn-common-utils",
|
||||
"@kbn/utils": "link:bazel-bin/packages/kbn-utils",
|
||||
|
@ -291,6 +291,7 @@
|
|||
"mapbox-gl-draw-rectangle-mode": "1.0.4",
|
||||
"markdown-it": "^10.0.0",
|
||||
"md5": "^2.1.0",
|
||||
"mdast-util-to-hast": "10.0.1",
|
||||
"memoize-one": "^5.0.0",
|
||||
"mime": "^2.4.4",
|
||||
"mime-types": "^2.1.27",
|
||||
|
|
|
@ -46,6 +46,7 @@ filegroup(
|
|||
"//packages/kbn-std:build",
|
||||
"//packages/kbn-telemetry-tools:build",
|
||||
"//packages/kbn-tinymath:build",
|
||||
"//packages/kbn-ui-shared-deps:build",
|
||||
"//packages/kbn-utility-types:build",
|
||||
"//packages/kbn-utils:build",
|
||||
],
|
||||
|
|
|
@ -9,8 +9,5 @@
|
|||
"build": "../../node_modules/.bin/tsc",
|
||||
"kbn:bootstrap": "yarn build",
|
||||
"kbn:watch": "yarn build --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kbn/ui-shared-deps": "link:../kbn-ui-shared-deps"
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ import cpy from 'cpy';
|
|||
import del from 'del';
|
||||
import { tap, filter } from 'rxjs/operators';
|
||||
import { REPO_ROOT } from '@kbn/utils';
|
||||
import { ToolingLog } from '@kbn/dev-utils';
|
||||
import { ToolingLog, createReplaceSerializer } from '@kbn/dev-utils';
|
||||
import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '../index';
|
||||
|
||||
import { allValuesFrom } from '../common';
|
||||
|
@ -29,6 +29,8 @@ expect.addSnapshotSerializer({
|
|||
test: (value: any) => typeof value === 'string' && value.includes(REPO_ROOT),
|
||||
});
|
||||
|
||||
expect.addSnapshotSerializer(createReplaceSerializer(/\w+-fastbuild/, '<platform>-fastbuild'));
|
||||
|
||||
const log = new ToolingLog({
|
||||
level: 'error',
|
||||
writeTo: {
|
||||
|
@ -130,13 +132,13 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
expect(foo.cache.getModuleCount()).toBe(6);
|
||||
expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/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/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/index.ts,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts,
|
||||
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
|
||||
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
|
||||
]
|
||||
`);
|
||||
|
||||
|
@ -153,6 +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/css-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/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/public/index.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts,
|
||||
|
@ -162,7 +165,6 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v8dark.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v8light.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
|
||||
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
|
||||
]
|
||||
`);
|
||||
|
||||
|
@ -173,10 +175,10 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
|
||||
expect(baz.cache.getReferencedFiles()).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/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/public/index.ts,
|
||||
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
|
||||
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
|
|
@ -54,8 +54,19 @@ export class PopulateBundleCachePlugin {
|
|||
for (const module of compilation.modules) {
|
||||
if (isNormalModule(module)) {
|
||||
moduleCount += 1;
|
||||
const path = getModulePath(module);
|
||||
const parsedPath = parseFilePath(path);
|
||||
let path = getModulePath(module);
|
||||
let parsedPath = parseFilePath(path);
|
||||
|
||||
if (parsedPath.dirs.includes('bazel-out')) {
|
||||
const index = parsedPath.dirs.indexOf('bazel-out');
|
||||
path = Path.join(
|
||||
workerConfig.repoRoot,
|
||||
'bazel-out',
|
||||
...parsedPath.dirs.slice(index + 1),
|
||||
parsedPath.filename ?? ''
|
||||
);
|
||||
parsedPath = parseFilePath(path);
|
||||
}
|
||||
|
||||
if (!parsedPath.dirs.includes('node_modules')) {
|
||||
referencedFiles.add(path);
|
||||
|
|
145
packages/kbn-ui-shared-deps/BUILD.bazel
Normal file
145
packages/kbn-ui-shared-deps/BUILD.bazel
Normal file
|
@ -0,0 +1,145 @@
|
|||
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")
|
||||
|
||||
PKG_BASE_NAME = "kbn-ui-shared-deps"
|
||||
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps"
|
||||
|
||||
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"
|
||||
]
|
||||
|
||||
SRC_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-utils",
|
||||
"@npm//@elastic/charts",
|
||||
"@npm//@elastic/eui",
|
||||
"@npm//@elastic/numeral",
|
||||
"@npm//abortcontroller-polyfill",
|
||||
"@npm//angular",
|
||||
"@npm//babel-loader",
|
||||
"@npm//compression-webpack-plugin",
|
||||
"@npm//core-js",
|
||||
"@npm//css-minimizer-webpack-plugin",
|
||||
"@npm//css-loader",
|
||||
"@npm//fflate",
|
||||
"@npm//jquery",
|
||||
"@npm//loader-utils",
|
||||
# TODO: we can remove this once EUI patches the dependencies
|
||||
"@npm//mdast-util-to-hast",
|
||||
"@npm//mini-css-extract-plugin",
|
||||
"@npm//moment",
|
||||
"@npm//moment-timezone",
|
||||
"@npm//raw-loader",
|
||||
"@npm//react",
|
||||
"@npm//react-dom",
|
||||
"@npm//react-intl",
|
||||
"@npm//react-is",
|
||||
"@npm//react-router",
|
||||
"@npm//react-router-dom",
|
||||
"@npm//regenerator-runtime",
|
||||
"@npm//resize-observer-polyfill",
|
||||
"@npm//rison-node",
|
||||
"@npm//rxjs",
|
||||
"@npm//styled-components",
|
||||
"@npm//symbol-observable",
|
||||
"@npm//terser-webpack-plugin",
|
||||
"@npm//url-loader",
|
||||
"@npm//val-loader",
|
||||
"@npm//whatwg-fetch"
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
]
|
||||
|
||||
DEPS = SRC_DEPS + TYPES_DEPS
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = DEPS,
|
||||
allow_js = True,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
incremental = True,
|
||||
out_dir = "target",
|
||||
source_map = True,
|
||||
root_dir = "src",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
webpack(
|
||||
name = "shared_built_assets",
|
||||
data = 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 = DEPS + [":tsc", ":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"],
|
||||
)
|
4
packages/kbn-ui-shared-deps/flot_charts/package.json
Normal file
4
packages/kbn-ui-shared-deps/flot_charts/package.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"main": "../target/flot_charts/index.js",
|
||||
"types": "../target/flot_charts/index.d.ts"
|
||||
}
|
59
packages/kbn-ui-shared-deps/index.d.ts
vendored
59
packages/kbn-ui-shared-deps/index.d.ts
vendored
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Absolute path to the distributable directory
|
||||
*/
|
||||
export const distDir: string;
|
||||
|
||||
/**
|
||||
* Filename of the main bundle file in the distributable directory
|
||||
*/
|
||||
export const jsFilename: string;
|
||||
|
||||
/**
|
||||
* Filename of files that must be loaded before the jsFilename
|
||||
*/
|
||||
export const jsDepFilenames: string[];
|
||||
|
||||
/**
|
||||
* Filename of the unthemed css file in the distributable directory
|
||||
*/
|
||||
export const baseCssDistFilename: string;
|
||||
|
||||
/**
|
||||
* Filename of the dark-theme css file in the distributable directory
|
||||
*/
|
||||
export const darkCssDistFilename: string;
|
||||
|
||||
/**
|
||||
* Filename of the dark-theme css file in the distributable directory
|
||||
*/
|
||||
export const darkV8CssDistFilename: string;
|
||||
|
||||
/**
|
||||
* Filename of the light-theme css file in the distributable directory
|
||||
*/
|
||||
export const lightCssDistFilename: string;
|
||||
|
||||
/**
|
||||
* Filename of the light-theme css file in the distributable directory
|
||||
*/
|
||||
export const lightV8CssDistFilename: string;
|
||||
|
||||
/**
|
||||
* Externals mapping inteded to be used in a webpack config
|
||||
*/
|
||||
export const externals: {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Webpack loader for configuring the public path lookup from `window.__kbnPublicPath__`.
|
||||
*/
|
||||
export const publicPathLoader: string;
|
|
@ -3,9 +3,6 @@
|
|||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0",
|
||||
"scripts": {
|
||||
"build": "node scripts/build",
|
||||
"kbn:bootstrap": "node scripts/build --dev",
|
||||
"kbn:watch": "node scripts/build --dev --watch"
|
||||
}
|
||||
"main": "target/index.js",
|
||||
"types": "target/index.d.ts"
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* 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 { run, createFailError } = require('@kbn/dev-utils');
|
||||
const webpack = require('webpack');
|
||||
const Stats = require('webpack/lib/Stats');
|
||||
const del = require('del');
|
||||
|
||||
const { getWebpackConfig } = require('../webpack.config');
|
||||
|
||||
const DIST_DIR = Path.resolve(__dirname, '../target');
|
||||
|
||||
run(
|
||||
async ({ log, flags }) => {
|
||||
log.info('cleaning previous build output');
|
||||
await del(DIST_DIR);
|
||||
|
||||
const compiler = webpack(
|
||||
getWebpackConfig({
|
||||
dev: flags.dev,
|
||||
})
|
||||
);
|
||||
|
||||
/** @param {webpack.Stats} stats */
|
||||
const onCompilationComplete = async (stats) => {
|
||||
const took = Math.round((stats.endTime - stats.startTime) / 1000);
|
||||
|
||||
if (!stats.hasErrors() && !stats.hasWarnings()) {
|
||||
log.success(`webpack completed in about ${took} seconds`);
|
||||
return;
|
||||
}
|
||||
|
||||
throw createFailError(
|
||||
`webpack failure in about ${took} seconds\n${stats.toString({
|
||||
colors: true,
|
||||
...Stats.presetToOptions('minimal'),
|
||||
})}`
|
||||
);
|
||||
};
|
||||
|
||||
if (flags.watch) {
|
||||
compiler.hooks.done.tap('report on stats', (stats) => {
|
||||
onCompilationComplete(stats).catch((error) => {
|
||||
log.error(error.message);
|
||||
});
|
||||
});
|
||||
|
||||
compiler.hooks.watchRun.tap('report on start', () => {
|
||||
if (process.stdout.isTTY) {
|
||||
process.stdout.cursorTo(0, 0);
|
||||
process.stdout.clearScreenDown();
|
||||
}
|
||||
|
||||
log.info('Running webpack compilation...');
|
||||
});
|
||||
|
||||
compiler.watch({}, (error) => {
|
||||
if (error) {
|
||||
log.error('Fatal webpack error');
|
||||
log.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
log.info('running webpack');
|
||||
await onCompilationComplete(
|
||||
await new Promise((resolve, reject) => {
|
||||
compiler.run((error, stats) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(stats);
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
},
|
||||
{
|
||||
description: 'build @kbn/ui-shared-deps',
|
||||
flags: {
|
||||
boolean: ['watch', 'dev'],
|
||||
help: `
|
||||
--watch Run in watch mode
|
||||
--dev Build development friendly version
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
|
@ -8,14 +8,49 @@
|
|||
|
||||
const Path = require('path');
|
||||
|
||||
exports.distDir = Path.resolve(__dirname, 'target');
|
||||
/**
|
||||
* Absolute path to the distributable directory
|
||||
*/
|
||||
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
|
||||
*/
|
||||
exports.jsFilename = 'kbn-ui-shared-deps.js';
|
||||
|
||||
/**
|
||||
* Filename of the unthemed css file in the distributable directory
|
||||
*/
|
||||
exports.baseCssDistFilename = 'kbn-ui-shared-deps.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
|
||||
*/
|
||||
exports.externals = {
|
||||
// stateful deps
|
||||
angular: '__kbnSharedDeps__.Angular',
|
||||
|
@ -63,4 +98,8 @@ exports.externals = {
|
|||
'@elastic/safer-lodash-set': '__kbnSharedDeps__.SaferLodashSet',
|
||||
'rison-node': '__kbnSharedDeps__.RisonNode',
|
||||
};
|
||||
|
||||
/**
|
||||
* Webpack loader for configuring the public path lookup from `window.__kbnPublicPath__`.
|
||||
*/
|
||||
exports.publicPathLoader = require.resolve('./public_path_loader');
|
4
packages/kbn-ui-shared-deps/theme/package.json
Normal file
4
packages/kbn-ui-shared-deps/theme/package.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"main": "../target/theme.js",
|
||||
"types": "../target/theme.d.ts"
|
||||
}
|
|
@ -1,10 +1,20 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-ui-shared-deps"
|
||||
"allowJs": true,
|
||||
"incremental": true,
|
||||
"outDir": "./target",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"rootDir": "src",
|
||||
"sourceMap": true,
|
||||
"sourceRoot": "../../../../packages/kbn-ui-shared-deps/src",
|
||||
"types": [
|
||||
"node",
|
||||
"resize-observer-polyfill"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"index.d.ts",
|
||||
"theme.ts"
|
||||
"src/**/*",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
const Path = require('path');
|
||||
const Os = require('os');
|
||||
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
||||
|
@ -14,24 +15,23 @@ const TerserPlugin = require('terser-webpack-plugin');
|
|||
|
||||
const CompressionPlugin = require('compression-webpack-plugin');
|
||||
const { REPO_ROOT } = require('@kbn/utils');
|
||||
const webpack = require('webpack');
|
||||
const { RawSource } = require('webpack-sources');
|
||||
|
||||
const UiSharedDeps = require('./index');
|
||||
const UiSharedDeps = require('./src/index');
|
||||
|
||||
const MOMENT_SRC = require.resolve('moment/min/moment-with-locales.js');
|
||||
|
||||
exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
||||
mode: dev ? 'development' : 'production',
|
||||
module.exports = {
|
||||
mode: 'production',
|
||||
entry: {
|
||||
'kbn-ui-shared-deps': './entry.js',
|
||||
'kbn-ui-shared-deps': './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,
|
||||
devtool: dev ? '#cheap-source-map' : false,
|
||||
devtool: 'cheap-source-map',
|
||||
output: {
|
||||
path: UiSharedDeps.distDir,
|
||||
filename: '[name].js',
|
||||
|
@ -39,13 +39,14 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
|||
devtoolModuleFilenameTemplate: (info) =>
|
||||
`kbn-ui-shared-deps/${Path.relative(REPO_ROOT, info.absoluteResourcePath)}`,
|
||||
library: '__kbnSharedDeps__',
|
||||
futureEmitAssets: true,
|
||||
},
|
||||
|
||||
module: {
|
||||
noParse: [MOMENT_SRC],
|
||||
rules: [
|
||||
{
|
||||
include: [require.resolve('./entry.js')],
|
||||
include: [require.resolve('./src/entry.js')],
|
||||
use: [
|
||||
{
|
||||
loader: UiSharedDeps.publicPathLoader,
|
||||
|
@ -60,7 +61,7 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
|||
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
||||
},
|
||||
{
|
||||
include: [require.resolve('./theme.ts')],
|
||||
include: [require.resolve('./src/theme.ts')],
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
|
@ -71,7 +72,7 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
|||
],
|
||||
},
|
||||
{
|
||||
test: !dev ? /[\\\/]@elastic[\\\/]eui[\\\/].*\.js$/ : () => false,
|
||||
test: /[\\\/]@elastic[\\\/]eui[\\\/].*\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
|
@ -110,6 +111,7 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
|||
optimization: {
|
||||
minimizer: [
|
||||
new CssMinimizerPlugin({
|
||||
parallel: Math.min(Os.cpus().length, 2),
|
||||
minimizerOptions: {
|
||||
preset: [
|
||||
'default',
|
||||
|
@ -123,7 +125,7 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
|||
cache: false,
|
||||
sourceMap: false,
|
||||
extractComments: false,
|
||||
parallel: false,
|
||||
parallel: Math.min(Os.cpus().length, 2),
|
||||
terserOptions: {
|
||||
compress: true,
|
||||
mangle: true,
|
||||
|
@ -154,54 +156,44 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
|
|||
new MiniCssExtractPlugin({
|
||||
filename: '[name].css',
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': dev ? '"development"' : '"production"',
|
||||
new CompressionPlugin({
|
||||
algorithm: 'brotliCompress',
|
||||
filename: '[path].br',
|
||||
test: /\.(js|css)$/,
|
||||
cache: false,
|
||||
}),
|
||||
...(dev
|
||||
? []
|
||||
: [
|
||||
new CompressionPlugin({
|
||||
algorithm: 'brotliCompress',
|
||||
filename: '[path].br',
|
||||
test: /\.(js|css)$/,
|
||||
cache: false,
|
||||
}),
|
||||
new CompressionPlugin({
|
||||
algorithm: 'gzip',
|
||||
filename: '[path].gz',
|
||||
test: /\.(js|css)$/,
|
||||
cache: false,
|
||||
}),
|
||||
new (class MetricsPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.emit.tap('MetricsPlugin', (compilation) => {
|
||||
const metrics = [
|
||||
{
|
||||
group: 'page load bundle size',
|
||||
id: 'kbnUiSharedDeps-js',
|
||||
value: compilation.assets['kbn-ui-shared-deps.js'].size(),
|
||||
},
|
||||
{
|
||||
group: 'page load bundle size',
|
||||
id: 'kbnUiSharedDeps-css',
|
||||
value:
|
||||
compilation.assets['kbn-ui-shared-deps.css'].size() +
|
||||
compilation.assets['kbn-ui-shared-deps.v7.light.css'].size(),
|
||||
},
|
||||
{
|
||||
group: 'page load bundle size',
|
||||
id: 'kbnUiSharedDeps-elastic',
|
||||
value: compilation.assets['kbn-ui-shared-deps.@elastic.js'].size(),
|
||||
},
|
||||
];
|
||||
new CompressionPlugin({
|
||||
algorithm: 'gzip',
|
||||
filename: '[path].gz',
|
||||
test: /\.(js|css)$/,
|
||||
cache: false,
|
||||
}),
|
||||
new (class MetricsPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.emit.tap('MetricsPlugin', (compilation) => {
|
||||
const metrics = [
|
||||
{
|
||||
group: 'page load bundle size',
|
||||
id: 'kbnUiSharedDeps-js',
|
||||
value: compilation.assets['kbn-ui-shared-deps.js'].size(),
|
||||
},
|
||||
{
|
||||
group: 'page load bundle size',
|
||||
id: 'kbnUiSharedDeps-css',
|
||||
value:
|
||||
compilation.assets['kbn-ui-shared-deps.css'].size() +
|
||||
compilation.assets['kbn-ui-shared-deps.v7.light.css'].size(),
|
||||
},
|
||||
{
|
||||
group: 'page load bundle size',
|
||||
id: 'kbnUiSharedDeps-elastic',
|
||||
value: compilation.assets['kbn-ui-shared-deps.@elastic.js'].size(),
|
||||
},
|
||||
];
|
||||
|
||||
compilation.emitAsset(
|
||||
'metrics.json',
|
||||
new RawSource(JSON.stringify(metrics, null, 2))
|
||||
);
|
||||
});
|
||||
}
|
||||
})(),
|
||||
]),
|
||||
compilation.emitAsset('metrics.json', new RawSource(JSON.stringify(metrics, null, 2)));
|
||||
});
|
||||
}
|
||||
})(),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ node scripts/build --debug --oss
|
|||
echo " -> shipping metrics from build to ci-stats"
|
||||
node scripts/ship_ci_stats \
|
||||
--metrics target/optimizer_bundle_metrics.json \
|
||||
--metrics packages/kbn-ui-shared-deps/target/metrics.json
|
||||
--metrics node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json
|
||||
|
||||
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
|
||||
installDir="$PARENT_DIR/install/kibana"
|
||||
|
|
|
@ -38,7 +38,7 @@ if [[ -z "$CODE_COVERAGE" ]] ; then
|
|||
echo " -> shipping metrics from build to ci-stats"
|
||||
node scripts/ship_ci_stats \
|
||||
--metrics target/optimizer_bundle_metrics.json \
|
||||
--metrics packages/kbn-ui-shared-deps/target/metrics.json
|
||||
--metrics node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json
|
||||
|
||||
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
|
||||
installDir="$KIBANA_DIR/install/kibana"
|
||||
|
|
|
@ -10,7 +10,7 @@ node scripts/build --debug --no-oss
|
|||
echo " -> shipping metrics from build to ci-stats"
|
||||
node scripts/ship_ci_stats \
|
||||
--metrics target/optimizer_bundle_metrics.json \
|
||||
--metrics packages/kbn-ui-shared-deps/target/metrics.json
|
||||
--metrics node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json
|
||||
|
||||
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
|
||||
installDir="$KIBANA_DIR/install/kibana"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { FunctionComponent } from 'react';
|
||||
import { Plugin, PluggableList } from 'unified';
|
||||
// Remove after this issue is resolved: https://github.com/elastic/eui/issues/4688
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { Options as Remark2RehypeOptions } from 'mdast-util-to-hast';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import rehype2react from 'rehype-react';
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
getDefaultEuiMarkdownUiPlugins,
|
||||
} from '@elastic/eui';
|
||||
// Remove after this issue is resolved: https://github.com/elastic/eui/issues/4688
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { Options as Remark2RehypeOptions } from 'mdast-util-to-hast';
|
||||
import { FunctionComponent } from 'react';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
|
|
|
@ -2792,7 +2792,7 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/ui-shared-deps@link:packages/kbn-ui-shared-deps":
|
||||
"@kbn/ui-shared-deps@link:bazel-bin/packages/kbn-ui-shared-deps":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue