@@ -23,6 +23,7 @@ use super::metadata::{
2323 ViewEncapsulation ,
2424} ;
2525use super :: namespace_registry:: NamespaceRegistry ;
26+ use super :: transform:: TransformOptions ;
2627use crate :: directive:: {
2728 create_host_directive_mappings_array, create_inputs_literal, create_outputs_literal,
2829} ;
@@ -62,6 +63,7 @@ pub struct ComponentDefinitions<'a> {
6263pub fn generate_component_definitions < ' a > (
6364 allocator : & ' a Allocator ,
6465 metadata : & ComponentMetadata < ' a > ,
66+ options : & TransformOptions ,
6567 job : & mut ComponentCompilationJob < ' a > ,
6668 template_fn : FunctionExpr < ' a > ,
6769 host_binding_result : Option < HostBindingCompilationResult < ' a > > ,
@@ -79,6 +81,7 @@ pub fn generate_component_definitions<'a>(
7981 let cmp_definition = generate_cmp_definition (
8082 allocator,
8183 metadata,
84+ options,
8285 job,
8386 template_fn,
8487 host_binding_result,
@@ -109,6 +112,7 @@ pub fn generate_component_definitions<'a>(
109112fn generate_cmp_definition < ' a > (
110113 allocator : & ' a Allocator ,
111114 metadata : & ComponentMetadata < ' a > ,
115+ options : & TransformOptions ,
112116 job : & mut ComponentCompilationJob < ' a > ,
113117 template_fn : FunctionExpr < ' a > ,
114118 host_binding_result : Option < HostBindingCompilationResult < ' a > > ,
@@ -435,23 +439,17 @@ fn generate_cmp_definition<'a>(
435439 if !metadata. styles . is_empty ( ) {
436440 let mut style_entries: OxcVec < ' a , OutputExpression < ' a > > = OxcVec :: new_in ( allocator) ;
437441 for style in & metadata. styles {
438- // Apply CSS scoping for Emulated encapsulation
439- let style_value = if metadata. encapsulation == ViewEncapsulation :: Emulated {
440- // Use shim_css_text with %COMP% placeholder
441- // Angular's runtime will replace %COMP% with the actual component ID
442- let scoped = crate :: styles:: shim_css_text ( style. as_str ( ) , content_attr, host_attr) ;
443- // Skip empty styles
444- if scoped. trim ( ) . is_empty ( ) {
445- continue ;
446- }
447- Atom :: from_in ( scoped. as_str ( ) , allocator)
448- } else {
449- // For None/ShadowDom, use styles as-is
450- if style. trim ( ) . is_empty ( ) {
451- continue ;
452- }
453- style. clone ( )
454- } ;
442+ let style = crate :: styles:: finalize_component_style (
443+ style. as_str ( ) ,
444+ metadata. encapsulation == ViewEncapsulation :: Emulated ,
445+ content_attr,
446+ host_attr,
447+ options. minify_component_styles ,
448+ ) ;
449+ if style. trim ( ) . is_empty ( ) {
450+ continue ;
451+ }
452+ let style_value = Atom :: from_in ( style. as_str ( ) , allocator) ;
455453
456454 style_entries. push ( OutputExpression :: Literal ( Box :: new_in (
457455 LiteralExpr { value : LiteralValue :: String ( style_value) , source_span : None } ,
0 commit comments