@@ -65,12 +65,12 @@ async function getDistTagsFromPackageJson(
6565) : Promise < Map < string , DistTags > > {
6666 const packageJson = JSON . parse ( await fs . promises . readFile ( packageJsonPath , 'utf-8' ) ) ;
6767 return new Map < string , DistTags > (
68- newModuleNames . map ( ( m ) => {
68+ newModuleNames . flatMap ( ( m ) => {
6969 const distTags = packageJson . dependencies [ m ] ;
7070 if ( distTags ) {
71- return [ m , { beta : distTags } ] ;
71+ return [ [ m , { beta : distTags } ] ] ;
7272 }
73- return [ m , { beta : '0.0.0' } ] ;
73+ return [ ] ;
7474 } )
7575 ) ;
7676}
@@ -86,7 +86,11 @@ async function getDistTagsForModuleNamesCached(
8686) : Promise < Map < string , DistTags > > {
8787 if ( params . sourceFile ) {
8888 if ( params . sourceFile . endsWith ( 'package.json' ) ) {
89- return getDistTagsFromPackageJson ( newModuleNames , params . sourceFile ) ;
89+ const distTagsFromPackageJson = await getDistTagsFromPackageJson ( newModuleNames , params . sourceFile ) ;
90+ const remainingNames = newModuleNames . filter ( ( m ) => ! distTagsFromPackageJson . has ( m ) ) ;
91+ console . log ( `Getting dist tags for ${ remainingNames . length } modules from npm` ) ;
92+ const distTagsByModuleName = await getDistTagsForModuleNames ( remainingNames ) ;
93+ return new Map < string , DistTags > ( [ ...distTagsFromPackageJson . entries ( ) , ...distTagsByModuleName . entries ( ) ] ) ;
9094 }
9195 }
9296
0 commit comments