Replies: 6 comments 3 replies
-
Replying my own question with what it is upto now: Babel has import generate from "@babel/generator";
const { code } = generate(ast); Though it looks promising, it doesn't seem to be working with SWC generated AST (Getting |
Beta Was this translation helpful? Give feedback.
-
Babel's AST format and SWC's are different in quite a few ways. Also, some other tools use another format again called ESTree. If you want to use On the other hand, if you want to use SWC, use SWC's I think these methods are undocumented at present, but the code for them in SWC is here: Lines 92 to 110 in 9feabcd Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
I think swc has codegen code for jsx.. |
Beta Was this translation helpful? Give feedback.
-
Any update on this? I'm also in need of an swc web version to transform AST to JSX output. |
Beta Was this translation helpful? Give feedback.
-
Calling |
Beta Was this translation helpful? Give feedback.
-
Closing as adqueadtely answered, use parse / print pair as needed. |
Beta Was this translation helpful? Give feedback.
-
Context: I'm trying to create a React to SolidJS converter using swc-playground as a base https://github.com/rrjanbiah/react2solid/tree/main/converter With the base swc-playground, I'm able to convert the React code to AST. I want to do some manipulations in the AST and convert back to the original/JSX code.
Is AST to JSX/React code possible? If possible, please share relevant links.
If not possible, please suggest the starting point for the development.
TIA
Beta Was this translation helpful? Give feedback.
All reactions