-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
How do I use visitor in oxc-parser using typescript ? #6244
Comments
Currently Oxc is focused on providing JS APIs based on "source text in, source text out". i.e. all AST manipulation occurs on Rust side. For this reason, the oxc-parser npm package does not currently provide a visitor. It will do in future, but it's going to take a while - it's more complicated than it sounds. Of course, you can write JS/TS code to traverse/explore the AST in whatever way you would like, but we don't provide an "out of the box" AST visitor (yet). The JS-side AST almost entirely aligns with ESTree, so you could try using another library which provides an ESTree AST visitor/transformer. However, the AST does not align exactly with ESTree at present - it is our intent that it will (#2854), but we're not there yet. There are also currently no TS type definitions for Oxc's AST (again, more difficult than it sounds - good Rust-JS interop is quite a hard problem). Sorry that's not the answer that you want, but I hope this info helps somewhat. |
@rizrmd where have you looked and what is lacking from our current documentation? |
Mainly here: https://oxc.rs/docs/guide/usage/parser.html Also, there are prior works from swc like woodpile and swc-walk.
Both are good enough, the problem is the size in wasm. I tried to parse oxc result using swc-walk, surprisingly it works for simple code. But there are some differences in node.type, and several node properties. I just add/modify them to works, but I think this is still a hack... |
No worries, understandable. Thanks for explaining. |
👍 so the question is regarding visitor in js, and we lack one. We need to document as such. Thank you for the input. |
Provided example is using rust, how do I do it in typescript/js ?
The text was updated successfully, but these errors were encountered: