@@ -172,6 +172,12 @@ impl CompiledTransform {
172172 }
173173 imports. css_map . as_mut ( ) . unwrap ( ) . push ( local_name) ;
174174 }
175+ "styled" => {
176+ if imports. styled . is_none ( ) {
177+ imports. styled = Some ( Vec :: new ( ) ) ;
178+ }
179+ imports. styled . as_mut ( ) . unwrap ( ) . push ( local_name) ;
180+ }
175181 _ => {
176182 should_remove_import = false ;
177183 }
@@ -312,6 +318,27 @@ impl VisitMut for CompiledTransform {
312318 }
313319
314320 fn visit_mut_call_expr ( & mut self , n : & mut CallExpr ) {
321+ // Error on any styled usage (styled.tag`...` or styled(tag)(...))
322+ if let Some ( ref imports) = self . state . compiled_imports {
323+ if let Some ( ref styled_locals) = imports. styled {
324+ // Check for styled("div")(...) pattern or styled.tag(...) pattern
325+ let is_styled_call = match & n. callee {
326+ Callee :: Expr ( expr) => match expr. as_ref ( ) {
327+ Expr :: Ident ( ident) => styled_locals. contains ( & ident. sym . to_string ( ) ) ,
328+ Expr :: Member ( MemberExpr { obj, .. } ) => match obj. as_ref ( ) {
329+ Expr :: Ident ( ident) => styled_locals. contains ( & ident. sym . to_string ( ) ) ,
330+ _ => false ,
331+ } ,
332+ _ => false ,
333+ } ,
334+ _ => false ,
335+ } ;
336+ if is_styled_call {
337+ panic ! ( "styled API is not supported by the SWC plugin. Please use css/cssMap or the Babel plugin." ) ;
338+ }
339+ }
340+ }
341+
315342 let mut handled_css_prop = false ;
316343 let is_react_jsx_like = match & n. callee {
317344 Callee :: Expr ( callee_expr) => match callee_expr. as_ref ( ) {
@@ -398,6 +425,20 @@ impl VisitMut for CompiledTransform {
398425 }
399426
400427 fn visit_mut_expr ( & mut self , n : & mut Expr ) {
428+ // Error on any styled tagged template usage like styled.div`...`
429+ if let Expr :: TaggedTpl ( tagged) = n {
430+ if let Expr :: Member ( MemberExpr { obj, .. } ) = tagged. tag . as_ref ( ) {
431+ if let Expr :: Ident ( ident) = obj. as_ref ( ) {
432+ if let Some ( ref imports) = self . state . compiled_imports {
433+ if let Some ( ref styled_locals) = imports. styled {
434+ if styled_locals. contains ( & ident. sym . to_string ( ) ) {
435+ panic ! ( "styled API is not supported by the SWC plugin. Please use css/cssMap or the Babel plugin." ) ;
436+ }
437+ }
438+ }
439+ }
440+ }
441+ }
401442 if let Expr :: Call ( call) = n {
402443 if visitors:: css:: is_css_call ( call, & self . state ) {
403444 if self . options . strict_mode {
0 commit comments