From df7d8c2f9dad6a847a747a493216249161e763e7 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Fri, 20 Mar 2026 21:45:59 +0000 Subject: [PATCH 1/2] fix: don't diff install size with first version Most initial versions are empty or unfinished, so generally show up as a large bump in file size to the 2nd version. This is misleading so we should just skip those. --- app/composables/useInstallSizeDiff.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/composables/useInstallSizeDiff.ts b/app/composables/useInstallSizeDiff.ts index d084ba14c3..0dd85206e2 100644 --- a/app/composables/useInstallSizeDiff.ts +++ b/app/composables/useInstallSizeDiff.ts @@ -31,7 +31,9 @@ function getComparisonVersion(pkg: SlimPackument, resolvedVersion: string): stri .sort((a, b) => compare(a, b)) const currentIdx = stableVersions.indexOf(resolvedVersion) - if (currentIdx <= 0) return null + // Don't compare the second version against the first as the first + // has no baseline so a large size difference is expected + if (currentIdx <= 1) return null return stableVersions[currentIdx - 1]! } From cc4dd6881fbbc8d7d13715fb14de826806c02f32 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Sat, 21 Mar 2026 04:17:30 +0000 Subject: [PATCH 2/2] test: fix 'em up --- .../composables/use-install-size-diff.spec.ts | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/test/nuxt/composables/use-install-size-diff.spec.ts b/test/nuxt/composables/use-install-size-diff.spec.ts index d464e2e353..100ca89f93 100644 --- a/test/nuxt/composables/use-install-size-diff.spec.ts +++ b/test/nuxt/composables/use-install-size-diff.spec.ts @@ -61,8 +61,19 @@ describe('useInstallSizeDiff', () => { expect(comparisonVersion.value).toBeNull() }) + it('returns null for the second stable version (no baseline for first)', () => { + const pkg = createPackage('test', { + '1.0.0': '2020-01-01', + '1.1.0': '2021-01-01', + }) + + const { comparisonVersion } = useInstallSizeDiff('test', '1.1.0', pkg, null) + expect(comparisonVersion.value).toBeNull() + }) + it('skips prerelease versions when finding previous stable', () => { const pkg = createPackage('test', { + '0.9.0': '2019-01-01', '1.0.0': '2020-01-01', '2.0.0-beta.1': '2021-01-01', '2.0.0-beta.2': '2021-06-01', @@ -117,6 +128,7 @@ describe('useInstallSizeDiff', () => { it('returns null when both thresholds are not met', async () => { const pkg = createPackage('pkg-no-threshold', { + '0.9.0': '2019-01-01', '1.0.0': '2020-01-01', '1.1.0': '2021-01-01', }) @@ -140,7 +152,11 @@ describe('useInstallSizeDiff', () => { }) it('sets sizeThresholdExceeded when size increased by more than 25%', async () => { - const pkg = createPackage('pkg-size-only', { '1.0.0': '2020-01-01', '1.1.0': '2021-01-01' }) + const pkg = createPackage('pkg-size-only', { + '0.9.0': '2019-01-01', + '1.0.0': '2020-01-01', + '1.1.0': '2021-01-01', + }) const current = createInstallSize('pkg-size-only', { version: '1.1.0', totalSize: 7000, @@ -172,7 +188,11 @@ describe('useInstallSizeDiff', () => { }) it('sets depThresholdExceeded when more than 5 dependencies were added', async () => { - const pkg = createPackage('pkg-deps-only', { '1.0.0': '2020-01-01', '1.1.0': '2021-01-01' }) + const pkg = createPackage('pkg-deps-only', { + '0.9.0': '2019-01-01', + '1.0.0': '2020-01-01', + '1.1.0': '2021-01-01', + }) const current = createInstallSize('pkg-deps-only', { version: '1.1.0', totalSize: 5100, @@ -204,7 +224,11 @@ describe('useInstallSizeDiff', () => { }) it('returns correct diff values', async () => { - const pkg = createPackage('pkg-both', { '1.0.0': '2020-01-01', '1.1.0': '2021-01-01' }) + const pkg = createPackage('pkg-both', { + '0.9.0': '2019-01-01', + '1.0.0': '2020-01-01', + '1.1.0': '2021-01-01', + }) const current = createInstallSize('pkg-both', { version: '1.1.0', totalSize: 10000, @@ -234,7 +258,11 @@ describe('useInstallSizeDiff', () => { describe('fetch behavior', () => { it('calls the correct API endpoint for the comparison version', async () => { - const pkg = createPackage('my-pkg', { '1.0.0': '2020-01-01', '1.1.0': '2021-01-01' }) + const pkg = createPackage('my-pkg', { + '0.9.0': '2019-01-01', + '1.0.0': '2020-01-01', + '1.1.0': '2021-01-01', + }) const current = createInstallSize('my-pkg', { version: '1.1.0', totalSize: 7000 }) fetchSpy.mockResolvedValue(createInstallSize('my-pkg', { version: '1.0.0', totalSize: 5000 }))