This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 657
feat(rome_v8): implement a wrapper for the V8 runtime #3580
Open
leops
wants to merge
5
commits into
main
Choose a base branch
from
feature/v8-poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for docs-rometools canceled.
|
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
This PR is stale because it has been open 14 days with no activity. |
leops
added
PR: on hold
A PR that needs some upstream work before getting merged.
and removed
S-Stale
labels
Nov 22, 2022
✅ Deploy Preview for docs-rometools canceled.
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usingcargo 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.