How to manipulate AST and generate code with comments #8334
Replies: 1 comment
-
I am also running to this issue. I believe it has to do with this code block: oxc/crates/oxc_codegen/src/comment.rs Lines 73 to 108 in 8eccdec Here, we can see that in As a workaround, I've made each of my comments pseudo "legal comments" (https://modernjs.dev/en/configure/app/output/legal-comments.html) because I find it acceptable to do so, and they are preserved in my output. e.g. let js_content = r#"
//! Change heading:
import { foo } from "module-name";
//! Change heading:
console.log("Duplicate import test");
"#; I would expect that we can preserve source comments (and ideally newlines) as first party nodes in the AST/writer. Am happy to contribute back code if there is agreement, let me know! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello friends, Sorry for this question. I am using OXC project in my Rust app and have a problem.
As you see in the below code, I generate AST and change it after that with
Codegen
, I create a new code again, but the problem is; it cleans all the comments of file. how can prevent it not to do this?I even used this, but still it cleans all the comment inside the code
Example js code:
Example rust code:
Thank in advance
Beta Was this translation helpful? Give feedback.
All reactions