diff --git a/crates/oxc/src/compiler.rs b/crates/oxc/src/compiler.rs index 4bad3a894..131456e9e 100644 --- a/crates/oxc/src/compiler.rs +++ b/crates/oxc/src/compiler.rs @@ -65,10 +65,6 @@ pub trait CompilerInterface { Some(CodegenOptions::default()) } - fn remove_whitespace(&self) -> bool { - false - } - fn check_semantic_error(&self) -> bool { true } @@ -215,9 +211,8 @@ pub trait CompilerInterface { options: CodegenOptions, ) -> String { let comment_options = CommentOptions { preserve_annotate_comments: true }; - CodeGenerator::new() - .with_options(CodegenOptions { minify: self.remove_whitespace(), ..options }) + .with_options(options) .enable_comment(source_text, trivias.clone(), comment_options) .build(program) .source_text diff --git a/crates/oxc_codegen/src/lib.rs b/crates/oxc_codegen/src/lib.rs index 6c6b23d39..8e0c16c81 100644 --- a/crates/oxc_codegen/src/lib.rs +++ b/crates/oxc_codegen/src/lib.rs @@ -41,6 +41,7 @@ pub struct CodegenOptions { /// Use single quotes instead of double quotes. pub single_quote: bool, + /// Remove whitespace. pub minify: bool, } diff --git a/tasks/coverage/src/driver.rs b/tasks/coverage/src/driver.rs index dfa6f168e..8f329414c 100644 --- a/tasks/coverage/src/driver.rs +++ b/tasks/coverage/src/driver.rs @@ -50,11 +50,8 @@ impl CompilerInterface for Driver { } fn codegen_options(&self) -> Option { - self.codegen.then(CodegenOptions::default) - } - - fn remove_whitespace(&self) -> bool { - self.remove_whitespace + self.codegen + .then(|| CodegenOptions { minify: self.remove_whitespace, ..CodegenOptions::default() }) } fn handle_errors(&mut self, errors: Vec) {