feat(rome_v8): implement a wrapper for the V8 runtime
Summary
This branch implements a prototype wrapper for the V8 JavaScript runtime, and exposes various syntax tree-related APIs to the JS environment: SyntaxNodes and SyntaxTokens, all AST node classes, and BatchMutations. These Rust functions and data structures are exposed to JS through a mix of hand written code and auto-generated "glue" code layer (this glue code is itself generated either from manually authored WebIDL files for individual rome crates, or directly from the grammar files for AST node).
For now the usage of this wrapper layer is limited as an example to running codemods through a dedicate CLI binary under crates/rome_v8/examples/codemod.rs. This binary can be run using cargo codemod --script <script> <INPUT...>: it expects the --script argument to be a JavaScript module declaring a single function as its default export. This function will be executed once for each JS file found in the inputs (using the same filesystem visitor logic as the main CLI) with the root syntax node of the file as an argument, and is expected to return either a syntax node or a batch mutation object. In either case the returned syntax tree is printed back to a string and saved back to the original file.
Test Plan
The wrapper currently only has a single, simple test for the codemod use case.
Deploy Preview for docs-rometools canceled.
| Name | Link |
|---|---|
| Latest commit | be3746456f2371fc668bd87e10babd0359c9a238 |
| Latest deploy log | https://app.netlify.com/sites/docs-rometools/deploys/63693d3113903a0008a73273 |
Parser conformance results on ubuntu-latest
js/262
| Test result | main count |
This PR count | Difference |
|---|---|---|---|
| Total | 48863 | 48863 | 0 |
| Passed | 47810 | 47810 | 0 |
| Failed | 1053 | 1053 | 0 |
| Panics | 0 | 0 | 0 |
| Coverage | 97.84% | 97.84% | 0.00% |
jsx/babel
| Test result | main count |
This PR count | Difference |
|---|---|---|---|
| Total | 40 | 40 | 0 |
| Passed | 37 | 37 | 0 |
| Failed | 3 | 3 | 0 |
| Panics | 0 | 0 | 0 |
| Coverage | 92.50% | 92.50% | 0.00% |
symbols/microsoft
| Test result | main count |
This PR count | Difference |
|---|---|---|---|
| Total | 6212 | 6212 | 0 |
| Passed | 1764 | 1764 | 0 |
| Failed | 4448 | 4448 | 0 |
| Panics | 0 | 0 | 0 |
| Coverage | 28.40% | 28.40% | 0.00% |
ts/babel
| Test result | main count |
This PR count | Difference |
|---|---|---|---|
| Total | 639 | 639 | 0 |
| Passed | 573 | 573 | 0 |
| Failed | 66 | 66 | 0 |
| Panics | 0 | 0 | 0 |
| Coverage | 89.67% | 89.67% | 0.00% |
ts/microsoft
| Test result | main count |
This PR count | Difference |
|---|---|---|---|
| Total | 17224 | 17224 | 0 |
| Passed | 13121 | 13121 | 0 |
| Failed | 4103 | 4103 | 0 |
| Panics | 0 | 0 | 0 |
| Coverage | 76.18% | 76.18% | 0.00% |
This PR is stale because it has been open 14 days with no activity.
Deploy Preview for docs-rometools canceled.
| Name | Link |
|---|---|
| Latest commit | 43e03872b8ad01cdd4551b3c1fc7151c3f6f5ef8 |
| Latest deploy log | https://app.netlify.com/sites/docs-rometools/deploys/64c78c14fbd1bd0008d95aa3 |