mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(codegen): do not print comments when --minify
This commit is contained in:
parent
0410314278
commit
7b1546bb66
2 changed files with 6 additions and 2 deletions
|
|
@ -50,7 +50,7 @@ impl<'a> Codegen<'a> {
|
||||||
&mut self,
|
&mut self,
|
||||||
node_start: u32,
|
node_start: u32,
|
||||||
) -> Vec<AnnotationComment> {
|
) -> Vec<AnnotationComment> {
|
||||||
if !self.comment_options.preserve_annotate_comments {
|
if !self.preserve_annotate_comments() {
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
let mut latest_comment_start = node_start;
|
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) {
|
pub(crate) fn gen_comments(&mut self, node_start: u32) {
|
||||||
if !self.comment_options.preserve_annotate_comments {
|
if !self.preserve_annotate_comments() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut annotation_kind_set = AnnotationKind::empty();
|
let mut annotation_kind_set = AnnotationKind::empty();
|
||||||
|
|
|
||||||
|
|
@ -519,6 +519,10 @@ impl<'a> Codegen<'a> {
|
||||||
|
|
||||||
// Comment related
|
// Comment related
|
||||||
impl<'a> Codegen<'a> {
|
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 .
|
/// 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
|
/// 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.
|
/// as immutable first, and call the [Self::print_str] which is a mutable borrow.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue