[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>
This commit is contained in:
Spencer 2022-11-22 11:25:50 -07:00 committed by GitHub
parent cffaa60bd1
commit cfdb8553ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 1245 additions and 282 deletions

View file

@ -64,6 +64,7 @@ layout: landing
{ pageId: "kibDevDocsOpsExpect" },
{ pageId: "kibDevDocsOpsAmbientStorybookTypes" },
{ pageId: "kibDevDocsOpsAmbientUiTypes" },
{ pageId: "kibDevDocsOpsAmbientCommonTypes" },
{ pageId: "kibDevDocsOpsTestSubjSelector" },
{ pageId: "kibDevDocsOpsBazelRunner" },
{ pageId: "kibDevDocsOpsCliDevMode" },
@ -77,5 +78,7 @@ layout: landing
{ pageId: "kibDevDocsOpsManagedVscodeConfigCli" },
{ pageId: "kibDevDocsOpsTest" },
{ pageId: "kibDevDocsOpsEsArchiver" },
{ pageId: "kibDevDocsOpsPeggy" },
{ pageId: "kibDevDocsOpsPeggyLoader" },
]}
/>