mirror of
https://github.com/elastic/kibana.git
synced 2025-04-19 15:35:00 -04:00
fix(NA): build external plugins with correct bazel artifacts output mode (#159630)
Closes https://github.com/elastic/kibana/issues/159328 , https://github.com/elastic/kibana/issues/154325, https://github.com/elastic/kibana/issues/157440 This PR fixes a problem in the plugin helpers tasks used to build external plugins. After changes to transpile packages differently in the past months a bug was introduced and external plugins were being built with the wrong shared ui deps output mode causing development form imports to be bundled and causing problems at page load time. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
6f1fe0c12c
commit
7e067ec478
8 changed files with 45 additions and 3 deletions
|
@ -112,7 +112,7 @@ async function runBazelRunner(runner, args, options = undefined) {
|
|||
]),
|
||||
]);
|
||||
|
||||
if (process.env.CI) {
|
||||
if (process.env.CI && !options?.quiet) {
|
||||
// on CI it's useful to reduce the logging output, but we still want to see basic info from Bazel so continue to log the INFO: lines from bazel
|
||||
for (const line of buffer) {
|
||||
if (line.startsWith('INFO:') && !line.startsWith('INFO: From ')) {
|
||||
|
|
|
@ -53,9 +53,9 @@ Generated plugins receive a handful of scripts that can be used during developme
|
|||
|
||||
> ***NOTE:*** The following scripts should be run from the generated plugin root folder.
|
||||
|
||||
- `yarn kbn bootstrap`
|
||||
- `yarn bootstrap`
|
||||
|
||||
Install dependencies and crosslink Kibana and all projects/plugins.
|
||||
Install dependencies both on Kibana and in your plugin.
|
||||
|
||||
> ***IMPORTANT:*** Use this script instead of `yarn` to install dependencies when switching branches, and re-run it whenever your dependencies change.
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"bootstrap": "yarn kbn bootstrap && yarn install",
|
||||
"build": "yarn plugin-helpers build",
|
||||
"dev": "yarn plugin-helpers dev",
|
||||
"plugin-helpers": "node ../../scripts/plugin_helpers",
|
||||
|
|
|
@ -85,6 +85,7 @@ export function runCli() {
|
|||
};
|
||||
|
||||
await Tasks.initTargets(context);
|
||||
await Tasks.buildBazelPackages(context);
|
||||
await Tasks.optimize(context);
|
||||
await Tasks.writePublicAssets(context);
|
||||
await Tasks.writeServerFiles(context);
|
||||
|
@ -160,6 +161,7 @@ export function runCli() {
|
|||
};
|
||||
|
||||
await Tasks.initDev(context);
|
||||
await Tasks.buildBazelPackages(context);
|
||||
await Tasks.optimize(context);
|
||||
},
|
||||
})
|
||||
|
|
|
@ -68,6 +68,8 @@ it('builds a generated plugin into a viable archive', async () => {
|
|||
|
||||
expect(filterLogs(buildProc.all)).toMatchInlineSnapshot(`
|
||||
" info deleting the build and target directories
|
||||
info run bazel and build required artifacts for the optimizer
|
||||
succ bazel run successfully and artifacts were created
|
||||
info running @kbn/optimizer
|
||||
│ succ browser bundle created at plugins/foo_test_plugin/build/kibana/fooTestPlugin/target/public
|
||||
│ info stopping @kbn/optimizer
|
||||
|
|
35
packages/kbn-plugin-helpers/src/tasks/bazel_packages.ts
Normal file
35
packages/kbn-plugin-helpers/src/tasks/bazel_packages.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { runBazel } from '@kbn/bazel-runner';
|
||||
import { TaskContext } from '../task_context';
|
||||
|
||||
export async function buildBazelPackages({ log, dist }: TaskContext) {
|
||||
log.info('run bazel and build required artifacts for the optimizer');
|
||||
|
||||
try {
|
||||
await runBazel(
|
||||
[
|
||||
'build',
|
||||
'//packages/kbn-ui-shared-deps-npm:shared_built_assets',
|
||||
'//packages/kbn-ui-shared-deps-src:shared_built_assets',
|
||||
'//packages/kbn-monaco:target_workers',
|
||||
'--show_result=1',
|
||||
].concat(dist ? [`--define=dist=true`] : []),
|
||||
{
|
||||
logPrefix: ' │ ',
|
||||
quiet: true,
|
||||
}
|
||||
);
|
||||
|
||||
log.success('bazel run successfully and artifacts were created');
|
||||
} catch (e) {
|
||||
log.error(`bazel run failed: ${e}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export * from './bazel_packages';
|
||||
export * from './clean';
|
||||
export * from './create_archive';
|
||||
export * from './optimize';
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"@kbn/jest-serializers",
|
||||
"@kbn/repo-packages",
|
||||
"@kbn/stdio-dev-helpers",
|
||||
"@kbn/bazel-runner",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
Loading…
Add table
Reference in a new issue