-
-
Notifications
You must be signed in to change notification settings - Fork 69
feat(ast-grep): Add experimental ast-grep
Wasm plugin
#435
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
base: main
Are you sure you want to change the base?
Conversation
|
cc @HerringtonDarkholme for visibility |
Hi Donny! For some background, ast-grep now is relying on tree-sitter as the parser. So using it with SWC will have to include another parser. Also, the tree-sitter cannot be compiled as WASM using Rust. It has to be compiled with emscripten. However, if ast-grep can be changed to be parser independent, say, providing a trait for AST node/Parser, it is possible to compile it with SWC to a standalone WASM. It will take quite a lot of effort, but it is not impossible! I can do some experiments in the coming weekend and give you a rough estimate of how much time it will take. |
Hi Donny, I'm working on ast-grep's parser abstraction on this branch now. ast-grep/ast-grep#1940 |
Hi Donny, now ast-grep is fully independent of tree-sitter parser now. See https://github.com/ast-grep/ast-grep/blob/290b31e6e44a9891f99d243b57c4ae1bdbaa340f/crates/core/Cargo.toml#L20 However, integrating swc still needs significant change in swc plugin system.
|
This is an example of using oxc as parser. ast-grep/ast-grep#1970 oxc is used because it has an untyped AST which makes the integration faster. But the general idea is three steps:
|
I'm trying to see if we can support
ast-grep
using a Wasm plugin so a user can modify AST usingast-grep
, instead of building a plugin