diff --git a/Cargo.lock b/Cargo.lock index de09633c3..f2a5a9214 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1092,7 +1092,7 @@ dependencies = [ "oxc_parser", "oxc_resolver", "oxc_semantic", - "oxc_sourcemap", + "oxc_sourcemap 7.0.0", "oxc_span", "oxc_str", "oxc_transformer", @@ -1194,7 +1194,7 @@ dependencies = [ "oxc_data_structures", "oxc_index", "oxc_semantic", - "oxc_sourcemap", + "oxc_sourcemap 6.1.1", "oxc_span", "oxc_str", "oxc_syntax", @@ -1390,6 +1390,19 @@ dependencies = [ "serde_json", ] +[[package]] +name = "oxc_sourcemap" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3866f9075027840e0711b52e15d2e1ba076fc5f5f01c96eeedd26375410641" +dependencies = [ + "base64-simd 0.8.0", + "json-escape-simd", + "rustc-hash", + "serde", + "serde_json", +] + [[package]] name = "oxc_span" version = "0.133.0" diff --git a/Cargo.toml b/Cargo.toml index 469ca9986..7372a2313 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ oxc_napi = "0.133" oxc_parser = "0.133" oxc_semantic = "0.133" oxc_span = "0.133" -oxc_sourcemap = "6.0.1" +oxc_sourcemap = "7.0.0" oxc_str = "0.133" oxc_transformer = "0.133" oxc_codegen = "0.133" diff --git a/crates/oxc_angular_compiler/src/component/transform.rs b/crates/oxc_angular_compiler/src/component/transform.rs index dc548416b..fb460b9fd 100644 --- a/crates/oxc_angular_compiler/src/component/transform.rs +++ b/crates/oxc_angular_compiler/src/component/transform.rs @@ -334,7 +334,7 @@ pub struct TemplateCompileOutput { pub code: String, /// Source map (if sourcemap option was enabled). - pub map: Option, + pub map: Option, } impl TemplateCompileOutput { @@ -344,7 +344,7 @@ impl TemplateCompileOutput { } /// Create a new template compile output with code and source map. - pub fn with_source_map(code: String, map: Option) -> Self { + pub fn with_source_map(code: String, map: Option) -> Self { Self { code, map } } } diff --git a/crates/oxc_angular_compiler/src/output/emitter.rs b/crates/oxc_angular_compiler/src/output/emitter.rs index 2b0df6f95..908152a5b 100644 --- a/crates/oxc_angular_compiler/src/output/emitter.rs +++ b/crates/oxc_angular_compiler/src/output/emitter.rs @@ -229,7 +229,10 @@ impl EmitterContext { /// Returns `None` if no source file information was provided or no mappings exist. /// /// See: `packages/compiler/src/output/abstract_emitter.ts:126-184` - pub fn to_source_map(&self, generated_file: Option<&str>) -> Option { + pub fn to_source_map( + &self, + generated_file: Option<&str>, + ) -> Option { // Need source file to generate a source map let source_file = self.source_file.as_ref()?; let source_url = &source_file.url; @@ -297,7 +300,7 @@ impl EmitterContext { } } - if has_mappings { Some(builder.into_sourcemap()) } else { None } + if has_mappings { Some(builder.into_owned_sourcemap()) } else { None } } /// Generate source and source map together. @@ -307,7 +310,7 @@ impl EmitterContext { pub fn to_source_with_map( &self, generated_file: Option<&str>, - ) -> (String, Option) { + ) -> (String, Option) { (self.to_source(), self.to_source_map(generated_file)) } } @@ -408,7 +411,7 @@ impl JsEmitter { expr: &OutputExpression<'a>, source_file: Arc, generated_file: Option<&str>, - ) -> (String, Option) { + ) -> (String, Option) { let mut ctx = EmitterContext::with_source_file(source_file); self.visit_expression(expr, &mut ctx); ctx.to_source_with_map(generated_file) @@ -423,7 +426,7 @@ impl JsEmitter { stmts: &[OutputStatement<'a>], source_file: Arc, generated_file: Option<&str>, - ) -> (String, Option) { + ) -> (String, Option) { let mut ctx = EmitterContext::with_source_file(source_file); self.visit_all_statements(stmts, &mut ctx); ctx.to_source_with_map(generated_file) @@ -1640,7 +1643,7 @@ mod tests { let map = ctx.to_source_map(Some("test.js")).expect("should generate source map"); // Verify the source map has the expected structure - assert!(map.get_sources().any(|s| s.as_ref() == "test.ts")); + assert!(map.get_sources().any(|s| s == "test.ts")); assert!(map.get_tokens().count() > 0); }