Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork78
feat(ast-grep): Add experimentalast-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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
changeset-botbot commentedApr 7, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
cc@HerringtonDarkholme for visibility |
HerringtonDarkholme commentedApr 8, 2025
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. |
HerringtonDarkholme commentedApr 25, 2025
Hi Donny, I'm working on ast-grep's parser abstraction on this branch now.ast-grep/ast-grep#1940 |
HerringtonDarkholme commentedMay 4, 2025
Hi Donny, now ast-grep is fully independent of tree-sitter parser now. Seehttps://github.com/ast-grep/ast-grep/blob/290b31e6e44a9891f99d243b57c4ae1bdbaa340f/crates/core/Cargo.toml#L20 However, integrating swc still needs significant change in swc plugin system.
|
HerringtonDarkholme commentedMay 4, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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