-
I'm trying to use SWC to write a custom build tool. I'm using SWC to parse some JS, modify the AST, and then I'd like to write out the modified AST as new javascript. When I try to generate the AST into code with
Where 467 is part of the span of one of the AST nodes, taken from my source data.
If I create an AST from scratch (with dummy spans), it outputs just fine, leading me to believe that the issue is the spans from the source file that was parsed. How would I get rid of these? I don't need these spans or source maps at all, since I'm not writing a plugin. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Nevermind, I wasn't aware that you could use |
Beta Was this translation helpful? Give feedback.
Nevermind, I wasn't aware that you could use
VisitMut
withEmitter
. I've switched to using that, and codegen now works for me. For anybody in a similar position (trying to do modify an AST and do codegen, but not trying to compile code or write a plugin), here is a discussion I found that contains the required code: #3141 (comment)