feat(ast-grep): Add experimental ast-grep Wasm plugin#435
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-grepusing a Wasm plugin so a user can modify AST usingast-grep, instead of building a plugin