Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/pack-scoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ async function getDistTagsFromPackageJson(
): Promise<Map<string, DistTags>> {
const packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf-8'));
return new Map<string, DistTags>(
newModuleNames.map((m) => {
newModuleNames.flatMap((m) => {
const distTags = packageJson.dependencies[m];
if (distTags) {
return [m, { beta: distTags }];
return [[m, { beta: distTags }]];
}
return [m, { beta: '0.0.0' }];
return [];
})
);
}
Expand All @@ -86,7 +86,11 @@ async function getDistTagsForModuleNamesCached(
): Promise<Map<string, DistTags>> {
if (params.sourceFile) {
if (params.sourceFile.endsWith('package.json')) {
return getDistTagsFromPackageJson(newModuleNames, params.sourceFile);
const distTagsFromPackageJson = await getDistTagsFromPackageJson(newModuleNames, params.sourceFile);
const remainingNames = newModuleNames.filter((m) => !distTagsFromPackageJson.has(m));
console.log(`Getting dist tags for ${remainingNames.length} modules from npm`);
const distTagsByModuleName = await getDistTagsForModuleNames(remainingNames);
return new Map<string, DistTags>([...distTagsFromPackageJson.entries(), ...distTagsByModuleName.entries()]);
}
}

Expand Down