@@ -533,12 +533,15 @@ export default class Module {
533533 const foundNamespaceReexport =
534534 name in this . namespaceReexportsByName
535535 ? this . namespaceReexportsByName [ name ]
536- : ( this . namespaceReexportsByName [ name ] = this . getVariableFromNamespaceReexports (
536+ : this . getVariableFromNamespaceReexports (
537537 name ,
538538 importerForSideEffects ,
539539 searchedNamesAndModules ,
540540 skipExternalNamespaceReexports
541- ) ) ;
541+ ) ;
542+ if ( ! skipExternalNamespaceReexports ) {
543+ this . namespaceReexportsByName [ name ] = foundNamespaceReexport ;
544+ }
542545 if ( foundNamespaceReexport ) {
543546 return foundNamespaceReexport ;
544547 }
@@ -1012,8 +1015,18 @@ export default class Module {
10121015 skipExternalNamespaceReexports = false
10131016 ) : Variable | null {
10141017 let foundSyntheticDeclaration : SyntheticNamedExportVariable | null = null ;
1015- const skipExternalNamespaceValues = new Set ( [ true , skipExternalNamespaceReexports ] ) ;
1016- for ( const skipExternalNamespaces of skipExternalNamespaceValues ) {
1018+ const skipExternalNamespaceValues = [ { searchedNamesAndModules, skipExternalNamespaces : true } ] ;
1019+ if ( ! skipExternalNamespaceReexports ) {
1020+ const clonedSearchedNamesAndModules = new Map < string , Set < Module | ExternalModule > > ( ) ;
1021+ for ( const [ name , modules ] of searchedNamesAndModules || [ ] ) {
1022+ clonedSearchedNamesAndModules . set ( name , new Set ( modules ) ) ;
1023+ }
1024+ skipExternalNamespaceValues . push ( {
1025+ searchedNamesAndModules : clonedSearchedNamesAndModules ,
1026+ skipExternalNamespaces : false
1027+ } ) ;
1028+ }
1029+ for ( const { skipExternalNamespaces, searchedNamesAndModules } of skipExternalNamespaceValues ) {
10171030 const foundDeclarations = new Set < Variable > ( ) ;
10181031 for ( const module of this . exportAllModules ) {
10191032 if ( module instanceof Module || ! skipExternalNamespaces ) {
0 commit comments