@@ -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 >
@@ -455,13 +446,18 @@ function buildPrecompileOptions<EnvSpecificOptions>(
455
446
// if scope has different keys and values, this function will remap the keys to the values
456
447
// you can see an example of this in the test "correctly handles scope if it contains keys and values"
457
448
function remapIdentifiers ( ast : Babel . types . File , babel : typeof Babel , scopeLocals : ScopeLocals ) {
458
- if ( ! scopeLocals . needsRemapping ( ) ) {
459
- // do nothing if all keys are the same as their values
460
- return ;
461
- }
462
-
463
449
babel . traverse ( ast , {
464
450
Identifier ( path : NodePath < t . Identifier > ) {
451
+ if ( path . node . name ) {
452
+ const binding = path . scope . getBinding ( path . node . name ) ;
453
+ if ( binding && binding . path . node !== path . parent ) {
454
+ binding . reference ( path ) ;
455
+ }
456
+ }
457
+ if ( ! scopeLocals . needsRemapping ( ) ) {
458
+ // do nothing if all keys are the same as their values
459
+ return ;
460
+ }
465
461
if ( scopeLocals . has ( path . node . name ) && path . node . name !== scopeLocals . get ( path . node . name ) ) {
466
462
// replace the path only if the key is different from the value
467
463
path . replaceWith ( babel . types . identifier ( scopeLocals . get ( path . node . name ) ) ) ;
0 commit comments