@@ -651,48 +651,45 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
651651 }
652652
653653 // Try to find all known exports of the entry module
654- outer: for ( const exportInfo of exportInfos ) {
654+ for ( const exportInfo of exportInfos ) {
655655 if ( ! exportInfo . provided ) continue ;
656656
657657 const originalName = exportInfo . name ;
658658 // Skip rendering the default export in some cases
659659 if ( skipRenderDefaultExport && originalName === "default" ) continue ;
660660
661661 // Try to find all exports from the reexported modules
662- const target = exportInfo . findTarget ( moduleGraph , ( _m ) => true ) ;
663- // A namespace object target (`export * as ns from "./module"`) has no
664- // export name, so there is nothing that could be missing
665- if ( target && target . export ) {
666- const targetExport = target . export [ 0 ] ;
667- const reexportsInfo = moduleGraph . getExportsInfo ( target . module ) ;
668- for ( const reexportInfo of reexportsInfo . orderedExports ) {
669- if (
670- reexportInfo . provided === false &&
671- reexportInfo . name !== "default" &&
672- reexportInfo . name === targetExport
673- ) {
674- continue outer;
675- }
676- }
662+ const target = exportInfo . getTarget ( moduleGraph ) ;
663+
664+ // A re-export is provided even when its target lacks the export, and
665+ // the path can end in a property access, so every name is looked up.
666+ if (
667+ target &&
668+ target . export &&
669+ target . export [ target . export . length - 1 ] !== "default" &&
670+ moduleGraph
671+ . getExportsInfo ( target . module )
672+ . isExportProvided ( target . export ) === false
673+ ) {
674+ continue ;
677675 }
678676
679- const externalTarget = exportInfo . getTarget ( moduleGraph ) ;
680677 if (
681- externalTarget &&
682- externalTarget . module instanceof ExternalModule &&
683- externalTarget . export &&
684- externalTarget . export . length === 1 &&
685- codeGenerationResults . has ( externalTarget . module , chunk . runtime )
678+ target &&
679+ target . module instanceof ExternalModule &&
680+ target . export &&
681+ target . export . length === 1 &&
682+ codeGenerationResults . has ( target . module , chunk . runtime )
686683 ) {
687684 const reexport = codeGenerationResults . getData (
688- externalTarget . module ,
685+ target . module ,
689686 chunk . runtime ,
690687 "externalReexport"
691688 ) ;
692689 if ( reexport ) {
693690 if ( ! bindingsTakenOver ) needExportsDeclaration = true ;
694691 result . add (
695- `export { ${ toExportName ( externalTarget . export [ 0 ] ) } as ${ toExportName ( originalName ) } } ${ reexport } ;\n`
692+ `export { ${ toExportName ( target . export [ 0 ] ) } as ${ toExportName ( originalName ) } } ${ reexport } ;\n`
696693 ) ;
697694 alreadyRenderedExports . add ( originalName ) ;
698695 continue ;
0 commit comments