Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_v8): implement a wrapper for the V8 runtime #3580

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

leops
Copy link
Contributor

@leops leops commented Nov 7, 2022

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.

@leops leops temporarily deployed to netlify-playground November 7, 2022 17:15 Inactive
@netlify
Copy link

netlify bot commented Nov 7, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit be37464
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63693d3113903a0008a73273

@github-actions
Copy link

github-actions bot commented Nov 7, 2022

@github-actions
Copy link

github-actions bot commented Nov 7, 2022

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%

@github-actions
Copy link

This PR is stale because it has been open 14 days with no activity.

@leops leops added PR: on hold A PR that needs some upstream work before getting merged. and removed S-Stale labels Nov 22, 2022
@netlify
Copy link

netlify bot commented Jul 31, 2023

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 43e0387
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/64c78c14fbd1bd0008d95aa3

@github-actions github-actions bot added A-Core Area: core A-CLI Area: CLI A-Tooling Area: our own build, development, and release tooling labels Jul 31, 2023
@ematipico ematipico marked this pull request as ready for review July 31, 2023 09:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-CLI Area: CLI A-Core Area: core A-Tooling Area: our own build, development, and release tooling PR: on hold A PR that needs some upstream work before getting merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants