@@ -496,13 +496,23 @@ function insertCompiledTemplate<EnvSpecificOptions>(
496
496
497
497
let expression = t . callExpression ( templateFactoryIdentifier , [ templateExpression ] ) ;
498
498
499
+ let assignment = target . parent ;
500
+ let assignmentName : string | null = null ;
501
+ if ( assignment . type === 'AssignmentExpression' && assignment . left . type === 'Identifier' ) {
502
+ assignmentName = assignment . left . name ;
503
+ }
504
+
505
+ if ( assignment . type === 'VariableDeclarator' && assignment . id . type === 'Identifier' ) {
506
+ assignmentName = assignment . id . name ;
507
+ }
508
+
499
509
if ( config . rfc931Support ) {
500
510
expression = t . callExpression ( i . import ( '@ember/component' , 'setComponentTemplate' ) , [
501
511
expression ,
502
512
backingClass ?. node ??
503
513
t . callExpression (
504
514
i . import ( '@ember/component/template-only' , 'default' , 'templateOnly' ) ,
505
- [ ]
515
+ [ '@ember/component/template-only' , assignmentName ]
506
516
) ,
507
517
] ) ;
508
518
}
@@ -606,14 +616,24 @@ function updateCallForm<EnvSpecificOptions>(
606
616
convertStrictMode ( babel , target ) ;
607
617
removeEvalAndScope ( target ) ;
608
618
target . node . arguments = target . node . arguments . slice ( 0 , 2 ) ;
619
+ let assignment = target . parent ;
620
+ let assignmentName : string | null = null ;
621
+ if ( assignment . type === 'AssignmentExpression' && assignment . left . type === 'Identifier' ) {
622
+ assignmentName = assignment . left . name ;
623
+ }
624
+
625
+ if ( assignment . type === 'VariableDeclarator' && assignment . id . type === 'Identifier' ) {
626
+ assignmentName = assignment . id . name ;
627
+ }
628
+
609
629
state . recursionGuard . add ( target . node ) ;
610
630
state . util . replaceWith ( target , ( i ) =>
611
631
babel . types . callExpression ( i . import ( '@ember/component' , 'setComponentTemplate' ) , [
612
632
target . node ,
613
633
backingClass ?. node ??
614
634
babel . types . callExpression (
615
635
i . import ( '@ember/component/template-only' , 'default' , 'templateOnly' ) ,
616
- [ ]
636
+ [ '@ember/component/template-only' , assignmentName ]
617
637
) ,
618
638
] )
619
639
) ;
0 commit comments