Skip to content

Commit 80ff8e5

Browse files
committed
fix changes
1 parent 5a8e807 commit 80ff8e5

File tree

3 files changed

+46
-53
lines changed

3 files changed

+46
-53
lines changed

Cargo.lock

+36-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/driver.rs

+7-21
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ use std::{
44
};
55

66
use oxc::{
7-
ast::{ast::Program, Trivias},
8-
codegen::{CodeGenerator, CodegenOptions, CodegenReturn, CommentOptions},
7+
codegen::{CodegenOptions, CodegenReturn},
98
diagnostics::OxcDiagnostic,
10-
mangler::{MangleOptions, Mangler},
9+
mangler::MangleOptions,
1110
minifier::CompressOptions,
1211
parser::ParseOptions,
1312
span::SourceType,
@@ -82,24 +81,11 @@ impl CompilerInterface for Driver {
8281
}
8382

8483
fn codegen_options(&self) -> Option<CodegenOptions> {
85-
Some(CodegenOptions { minify: self.remove_whitespace, ..CodegenOptions::default() })
86-
}
87-
88-
fn codegen<'a>(
89-
&self,
90-
program: &Program<'a>,
91-
source_text: &'a str,
92-
_source_path: &Path,
93-
trivias: &Trivias,
94-
mangler: Option<Mangler>,
95-
options: CodegenOptions,
96-
) -> CodegenReturn {
97-
let mut codegen = CodeGenerator::new().with_options(options).with_mangler(mangler);
98-
if self.compress_options().is_none() {
99-
let comment_options = CommentOptions { preserve_annotate_comments: true };
100-
codegen = codegen.enable_comment(source_text, trivias.clone(), comment_options);
101-
};
102-
codegen.build(program)
84+
Some(CodegenOptions {
85+
minify: self.remove_whitespace,
86+
source_map_path: self.compress_options().is_none().then(|| self.path.clone()),
87+
..CodegenOptions::default()
88+
})
10389
}
10490
}
10591

src/isolated_declarations/mod.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::NodeModulesRunner;
77

88
use oxc::{
99
allocator::Allocator,
10-
codegen::{Codegen, CommentOptions},
10+
codegen::Codegen,
1111
isolated_declarations::{IsolatedDeclarations, IsolatedDeclarationsOptions},
1212
parser::Parser,
1313
span::SourceType,
@@ -56,21 +56,15 @@ pub fn test(path_to_vue: Option<PathBuf>) -> ExitCode {
5656
}
5757

5858
let source_text = fs::read_to_string(path).unwrap();
59-
let comment_options = CommentOptions { preserve_annotate_comments: false };
6059
let printed = {
6160
let allocator = Allocator::default();
6261
let ret = Parser::new(&allocator, &source_text, source_type).parse();
6362
let id = IsolatedDeclarations::new(
6463
&allocator,
65-
&source_text,
66-
&ret.trivias,
6764
IsolatedDeclarationsOptions { strip_internal: true },
6865
)
6966
.build(&ret.program);
70-
Codegen::new()
71-
.enable_comment(&source_text, ret.trivias, comment_options)
72-
.build(&id.program)
73-
.code
67+
Codegen::new().build(&id.program).code
7468
};
7569

7670
let root_str = root.to_string_lossy();
@@ -85,10 +79,7 @@ pub fn test(path_to_vue: Option<PathBuf>) -> ExitCode {
8579
let source_text =
8680
fs::read_to_string(&read_path).unwrap_or_else(|e| panic!("{e}\n{read_path:?}"));
8781
let ret = Parser::new(&allocator, &source_text, source_type).parse();
88-
Codegen::new()
89-
.enable_comment(&source_text, ret.trivias, comment_options)
90-
.build(&ret.program)
91-
.code
82+
Codegen::new().build(&ret.program).code
9283
};
9384

9485
if tsc_output.trim() != printed.trim() {

0 commit comments

Comments
 (0)