From 3fe954893ba0e7780436f183881c7022b1389d4c Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Mon, 17 Nov 2025 13:10:02 +0100 Subject: [PATCH] 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 --- scripts/pack-scoped.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/pack-scoped.ts b/scripts/pack-scoped.ts index 4259622868..4141ac3675 100644 --- a/scripts/pack-scoped.ts +++ b/scripts/pack-scoped.ts @@ -65,12 +65,12 @@ async function getDistTagsFromPackageJson( ): Promise> { const packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf-8')); return new Map( - 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 []; }) ); } @@ -86,7 +86,11 @@ async function getDistTagsForModuleNamesCached( ): Promise> { 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([...distTagsFromPackageJson.entries(), ...distTagsByModuleName.entries()]); } }