-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[pkgs/peggy] automatically transform peggy files with babel-register and webpack #145615
[pkgs/peggy] automatically transform peggy files with babel-register and webpack #145615
Conversation
697431e
to
7ee2e8e
Compare
7ee2e8e
to
0214607
Compare
…-register-hook-for-peggy-files
Pinging @elastic/kibana-operations (Team:Operations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind if we add the ci:build-storybooks
and ci:build-canvas-shareable-runtime
labels?
…-register-hook-for-peggy-files
…b.com:spalger/kibana into implement/babel-register-hook-for-peggy-files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Canvas sharable runtime webpack config change LGTM.
…-ref HEAD~1..HEAD --fix'
…b.com:spalger/kibana into implement/babel-register-hook-for-peggy-files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Any counts in public APIs
Async chunks
Canvas Sharable Runtime
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
## Summary Resolves #143335. Some history: A similar issue was reported a few years back (#76811). The solution (#93319) was to use the `--cache` PEG.js [parameter](https://pegjs.org/documentation#generating-a-parser) when generating the parser. Back when this was added, we were still manually building the parser on demand when it was changed. Eventually we added support for dynamically building the parser during the build process (#145615). I'm not sure where along the process the `cache` parameter got lost but it didn't appear to be used when we switched. This PR re-adds this parameter which increases performance considerably (metrics shown in ops/sec): ``` Before using cache: ● kuery AST API › fromKueryExpression › performance › with simple expression Received: 7110.68990544415 ● kuery AST API › fromKueryExpression › performance › with complex expression Received: 40.51361746242248 ● kuery AST API › fromKueryExpression › performance › with many subqueries Received: 17.071767133068473 After using cache: ● kuery AST API › fromKueryExpression › performance › with simple expression Received: 8275.49109867502 ● kuery AST API › fromKueryExpression › performance › with complex expression Received: 447.0459218892934 ● kuery AST API › fromKueryExpression › performance › with many subqueries Received: 115852.43643466769 ``` ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
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 likeallowedStartRules
as described in the peggy docs.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.