Skip to content

Commit c8a0946

Browse files
committed
save
1 parent 1567c3d commit c8a0946

95 files changed

Lines changed: 1651 additions & 173588 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_angular_compiler/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ rustc-hash = { workspace = true }
2727
lazy-regex = { workspace = true }
2828
indexmap = { workspace = true }
2929
oxc_resolver = { version = "11", optional = true }
30+
pathdiff = { version = "0.2", optional = true }
3031

3132
[features]
3233
default = []
33-
cross_file_elision = ["oxc_resolver"]
34+
cross_file_elision = ["oxc_resolver", "pathdiff"]
3435

3536
[dev-dependencies]
3637
insta = { workspace = true, features = ["glob"] }

crates/oxc_angular_compiler/src/component/cross_file_elision.rs

Lines changed: 346 additions & 8 deletions
Large diffs are not rendered by default.

crates/oxc_angular_compiler/src/component/decorator.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,48 @@ pub fn collect_member_decorator_spans(class: &Class<'_>, spans: &mut std::vec::V
10881088
}
10891089
}
10901090

1091+
/// Collect spans of uninitialized class field declarations for stripping.
1092+
///
1093+
/// TypeScript class field declarations like `name: string;` without initializers are
1094+
/// type-only annotations that have no runtime effect. They should be stripped from
1095+
/// the output to match TypeScript's emit behavior.
1096+
///
1097+
/// Only collects:
1098+
/// - Non-static property definitions without an initializer (e.g., `name: string;`)
1099+
///
1100+
/// Does NOT collect:
1101+
/// - Fields with initializers (e.g., `name = 'value';`) - these have runtime values
1102+
/// - Static fields (e.g., `static version: string;`) - handled separately
1103+
/// - Methods or accessors - they have runtime bodies
1104+
/// - Decorated fields - Angular may need the field structure
1105+
///
1106+
/// These spans are used by `transform.rs` to remove the declarations from the
1107+
/// source text during transformation.
1108+
pub fn collect_uninitialized_field_spans(class: &Class<'_>, spans: &mut std::vec::Vec<Span>) {
1109+
for element in &class.body.body {
1110+
if let ClassElement::PropertyDefinition(prop) = element {
1111+
// Skip static fields - they're handled differently
1112+
if prop.r#static {
1113+
continue;
1114+
}
1115+
1116+
// Skip fields with initializers - they have runtime values
1117+
if prop.value.is_some() {
1118+
continue;
1119+
}
1120+
1121+
// Skip decorated fields - Angular may need them
1122+
if !prop.decorators.is_empty() {
1123+
continue;
1124+
}
1125+
1126+
// This is an uninitialized, non-static, non-decorated field declaration
1127+
// (e.g., `name: string;`) - it should be stripped
1128+
spans.push(prop.span);
1129+
}
1130+
}
1131+
}
1132+
10911133
#[cfg(test)]
10921134
mod tests {
10931135
use super::*;
@@ -1109,7 +1151,7 @@ mod tests {
11091151
let parser_ret = Parser::new(&allocator, code, source_type).parse();
11101152

11111153
// Build import map from the program body
1112-
let import_map = build_import_map(&parser_ret.program.body);
1154+
let import_map = build_import_map(&allocator, &parser_ret.program.body, None);
11131155

11141156
// Find the first class declaration (handles plain, export default, and export named)
11151157
let mut found_metadata = None;

0 commit comments

Comments
 (0)