kibana/packages
Spencer cfdb8553ba
[pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615)
In order to get us closer to the developer experience we want for
packages, we are trying to move package builds out of bazel and instead
we want to build files on demand. In the case of .peggy files this means
importing them directly and teaching babel/jest/webpack how to handle
these imports by automatically transpiling and caching the results.

This change does just that, adding a `@kbn/peggy` package which wraps
peggy for types, and also adds support for defining peggy config
adjacent to a peggy grammar file in a `${basename}.config.json` file.
This file will be parsed and used to configure things like
`allowedStartRules` as described in [the peggy
docs](https://peggyjs.org/documentation.html#generating-a-parser-javascript-api).

This PR also implements `@kbn/peggy-loader` which uses `@kbn/peggy` to
transpile peggy files in webpack, and a peggy transform for both Jest
and our custom babel register hook.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-11-22 11:25:50 -07:00
..
analytics Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
content-management chore(NA): enables isolatedModules on base tsconfig file (#144841) 2022-11-18 19:39:11 +00:00
core Fix SO service status when migration is disabled (#145693) 2022-11-21 01:02:52 -07:00
home Upgrade EUI to v70.2.4 (#144845) 2022-11-18 14:21:28 -06:00
kbn-ace fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-alerts Bumping EUI to version 67.1.8 (#141279) 2022-11-07 21:45:50 +00:00
kbn-ambient-common-types [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-ambient-storybook-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ambient-ui-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-analytics Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-apm-config-loader fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-apm-synthtrace [APM] Agent explorer (PoC) (#143844) 2022-11-14 15:40:49 +01:00
kbn-apm-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-axe-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-babel-plugin-synthetic-packages [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-babel-preset Update dependency core-js to ^3.26.1 (main) (#145795) 2022-11-21 10:30:59 -06:00
kbn-bazel-packages fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-bazel-runner fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-cases-components fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-chart-icons Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-ci-stats-core fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ci-stats-performance-metrics fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ci-stats-reporter [ci-stats] ensure that all timing metadata values are of valid types (#145919) 2022-11-21 13:55:36 -07:00
kbn-cli-dev-mode Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
kbn-coloring Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
kbn-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-config-mocks fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-config-schema Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-crypto fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-crypto-browser fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-datemath Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
kbn-dev-cli-errors fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-dev-cli-runner fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-dev-proc-runner fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-dev-utils fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-doc-links [Enterprise Search] Rename filtering to sync rules (#146013) 2022-11-22 10:38:49 -07:00
kbn-docs-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-ebt-tools remove unnecessary import aliases (#144250) 2022-10-31 17:56:59 +01:00
kbn-es fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-es-archiver fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-es-errors fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-es-query [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-es-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-eslint-config chore(NA): enables isolatedModules on base tsconfig file (#144841) 2022-11-18 19:39:11 +00:00
kbn-eslint-plugin-disable fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-eslint-plugin-eslint [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-eslint-plugin-imports fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-expect [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-failed-test-reporter-cli Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-field-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-find-used-node-modules fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-flot-charts [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-ftr-common-functional-services fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ftr-screenshot-filename fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-generate fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-get-repo-files fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-guided-onboarding [Guided onboarding] Fix card footer button markup (#145050) 2022-11-14 10:10:53 -05:00
kbn-handlebars fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-hapi-mocks fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-health-gateway-server [Health Gateway] Add extra logging (#144888) 2022-11-21 14:20:09 +01:00
kbn-i18n Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
kbn-i18n-react Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
kbn-import-resolver [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-interpreter [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-io-ts-utils fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-jest-serializers fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-journeys [kbn-journeys] extend apm labels with branch, gitRev, ciBuildName (#144521) 2022-11-04 23:11:45 +01:00
kbn-kibana-manifest-schema fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-language-documentation-popover Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-logging fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-logging-mocks fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-managed-vscode-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-managed-vscode-config-cli fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-mapbox-gl [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-monaco Upgrade to Jest 29 (#143319) 2022-11-18 09:40:16 -06:00
kbn-optimizer [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-optimizer-webpack-helpers fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-osquery-io-ts-types [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-peggy [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-peggy-loader [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-performance-testing-dataset-extractor fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-plugin-discovery fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-plugin-generator [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-plugin-helpers [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-react-field fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-repo-source-classifier fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-repo-source-classifier-cli fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-rule-data-utils [ResponseOps][Rules] Adding rule.url variable (#145035) 2022-11-15 16:05:32 -07:00
kbn-safer-lodash-set [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-autocomplete [Security Solution] [Exceptions] Adds options to create a shared exception list and to create a single item from the manage exceptions view (#144575) 2022-11-09 09:54:45 -05:00
kbn-securitysolution-es-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-exception-list-components Endpoint fixes (#145834) 2022-11-21 18:37:35 +01:00
kbn-securitysolution-hook-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-io-ts-alerting-types [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-io-ts-list-types Add sorting for exceptions cards (#145070) 2022-11-15 13:55:38 -07:00
kbn-securitysolution-io-ts-types [Security Solution] [Exceptions] Updates the exceptions list table to match mockups (#142289) 2022-11-02 08:41:48 -07:00
kbn-securitysolution-io-ts-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-list-api Add sorting for exceptions cards (#145070) 2022-11-15 13:55:38 -07:00
kbn-securitysolution-list-constants [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-list-hooks chore(NA): enables isolatedModules on base tsconfig file (#144841) 2022-11-18 19:39:11 +00:00
kbn-securitysolution-list-utils [Security Solution] [Exceptions] Adds a new react route for viewing details about an individual exception list (#144754) 2022-11-14 07:32:52 -05:00
kbn-securitysolution-rules [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-t-grid [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-utils chore(NA): enables isolatedModules on base tsconfig file (#144841) 2022-11-18 19:39:11 +00:00
kbn-server-http-tools Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-server-route-repository fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-shared-svg fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-shared-ux-utility rename codeowners from shared-ux to global-experience (#144746) 2022-11-08 09:13:16 -07:00
kbn-some-dev-log fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-sort-package-json fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-spec-to-console [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-std fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-stdio-dev-helpers fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-storybook [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-synthetic-package-map fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-telemetry-tools [UsageCollection] Allow pass_through on Record<string, unknown> types (#144571) 2022-11-04 09:22:01 +01:00
kbn-test [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-test-jest-helpers [ContentManagement] Inspector flyout (#144240) 2022-11-09 06:01:53 -07:00
kbn-test-subj-selector fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-timelion-grammar [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-tinymath [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-tooling-log fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-type-summarizer fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-type-summarizer-cli fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-type-summarizer-core fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-typed-react-router-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ui-framework [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-ui-shared-deps-npm fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ui-shared-deps-src [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
kbn-ui-theme fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-user-profile-components Add the ability to limit the number of users you can select (#144618) 2022-11-07 12:39:30 +00:00
kbn-utility-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-utility-types-jest fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-yarn-lock-validator fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
shared-ux Upgrade EUI to v70.2.4 (#144845) 2022-11-18 14:21:28 -06:00
BUILD.bazel [pkgs/peggy] automatically transform peggy files with babel-register and webpack (#145615) 2022-11-22 11:25:50 -07:00
README.md [kbn/pm] rewrite to avoid needing a build process (#136207) 2022-07-18 08:46:13 -07:00

Kibana-related packages

This folder contains packages that are intended for use in Kibana and Kibana plugins.

tl;dr:

  • Don't publish to npm registry
  • Always use the @kbn namespace
  • Always set "private": true in package.json

Using these packages

We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.

For example if you want to use the @kbn/i18n package in Kibana itself, you can specify the dependency like this:

"@kbn/i18n": "1.0.0"

However, if you want to use this from a Kibana plugin, you need to use a link: dependency and account for the relative location of the Kibana repo, so it would instead be:

"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"

Creating a new package

Create a new sub-folder. The name of the folder should mirror the name in the package's package.json. E.g. if the name is @kbn/i18n the folder name should be kbn-i18n.

All new packages should use the @kbn namespace, and should be marked with "private": true.

Unit tests for a package

Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.

Jest

A package should follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.

A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.

  • yarn test runs all unit tests.
  • yarn jest runs all Jest tests in Kibana.

In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.


Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.