@@ -174,15 +174,6 @@ export function makePlugin<EnvSpecificOptions>(loadOptions: (opts: EnvSpecificOp
174
174
} ,
175
175
} ,
176
176
177
- Identifier ( path : NodePath < t . Identifier > ) {
178
- if ( path . node . name ) {
179
- const binding = path . scope . getBinding ( path . node . name ) ;
180
- if ( binding && binding . path . node !== path . parent ) {
181
- binding . reference ( path ) ;
182
- }
183
- }
184
- } ,
185
-
186
177
TaggedTemplateExpression (
187
178
path : NodePath < t . TaggedTemplateExpression > ,
188
179
state : State < EnvSpecificOptions >
@@ -545,6 +536,7 @@ function insertCompiledTemplate<EnvSpecificOptions>(
545
536
) ;
546
537
}
547
538
target . replaceWith ( expression ) ;
539
+ target . scope . crawl ( ) ;
548
540
}
549
541
550
542
function insertTransformedTemplate < EnvSpecificOptions > (
@@ -569,6 +561,7 @@ function insertTransformedTemplate<EnvSpecificOptions>(
569
561
) ;
570
562
let ast = preprocess ( template , { ...options , mode : 'codemod' } ) ;
571
563
let transformed = print ( ast , { entityEncoding : 'raw' } ) ;
564
+ let needsScopeCrawl = false ;
572
565
if ( target . isCallExpression ( ) ) {
573
566
( target . get ( 'arguments.0' ) as NodePath < t . Node > ) . replaceWith ( t . stringLiteral ( transformed ) ) ;
574
567
if ( ! scopeLocals . isEmpty ( ) ) {
@@ -577,6 +570,7 @@ function insertTransformedTemplate<EnvSpecificOptions>(
577
570
target . set ( 'callee' , precompileTemplate ( state . util , target ) ) ;
578
571
}
579
572
updateScope ( babel , target , scopeLocals ) ;
573
+ needsScopeCrawl = true ;
580
574
}
581
575
582
576
if ( formatOptions . rfc931Support === 'polyfilled' ) {
@@ -586,7 +580,7 @@ function insertTransformedTemplate<EnvSpecificOptions>(
586
580
removeEvalAndScope ( target ) ;
587
581
target . node . arguments = target . node . arguments . slice ( 0 , 2 ) ;
588
582
state . recursionGuard . add ( target . node ) ;
589
- target . replaceWith (
583
+ target = target . replaceWith (
590
584
t . callExpression ( state . util . import ( target , '@ember/component' , 'setComponentTemplate' ) , [
591
585
target . node ,
592
586
backingClass ?. node ??
@@ -600,7 +594,11 @@ function insertTransformedTemplate<EnvSpecificOptions>(
600
594
[ ]
601
595
) ,
602
596
] )
603
- ) ;
597
+ ) [ 0 ] ;
598
+ needsScopeCrawl = true ;
599
+ }
600
+ if ( needsScopeCrawl ) {
601
+ target . scope . crawl ( ) ;
604
602
}
605
603
} else {
606
604
if ( ! scopeLocals . isEmpty ( ) ) {
@@ -611,6 +609,7 @@ function insertTransformedTemplate<EnvSpecificOptions>(
611
609
t . callExpression ( precompileTemplate ( state . util , target ) , [ t . stringLiteral ( transformed ) ] )
612
610
) [ 0 ] ;
613
611
updateScope ( babel , newCall , scopeLocals ) ;
612
+ newCall . scope . crawl ( ) ;
614
613
} else {
615
614
( target . get ( 'quasi' ) . get ( 'quasis.0' ) as NodePath < t . TemplateElement > ) . replaceWith (
616
615
t . templateElement ( { raw : transformed } )
0 commit comments