Skip to content

Commit 3fe9548

Browse files
OttoAllmendingerllm-git
andcommitted
fix(scripts): fix dist tags for modules not in package.json
Previously, modules not in package.json weren't included in the dist tags map. Now we filter the missing modules and fetch their dist tags from npm. Issue: BTC-2732 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent 994d837 commit 3fe9548

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

scripts/pack-scoped.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)