Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NA): moving @kbn/ui-shared-deps into bazel #101669

Merged
merged 21 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
82843a7
chore(NA): moving @kbn/io-ts-utils into bazel
mistic May 27, 2021
8117d2d
Merge remote-tracking branch 'upstream/master' into move-kbn-io-ts-ut…
mistic May 27, 2021
be2024d
chore(NA): moving @kbn/ui-shared-deps into bazel
mistic May 27, 2021
6ae9749
chore(NA): merge and solve conflicts with master
mistic Jun 9, 2021
844b906
chore(NA): compelte working build for @kbn/ui-shared-deps
mistic Jun 9, 2021
5e32dc3
chore(NA): solve eslint problems
mistic Jun 9, 2021
e369814
chore(NA): solve typechecking
mistic Jun 9, 2021
fccd4cf
chore(NA): debugger changes
mistic Jun 9, 2021
7d9006a
chore(NA): update optimizer basic integration tests
mistic Jun 9, 2021
c770a19
chore(NA): ship kbn/ui-shared-deps metrics.json from new location at …
mistic Jun 9, 2021
193d3f9
chore(NA): use correct ui-shared-deps metrics file location
mistic Jun 9, 2021
8142ffd
Merge remote-tracking branch 'upstream/master' into move-kbn-ui-share…
mistic Jun 9, 2021
c4707ba
Merge remote-tracking branch 'upstream/master' into move-kbn-ui-share…
mistic Jun 10, 2021
f9c6b9d
chore(NA): remove webpack bazel config
mistic Jun 11, 2021
f0063e3
Merge branch 'master' into move-kbn-ui-shared-deps-into-bazel
kibanamachine Jun 12, 2021
e5356f2
Merge branch 'master' into move-kbn-ui-shared-deps-into-bazel
kibanamachine Jun 14, 2021
b72028c
Merge branch 'master' into move-kbn-ui-shared-deps-into-bazel
kibanamachine Jun 17, 2021
141c9d4
chore(NA): implement improvements on webpack config
mistic Jun 17, 2021
ba86e2b
chore(NA): remove extra comment
mistic Jun 17, 2021
bffc49a
chore(NA): try esbuild-loader minimizer
mistic Jun 17, 2021
b59264c
Revert "chore(NA): try esbuild-loader minimizer"
mistic Jun 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/scripts/post_build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,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,
},
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@ yarn kbn watch-bazel
- @kbn/std
- @kbn/telemetry-utils
- @kbn/tinymath
- @kbn/ui-shared-deps
- @kbn/utility-types
- @kbn/utils
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,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",
Expand Down Expand Up @@ -290,6 +290,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",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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",
],
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: {
Expand Down Expand Up @@ -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,
]
`);

Expand All @@ -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,
Expand All @@ -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,
]
`);

Expand All @@ -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,
]
`);
});
Expand Down
15 changes: 13 additions & 2 deletions packages/kbn-optimizer/src/worker/populate_bundle_cache_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
145 changes: 145 additions & 0 deletions packages/kbn-ui-shared-deps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions packages/kbn-ui-shared-deps/flot_charts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"main": "../target/flot_charts/index.js",
"types": "../target/flot_charts/index.d.ts"
}
59 changes: 0 additions & 59 deletions packages/kbn-ui-shared-deps/index.d.ts

This file was deleted.

7 changes: 2 additions & 5 deletions packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Loading