diff --git a/crates/oxc_codegen/src/annotation_comment.rs b/crates/oxc_codegen/src/annotation_comment.rs index 048bb5b06..e42cd70f4 100644 --- a/crates/oxc_codegen/src/annotation_comment.rs +++ b/crates/oxc_codegen/src/annotation_comment.rs @@ -50,7 +50,7 @@ impl<'a> Codegen<'a> { &mut self, node_start: u32, ) -> Vec { - if !self.comment_options.preserve_annotate_comments { + if !self.preserve_annotate_comments() { return vec![]; } let mut latest_comment_start = node_start; @@ -127,7 +127,7 @@ impl<'a> Codegen<'a> { } pub(crate) fn gen_comments(&mut self, node_start: u32) { - if !self.comment_options.preserve_annotate_comments { + if !self.preserve_annotate_comments() { return; } let mut annotation_kind_set = AnnotationKind::empty(); diff --git a/crates/oxc_codegen/src/lib.rs b/crates/oxc_codegen/src/lib.rs index 36072583d..333a94c7c 100644 --- a/crates/oxc_codegen/src/lib.rs +++ b/crates/oxc_codegen/src/lib.rs @@ -519,6 +519,10 @@ impl<'a> Codegen<'a> { // Comment related impl<'a> Codegen<'a> { + fn preserve_annotate_comments(&self) -> bool { + self.comment_options.preserve_annotate_comments && !self.options.minify + } + /// Avoid issue related to rustc borrow checker . /// Since if you want to print a range of source code, you need to borrow the source code /// as immutable first, and call the [Self::print_str] which is a mutable borrow.