@@ -531,7 +531,9 @@ export function compileCodeSplitReferenceRoute(
531531 modified = true
532532
533533 // Track which variable declarations we've already processed to avoid duplicate processing
534- const processedVarDecls = new Set < babel . NodePath < t . VariableDeclaration > > ( )
534+ const processedVarDecls = new Set <
535+ babel . NodePath < t . VariableDeclaration >
536+ > ( )
535537
536538 sharedModuleLevelIdents . forEach ( ( identName ) => {
537539 const binding = programPath . scope . getBinding ( identName )
@@ -545,7 +547,8 @@ export function compileCodeSplitReferenceRoute(
545547 bindingPath . parentPath ?. isVariableDeclaration ( ) &&
546548 bindingPath . parentPath . parentPath ?. isProgram ( )
547549 ) {
548- const varDecl = bindingPath . parentPath as babel . NodePath < t . VariableDeclaration >
550+ const varDecl =
551+ bindingPath . parentPath as babel . NodePath < t . VariableDeclaration >
549552
550553 // Only export const/let declarations (not imports or functions)
551554 if (
@@ -566,7 +569,10 @@ export function compileCodeSplitReferenceRoute(
566569 const localDeclarators : Array < t . VariableDeclarator > = [ ]
567570
568571 declarators . forEach ( ( declarator ) => {
569- if ( t . isIdentifier ( declarator . id ) && sharedModuleLevelIdents . has ( declarator . id . name ) ) {
572+ if (
573+ t . isIdentifier ( declarator . id ) &&
574+ sharedModuleLevelIdents . has ( declarator . id . name )
575+ ) {
570576 sharedDeclarators . push ( declarator )
571577 knownExportedIdents . add ( declarator . id . name )
572578 opts . sharedExports ?. add ( declarator . id . name )
@@ -576,17 +582,35 @@ export function compileCodeSplitReferenceRoute(
576582 } )
577583
578584 // Replace with split declarations
579- if ( sharedDeclarators . length > 0 && localDeclarators . length > 0 ) {
585+ if (
586+ sharedDeclarators . length > 0 &&
587+ localDeclarators . length > 0
588+ ) {
580589 // Both shared and local declarators
581- const localVarDecl = t . variableDeclaration ( varDecl . node . kind , localDeclarators )
582- const sharedVarDecl = t . variableDeclaration ( varDecl . node . kind , sharedDeclarators )
583- const exportDecl = t . exportNamedDeclaration ( sharedVarDecl , [ ] )
590+ const localVarDecl = t . variableDeclaration (
591+ varDecl . node . kind ,
592+ localDeclarators ,
593+ )
594+ const sharedVarDecl = t . variableDeclaration (
595+ varDecl . node . kind ,
596+ sharedDeclarators ,
597+ )
598+ const exportDecl = t . exportNamedDeclaration (
599+ sharedVarDecl ,
600+ [ ] ,
601+ )
584602
585603 varDecl . replaceWithMultiple ( [ localVarDecl , exportDecl ] )
586604 } else if ( sharedDeclarators . length > 0 ) {
587605 // All declarators are shared
588- const sharedVarDecl = t . variableDeclaration ( varDecl . node . kind , sharedDeclarators )
589- const exportDecl = t . exportNamedDeclaration ( sharedVarDecl , [ ] )
606+ const sharedVarDecl = t . variableDeclaration (
607+ varDecl . node . kind ,
608+ sharedDeclarators ,
609+ )
610+ const exportDecl = t . exportNamedDeclaration (
611+ sharedVarDecl ,
612+ [ ] ,
613+ )
590614 varDecl . replaceWith ( exportDecl )
591615 }
592616 } else {
0 commit comments