Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
145e485
fix: show correct dependencies count
gameroman Feb 2, 2026
f05a7fc
fix: show correct dependencies count
gameroman Feb 2, 2026
dfc22b8
fix: show correct dependencies count
gameroman Feb 2, 2026
014ebea
fix: show correct dependencies count
gameroman Feb 2, 2026
52d5677
Merge branch 'fix-compare-deps' of https://github.com/gameroman/npmx.…
gameroman Feb 3, 2026
73a8d30
fix after rebase
gameroman Feb 3, 2026
c330cd0
wip
gameroman Feb 3, 2026
e8f0a33
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
62f2eae
Remove tests that rely on hard-coded values
gameroman Feb 3, 2026
4164058
address coderabbit's feedback
gameroman Feb 3, 2026
ed19aab
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
4ec6eed
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
dda8d69
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
93f3b70
Update usePackageComparison.ts
gameroman Feb 3, 2026
2557997
Merge branch 'fix-compare-deps' of https://github.com/gameroman/npmx.…
gameroman Feb 3, 2026
01c90eb
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
d149e56
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
3a4f470
fix: use approach from #868
gameroman Feb 3, 2026
3a6b34a
Merge branch 'fix-compare-deps' of https://github.com/gameroman/npmx.…
gameroman Feb 3, 2026
68d0786
Update usePackageComparison.ts
gameroman Feb 3, 2026
8adb836
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
3a536fa
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
3d7d799
Merge branch 'main' into fix-compare-deps
gameroman Feb 3, 2026
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
22 changes: 18 additions & 4 deletions app/composables/usePackageComparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import type {
import { encodePackageName } from '#shared/utils/npm'
import type { PackageAnalysisResponse } from './usePackageAnalysis'
import { isBinaryOnlyPackage } from '#shared/utils/binary-detection'
import { getDependencyCount } from '~/utils/npm/dependency-count'

export interface PackageComparisonData {
package: ComparisonPackage
downloads?: number
/** Package's own unpacked size (from dist.unpackedSize) */
packageSize?: number
/** Direct dependencies count */
directDeps: number
/** Install size data (fetched lazily) */
installSize?: {
selfSize: number
totalSize: number
/** Total dependency count */
dependencyCount: number
}
analysis?: PackageAnalysisResponse
Expand Down Expand Up @@ -109,6 +113,9 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
),
])

const pkg = usePackage(name, latestVersion)
const requestedVersion = pkg.data.value?.requestedVersion

const versionData = pkgData.versions[latestVersion]
const packageSize = versionData?.dist?.unpackedSize

Expand Down Expand Up @@ -139,6 +146,7 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
},
downloads: downloads?.downloads,
packageSize,
directDeps: getDependencyCount(requestedVersion ?? null),
installSize: undefined, // Will be filled in second pass
analysis: analysis ?? undefined,
vulnerabilities: {
Expand Down Expand Up @@ -360,12 +368,12 @@ function computeFacetValue(
}

case 'dependencies':
if (!data.installSize) return null
const depCount = data.installSize.dependencyCount
if (!data.directDeps) return null
const depCount = data.directDeps
return {
raw: depCount,
display: String(depCount),
status: depCount > 50 ? 'warning' : 'neutral',
status: depCount > 10 ? 'warning' : 'neutral',
}

case 'deprecated':
Expand All @@ -380,7 +388,13 @@ function computeFacetValue(

// Coming soon facets
case 'totalDependencies':
return null
if (!data.installSize) return null
const totalDepCount = data.installSize.dependencyCount
return {
raw: totalDepCount,
display: String(totalDepCount),
status: totalDepCount > 50 ? 'warning' : 'neutral',
}

default:
return null
Expand Down
6 changes: 1 addition & 5 deletions app/pages/package/[...package].vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { joinURL } from 'ufo'
import { areUrlsEquivalent } from '#shared/utils/url'
import { isEditableElement } from '~/utils/input'
import { formatBytes } from '~/utils/formatters'
import { getDependencyCount } from '~/utils/npm/dependency-count'
import { NuxtLink } from '#components'
import { useModal } from '~/composables/useModal'
import { useAtproto } from '~/composables/atproto/useAtproto'
Expand Down Expand Up @@ -300,11 +301,6 @@ function normalizeGitUrl(url: string): string {
.replace(/^git@github\.com:/, 'https://github.com/')
}

function getDependencyCount(version: PackumentVersion | null): number {
if (!version?.dependencies) return 0
return Object.keys(version.dependencies).length
}

// Check if a version has provenance/attestations
// The dist object may have attestations that aren't in the base type
function hasProvenance(version: PackumentVersion | null): boolean {
Expand Down
6 changes: 6 additions & 0 deletions app/utils/npm/dependency-count.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { PackumentVersion } from '#shared/types'

export function getDependencyCount(version: PackumentVersion | null): number {
if (!version?.dependencies) return 0
return Object.keys(version.dependencies).length
}
1 change: 0 additions & 1 deletion shared/types/comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const FACET_INFO: Record<ComparisonFacet, Omit<FacetInfo, 'id'>> = {
},
totalDependencies: {
category: 'performance',
comingSoon: true,
},
// Health
downloads: {
Expand Down
Loading