@@ -18,9 +18,8 @@ use rustc_hash::FxHashMap;
1818#[ cfg( feature = "cross_file_elision" ) ]
1919use super :: cross_file_elision:: CrossFileAnalyzer ;
2020use super :: decorator:: {
21- collect_all_class_decorator_spans, collect_constructor_decorator_spans,
22- collect_member_decorator_spans, extract_component_metadata, find_component_decorator,
23- find_component_decorator_span,
21+ collect_constructor_decorator_spans, collect_member_decorator_spans,
22+ extract_component_metadata, find_component_decorator, find_component_decorator_span,
2423} ;
2524use super :: definition:: { const_value_to_expression, generate_component_definitions} ;
2625use super :: import_elision:: { ImportElisionAnalyzer , filter_imports} ;
@@ -791,13 +790,10 @@ pub fn transform_angular_file(
791790 ) ;
792791 }
793792
794- // Track ALL class decorator spans for removal (Angular + non-Angular).
795- // Non-Angular decorators (e.g. @UntilDestroy()) must also be removed,
796- // otherwise they end up decorating the compiled output which is invalid JS.
797- collect_all_class_decorator_spans (
798- class,
799- & mut decorator_spans_to_remove,
800- ) ;
793+ // Track the decorator span to remove
794+ if let Some ( span) = find_component_decorator_span ( class) {
795+ decorator_spans_to_remove. push ( span) ;
796+ }
801797 // Collect constructor parameter decorators (@Optional, @Inject, etc.)
802798 collect_constructor_decorator_spans (
803799 class,
@@ -931,8 +927,10 @@ pub fn transform_angular_file(
931927 if let Some ( mut directive_metadata) =
932928 extract_directive_metadata ( allocator, class, implicit_standalone)
933929 {
934- // Track ALL class decorator spans for removal (Angular + non-Angular)
935- collect_all_class_decorator_spans ( class, & mut decorator_spans_to_remove) ;
930+ // Track decorator span for removal
931+ if let Some ( span) = find_directive_decorator_span ( class) {
932+ decorator_spans_to_remove. push ( span) ;
933+ }
936934 // Collect constructor parameter decorators (@Optional, @Inject, etc.)
937935 collect_constructor_decorator_spans ( class, & mut decorator_spans_to_remove) ;
938936 // Collect member decorators (@Input, @Output, @HostBinding, etc.)
@@ -983,8 +981,10 @@ pub fn transform_angular_file(
983981 // - ɵprov: Provider metadata for Angular's DI system
984982 // - ɵfac: Factory function to instantiate the class
985983
986- // Track ALL class decorator spans for removal (Angular + non-Angular)
987- collect_all_class_decorator_spans ( class, & mut decorator_spans_to_remove) ;
984+ // Track decorator span for removal
985+ if let Some ( span) = find_injectable_decorator_span ( class) {
986+ decorator_spans_to_remove. push ( span) ;
987+ }
988988 // Collect constructor parameter decorators (@Optional, @Inject, etc.)
989989 collect_constructor_decorator_spans ( class, & mut decorator_spans_to_remove) ;
990990
@@ -1035,8 +1035,10 @@ pub fn transform_angular_file(
10351035 // - ɵpipe: Pipe definition for Angular's pipe system
10361036 // - ɵfac: Factory function for dependency injection (when pipe has constructor deps)
10371037
1038- // Track ALL class decorator spans for removal (Angular + non-Angular)
1039- collect_all_class_decorator_spans ( class, & mut decorator_spans_to_remove) ;
1038+ // Track decorator span for removal
1039+ if let Some ( span) = find_pipe_decorator_span ( class) {
1040+ decorator_spans_to_remove. push ( span) ;
1041+ }
10401042 // Collect constructor parameter decorators (@Optional, @Inject, etc.)
10411043 collect_constructor_decorator_spans ( class, & mut decorator_spans_to_remove) ;
10421044
@@ -1081,8 +1083,10 @@ pub fn transform_angular_file(
10811083 // - ɵfac: Factory function for instantiation (with constructor dependencies)
10821084 // - ɵinj: Injector definition with providers and imports
10831085
1084- // Track ALL class decorator spans for removal (Angular + non-Angular)
1085- collect_all_class_decorator_spans ( class, & mut decorator_spans_to_remove) ;
1086+ // Track decorator span for removal
1087+ if let Some ( span) = find_ng_module_decorator_span ( class) {
1088+ decorator_spans_to_remove. push ( span) ;
1089+ }
10861090 // Collect constructor parameter decorators (@Optional, @Inject, etc.)
10871091 collect_constructor_decorator_spans ( class, & mut decorator_spans_to_remove) ;
10881092
@@ -1165,22 +1169,25 @@ pub fn transform_angular_file(
11651169 _ => None ,
11661170 } ;
11671171 if let Some ( class) = class {
1168- // Check if this is an Angular-decorated class (component, directive, etc.)
1169- // and collect ALL decorator spans for removal (Angular + non-Angular)
1170- let is_component = find_component_decorator_span ( class) . is_some ( ) ;
1171- let is_directive = !is_component && find_directive_decorator_span ( class) . is_some ( ) ;
1172- let is_angular_class = is_component
1173- || is_directive
1174- || find_injectable_decorator_span ( class) . is_some ( )
1175- || find_pipe_decorator_span ( class) . is_some ( )
1176- || find_ng_module_decorator_span ( class) . is_some ( ) ;
1177-
1178- if is_angular_class {
1179- collect_all_class_decorator_spans ( class, & mut new_decorator_spans) ;
1172+ // Check for component, directive, injectable, pipe, or ngmodule decorators
1173+ // and collect associated parameter/member decorator spans
1174+ if let Some ( span) = find_component_decorator_span ( class) {
1175+ new_decorator_spans. push ( span) ;
1176+ collect_constructor_decorator_spans ( class, & mut new_decorator_spans) ;
1177+ collect_member_decorator_spans ( class, & mut new_decorator_spans) ;
1178+ } else if let Some ( span) = find_directive_decorator_span ( class) {
1179+ new_decorator_spans. push ( span) ;
1180+ collect_constructor_decorator_spans ( class, & mut new_decorator_spans) ;
1181+ collect_member_decorator_spans ( class, & mut new_decorator_spans) ;
1182+ } else if let Some ( span) = find_injectable_decorator_span ( class) {
1183+ new_decorator_spans. push ( span) ;
1184+ collect_constructor_decorator_spans ( class, & mut new_decorator_spans) ;
1185+ } else if let Some ( span) = find_pipe_decorator_span ( class) {
1186+ new_decorator_spans. push ( span) ;
1187+ collect_constructor_decorator_spans ( class, & mut new_decorator_spans) ;
1188+ } else if let Some ( span) = find_ng_module_decorator_span ( class) {
1189+ new_decorator_spans. push ( span) ;
11801190 collect_constructor_decorator_spans ( class, & mut new_decorator_spans) ;
1181- if is_component || is_directive {
1182- collect_member_decorator_spans ( class, & mut new_decorator_spans) ;
1183- }
11841191 }
11851192 }
11861193 }
0 commit comments