kibana/kbn_pm
Anton Dosov 5cd26eef91
[8.x] Sustainable Kibana Architecture: Move CodeEditor related packages #205587 (#205738) (#205919)
# Backport

This will backport the following commits from `main` to `8.x`:
- [Sustainable Kibana Architecture: Move `CodeEditor` related packages
#205587 (#205738)](https://github.com/elastic/kibana/pull/205738)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Anton
Dosov","email":"anton.dosov@elastic.co"},"sourceCommit":{"committedDate":"2025-01-08T14:25:47Z","message":"Sustainable
Kibana Architecture: Move `CodeEditor` related packages #205587
(#205738)\n\n## Summary\r\n\r\nThis PR aims at relocating some of the
Kibana modules (plugins and\r\npackages) into a new folder structure,
according to the _Sustainable\r\nKibana Architecture_
initiative.\r\n\r\n> [!IMPORTANT]\r\n> * We kindly ask you to:\r\n> *
Manually fix the errors in the error section below (if there
are\r\nany).\r\n> * Search for the `packages[\\/\\\\]` and
`plugins[\\/\\\\]` patterns in the\r\nsource code (Babel and Eslint
config files), and update them\r\nappropriately.\r\n> * Manually
review\r\n`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to
ensure that\r\nany CI pipeline customizations continue to be correctly
applied after\r\nthe changed path names\r\n> * Review all of the updated
files, specially the `.ts` and `.js` files\r\nlisted in the sections
below, as some of them contain relative paths\r\nthat have been
updated.\r\n> * Think of potential impact of the move, including tooling
and\r\nconfiguration files that can be pointing to the relocated
modules. E.g.:\r\n> * customised eslint rules\r\n> * docs pointing to
source code\r\n\r\n> [!NOTE]\r\n> * This PR has been
auto-generated.\r\n> * Any manual contributions will be lost if the
'relocate' script is\r\nre-run.\r\n> * Try to obtain the missing reviews
/ approvals before applying manual\r\nfixes, and/or keep your changes in
a .patch / git stash.\r\n> * Please
use\r\n[#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E)\r\nSlack
channel for feedback.\r\n\r\nAre you trying to rebase this PR to solve
merge conflicts? Please follow\r\nthe steps
describe\r\n[here](https://elastic.slack.com/archives/C07TCKTA22E/p1734019532879269?thread_ts=1734019339.935419&cid=C07TCKTA22E).\r\n\r\n####
3 packages(s) are going to be relocated:\r\n\r\n| Id | Target folder
|\r\n| -- | ------------- |\r\n| `@kbn/code-editor`
|\r\n`src/platform/packages/shared/shared-ux/code_editor/impl` |\r\n|
`@kbn/code-editor-mock`
|\r\n`src/platform/packages/shared/shared-ux/code_editor/mocks` |\r\n|
`@kbn/monaco` | `src/platform/packages/shared/kbn-monaco`
|\r\n\r\n\r\n<details >\r\n<summary>Updated relative
paths</summary>\r\n\r\n```\r\nsrc/platform/packages/shared/kbn-monaco/jest.config.js:12\r\nsrc/platform/packages/shared/kbn-monaco/tsconfig.json:2\r\nsrc/platform/packages/shared/kbn-monaco/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/jest.config.js:12\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:16\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:18\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:25\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:28\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:31\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:34\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:37\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:40\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:16\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:18\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:25\r\n```\r\n\r\n</details>","sha":"3b2ab7b4134c05c00a74a70d7905f6b06e1364c1","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","backport:prev-minor","plugin
groups"],"number":205738,"url":"https://github.com/elastic/kibana/pull/205738","mergeCommit":{"message":"Sustainable
Kibana Architecture: Move `CodeEditor` related packages #205587
(#205738)\n\n## Summary\r\n\r\nThis PR aims at relocating some of the
Kibana modules (plugins and\r\npackages) into a new folder structure,
according to the _Sustainable\r\nKibana Architecture_
initiative.\r\n\r\n> [!IMPORTANT]\r\n> * We kindly ask you to:\r\n> *
Manually fix the errors in the error section below (if there
are\r\nany).\r\n> * Search for the `packages[\\/\\\\]` and
`plugins[\\/\\\\]` patterns in the\r\nsource code (Babel and Eslint
config files), and update them\r\nappropriately.\r\n> * Manually
review\r\n`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to
ensure that\r\nany CI pipeline customizations continue to be correctly
applied after\r\nthe changed path names\r\n> * Review all of the updated
files, specially the `.ts` and `.js` files\r\nlisted in the sections
below, as some of them contain relative paths\r\nthat have been
updated.\r\n> * Think of potential impact of the move, including tooling
and\r\nconfiguration files that can be pointing to the relocated
modules. E.g.:\r\n> * customised eslint rules\r\n> * docs pointing to
source code\r\n\r\n> [!NOTE]\r\n> * This PR has been
auto-generated.\r\n> * Any manual contributions will be lost if the
'relocate' script is\r\nre-run.\r\n> * Try to obtain the missing reviews
/ approvals before applying manual\r\nfixes, and/or keep your changes in
a .patch / git stash.\r\n> * Please
use\r\n[#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E)\r\nSlack
channel for feedback.\r\n\r\nAre you trying to rebase this PR to solve
merge conflicts? Please follow\r\nthe steps
describe\r\n[here](https://elastic.slack.com/archives/C07TCKTA22E/p1734019532879269?thread_ts=1734019339.935419&cid=C07TCKTA22E).\r\n\r\n####
3 packages(s) are going to be relocated:\r\n\r\n| Id | Target folder
|\r\n| -- | ------------- |\r\n| `@kbn/code-editor`
|\r\n`src/platform/packages/shared/shared-ux/code_editor/impl` |\r\n|
`@kbn/code-editor-mock`
|\r\n`src/platform/packages/shared/shared-ux/code_editor/mocks` |\r\n|
`@kbn/monaco` | `src/platform/packages/shared/kbn-monaco`
|\r\n\r\n\r\n<details >\r\n<summary>Updated relative
paths</summary>\r\n\r\n```\r\nsrc/platform/packages/shared/kbn-monaco/jest.config.js:12\r\nsrc/platform/packages/shared/kbn-monaco/tsconfig.json:2\r\nsrc/platform/packages/shared/kbn-monaco/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/jest.config.js:12\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:16\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:18\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:25\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:28\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:31\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:34\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:37\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:40\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:16\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:18\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:25\r\n```\r\n\r\n</details>","sha":"3b2ab7b4134c05c00a74a70d7905f6b06e1364c1"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205738","number":205738,"mergeCommit":{"message":"Sustainable
Kibana Architecture: Move `CodeEditor` related packages #205587
(#205738)\n\n## Summary\r\n\r\nThis PR aims at relocating some of the
Kibana modules (plugins and\r\npackages) into a new folder structure,
according to the _Sustainable\r\nKibana Architecture_
initiative.\r\n\r\n> [!IMPORTANT]\r\n> * We kindly ask you to:\r\n> *
Manually fix the errors in the error section below (if there
are\r\nany).\r\n> * Search for the `packages[\\/\\\\]` and
`plugins[\\/\\\\]` patterns in the\r\nsource code (Babel and Eslint
config files), and update them\r\nappropriately.\r\n> * Manually
review\r\n`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to
ensure that\r\nany CI pipeline customizations continue to be correctly
applied after\r\nthe changed path names\r\n> * Review all of the updated
files, specially the `.ts` and `.js` files\r\nlisted in the sections
below, as some of them contain relative paths\r\nthat have been
updated.\r\n> * Think of potential impact of the move, including tooling
and\r\nconfiguration files that can be pointing to the relocated
modules. E.g.:\r\n> * customised eslint rules\r\n> * docs pointing to
source code\r\n\r\n> [!NOTE]\r\n> * This PR has been
auto-generated.\r\n> * Any manual contributions will be lost if the
'relocate' script is\r\nre-run.\r\n> * Try to obtain the missing reviews
/ approvals before applying manual\r\nfixes, and/or keep your changes in
a .patch / git stash.\r\n> * Please
use\r\n[#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E)\r\nSlack
channel for feedback.\r\n\r\nAre you trying to rebase this PR to solve
merge conflicts? Please follow\r\nthe steps
describe\r\n[here](https://elastic.slack.com/archives/C07TCKTA22E/p1734019532879269?thread_ts=1734019339.935419&cid=C07TCKTA22E).\r\n\r\n####
3 packages(s) are going to be relocated:\r\n\r\n| Id | Target folder
|\r\n| -- | ------------- |\r\n| `@kbn/code-editor`
|\r\n`src/platform/packages/shared/shared-ux/code_editor/impl` |\r\n|
`@kbn/code-editor-mock`
|\r\n`src/platform/packages/shared/shared-ux/code_editor/mocks` |\r\n|
`@kbn/monaco` | `src/platform/packages/shared/kbn-monaco`
|\r\n\r\n\r\n<details >\r\n<summary>Updated relative
paths</summary>\r\n\r\n```\r\nsrc/platform/packages/shared/kbn-monaco/jest.config.js:12\r\nsrc/platform/packages/shared/kbn-monaco/tsconfig.json:2\r\nsrc/platform/packages/shared/kbn-monaco/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/jest.config.js:12\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:16\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:18\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:25\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:28\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:31\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:34\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:37\r\nsrc/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:40\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:16\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:18\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:2\r\nsrc/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:25\r\n```\r\n\r\n</details>","sha":"3b2ab7b4134c05c00a74a70d7905f6b06e1364c1"}}]}]
BACKPORT-->

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2025-01-10 11:20:26 +00:00
..
src [8.x] Sustainable Kibana Architecture: Move CodeEditor related packages #205587 (#205738) (#205919) 2025-01-10 11:20:26 +00:00
README.mdx Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
tsconfig.json [packages] migrate all plugins to packages (#148130) 2023-02-08 21:06:50 -06:00

---
id: kibDevDocsOpsKbnPm
slug: /kibana-dev-docs/ops/kbn-pm
title: "@kbn/pm"
description: 'The tool which bootstraps the repo and helps work with packages'
date: 2022-07-14
tags: ['kibana', 'dev', 'contributor', 'operations', 'packages', 'scripts']
---

`@kbn/pm` is the tool that we use to bootstrap the Kibana repository, build packages with Bazel, and run scripts in packages.

## commands

### `yarn kbn bootstrap`

Use this command to install dependencies, build packages, and prepare the repo for local development.

### `yarn kbn watch`

Use this command to build all packages and make sure that they are rebuilt as you make changes.

### and more!

There are several commands supported by `@kbn/pm`, but rather than documenting them here they are documented in the help text. Please run `yarn kbn --help` locally to see the most up-to-date info.

## Why isn't this TypeScript?

Since this tool is required for bootstrapping the repository it needs to work without any dependencies installed and without a build toolchain. We accomplish this by writing the tool in vanilla JS (shocker!) and using TypeScript to validate the code which is typed via heavy use of JSDoc comments.

In order to use import/export syntax and enhance the developer experience a little we use the `.mjs` file extension.

In some cases we actually do use TypeScript files, just for defining complicated types. These files are then imported only in special TS-compatible JSDoc comments, so Node.js will never try to import them but they can be used to define types which are too complicated to define inline or in a JSDoc comment.

There are cases where `@kbn/pm` relies on code from packages, mostly to prevent reimplementing common functionality. This can only be done in one of two ways:

 1. With a dynamic `await import(...)` statement that is always run after boostrap is complete, or is wrapped in a try/catch in case bootstrap didn't complete successfully.
 2. By pulling in the source code of the un-built package.

Option 1 is used in several places, with contingencies in place in case bootstrap failed. Option 2 is used for two pieces of code which are needed in order to run bootstrap:

 1. `@kbn/plugin-discovery` as we need to populate the `@kbn/package-map` to run Bazel
 2. `@kbn/bazel-runner` as we want to have the logic for running bazel in a single location

Because we load these two packages from source, without being built, before bootstrap is ever run, they can not depend on other packages and must be written in Vanilla JS as well.