@@ -232,7 +232,7 @@ export default class Module {
232232 private astContext ! : AstContext ;
233233 private context : string ;
234234 private customTransformCache ! : boolean ;
235- private defaultExport : ExportDefaultVariable | null | undefined = null ;
235+ private defaultExport : Variable | null | undefined = null ;
236236 private esTreeAst ! : acorn . Node ;
237237 private exportAllModules : ( Module | ExternalModule ) [ ] = [ ] ;
238238 private exportNamesByVariable : Map < Variable , string [ ] > | null = null ;
@@ -324,7 +324,7 @@ export default class Module {
324324 getDefaultExport ( ) {
325325 if ( this . defaultExport === null ) {
326326 this . defaultExport = undefined ;
327- this . defaultExport = this . getVariableForExportName ( 'default' ) as ExportDefaultVariable ;
327+ this . defaultExport = this . getVariableForExportName ( 'default' ) ;
328328 }
329329 if ( ! this . defaultExport ) {
330330 return error ( {
@@ -339,21 +339,23 @@ export default class Module {
339339 getDependenciesToBeIncluded ( ) : Set < Module | ExternalModule > {
340340 if ( this . relevantDependencies ) return this . relevantDependencies ;
341341 const relevantDependencies = new Set < Module | ExternalModule > ( ) ;
342- for ( const variable of this . imports ) {
343- relevantDependencies . add (
344- variable instanceof SyntheticNamedExportVariable
345- ? variable . getOriginalVariable ( ) . module !
346- : variable . module !
347- ) ;
342+ for ( let variable of this . imports ) {
343+ if ( variable instanceof SyntheticNamedExportVariable ) {
344+ variable = variable . getBaseVariable ( ) ;
345+ } else if ( variable instanceof ExportDefaultVariable ) {
346+ variable = variable . getOriginalVariable ( ) ;
347+ }
348+ relevantDependencies . add ( variable . module ! ) ;
348349 }
349350 if ( this . isEntryPoint || this . dynamicallyImportedBy . length > 0 || this . graph . preserveModules ) {
350351 for ( const exportName of [ ...this . getReexports ( ) , ...this . getExports ( ) ] ) {
351- const variable = this . getVariableForExportName ( exportName ) ;
352- relevantDependencies . add (
353- variable instanceof SyntheticNamedExportVariable
354- ? variable . getOriginalVariable ( ) . module !
355- : variable . module !
356- ) ;
352+ let variable = this . getVariableForExportName ( exportName ) ;
353+ if ( variable instanceof SyntheticNamedExportVariable ) {
354+ variable = variable . getBaseVariable ( ) ;
355+ } else if ( variable instanceof ExportDefaultVariable ) {
356+ variable = variable . getOriginalVariable ( ) ;
357+ }
358+ relevantDependencies . add ( variable . module ! ) ;
357359 }
358360 }
359361 if ( this . graph . treeshakingOptions ) {
@@ -402,7 +404,10 @@ export default class Module {
402404 }
403405 const exportNamesByVariable : Map < Variable , string [ ] > = new Map ( ) ;
404406 for ( const exportName of this . getAllExportNames ( ) ) {
405- const tracedVariable = this . getVariableForExportName ( exportName ) ;
407+ let tracedVariable = this . getVariableForExportName ( exportName ) ;
408+ if ( tracedVariable instanceof ExportDefaultVariable ) {
409+ tracedVariable = tracedVariable . getOriginalVariable ( ) ;
410+ }
406411 if (
407412 ! tracedVariable ||
408413 ! ( tracedVariable . included || tracedVariable instanceof ExternalVariable )
0 commit comments