@@ -26,6 +26,13 @@ module.exports = function (src) {
2626 dependencies [ dependency ] . importSpecifiers = [ importSpecifier ] ;
2727 }
2828 } ;
29+ const addExportedToImportSpecifier = ( name ) => {
30+ Object . keys ( dependencies ) . forEach ( ( dependency ) => {
31+ if ( ! dependencies [ dependency ] . importSpecifiers ) return ;
32+ const specifier = dependencies [ dependency ] . importSpecifiers . find ( i => i . name === name ) ;
33+ if ( specifier ) specifier . exported = true ;
34+ } ) ;
35+ } ;
2936
3037 if ( typeof src === 'undefined' ) {
3138 throw new Error ( 'src not given' ) ;
@@ -60,13 +67,21 @@ module.exports = function (src) {
6067 node . specifiers . forEach ( ( specifier ) => {
6168 const specifierValue = {
6269 isDefault : ! specifier . local || specifier . local . name === 'default' , // e.g. export { default as isArray } from './is-array';
63- name : specifier . exported . name
70+ name : specifier . exported . name ,
71+ exported : true
6472 } ;
6573 addImportSpecifier ( dependency , specifierValue ) ;
6674 } ) ;
6775 }
76+ } else if ( node . specifiers && node . specifiers . length ) {
77+ node . specifiers . forEach ( ( exportSpecifier ) => {
78+ addExportedToImportSpecifier ( exportSpecifier . exported . name ) ;
79+ } ) ;
6880 }
6981 break ;
82+ case 'ExportDefaultDeclaration' :
83+ addExportedToImportSpecifier ( node . declaration . name ) ;
84+ break ;
7085 case 'CallExpression' :
7186 if ( node . callee . type === 'Import' && node . arguments . length && node . arguments [ 0 ] . value ) {
7287 addDependency ( node . arguments [ 0 ] . value ) ;
0 commit comments