import * as t from '@babel/types' ; import type { Metadata } from '../../../../types' ; import { getDefaultExport , getNamedExport } from '../../../traversers' ; import { createResultPair } from '../../common' ; export const evaluateNamespaceImportPath = ( expression , file , meta , exportName ) : ReturnType < typeof createResultPair > => { const result = exportName === 'default' ? getDefaultExport ( file ) : getNamedExport ( file , exportName ) ; if ( result ) { const { node , path } = result ; const updatedMeta = { ... meta , parentPath : path , ownPath : meta . parentPath } ; const { parentPath } = updatedMeta ; if ( exportName === 'default' && ! parentPath . scope . getOwnBinding ( 'default' ) ) { parentPath . scope . push ( { id : t . identifier ( 'default' ) , init : node as t . Expression , kind : 'const' , } ) ; } return createResultPair ( node as t . Expression , updatedMeta ) ; } return createResultPair ( expression , meta ) ; } ;