-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: celebrate bundle size decreases and report no-change #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
43081j
merged 14 commits into
e18e:main
from
bartveneman:claude/bundle-size-celebration-DeSKF
Apr 10, 2026
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cf99d21
feat: celebrate bundle size decreases and report no-change
bartveneman 6a55249
fix: use per-package zero-check for no-change and net total for thres…
bartveneman 50d7d76
refactor: combine decreases and increases into one table when thresho…
bartveneman 784a8b5
feat: show signed size changes (+/-) in bundle size table
bartveneman 576d8d1
fix: only show 'no bundle size changes' message when threshold is -1
bartveneman e411595
docs: correct README description of no-change bundle size behaviour
bartveneman 8ab1a37
fix: base threshold comparison on sum of increases only, not net change
bartveneman 8d65bd4
test: add tests proving threshold is based on increases only, not net…
bartveneman 19c295c
Merge branch 'main' into claude/bundle-size-celebration-DeSKF
43081j b341eb8
refactor: consolidate bundle size logic
43081j 5fbecbe
fix: remove extra minus
43081j 4f1b86e
test: clean up tests
43081j 8c12799
test: remove redundant assertions
43081j b12d3e2
chore: format readme
43081j File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`scanForBundleSize > should celebrate size decrease when threshold is -1 1`] = ` | ||
| [ | ||
| "## 🎉 Package Size Decrease | ||
|
|
||
| | 📦 Package | 📏 Base Size | 📏 Source Size | 📊 Size Change | | ||
| | --- | --- | --- | --- | | ||
| | my-package | 200 kB | 100 kB | -100 kB |", | ||
| ] | ||
| `; | ||
|
|
||
| exports[`scanForBundleSize > should report no bundle size change with threshold=-1 when diff is 0 1`] = ` | ||
| [ | ||
| "## 📦 Package Bundle Size | ||
|
|
||
| No bundle size changes.", | ||
| ] | ||
| `; | ||
|
|
||
| exports[`scanForBundleSize > should show both decreases and increases when threshold is -1 1`] = ` | ||
| [ | ||
| "## 📦 Package Bundle Size Changes | ||
|
|
||
| | 📦 Package | 📏 Base Size | 📏 Source Size | 📊 Size Change | | ||
| | --- | --- | --- | --- | | ||
| | pkg-b | 50 kB | 150 kB | +100 kB | | ||
| | pkg-a | 200 kB | 100 kB | -100 kB |", | ||
| ] | ||
| `; | ||
|
|
||
| exports[`scanForBundleSize > should show only increases when threshold is -1 and no decreases 1`] = ` | ||
| [ | ||
| "## ⚠️ Package Size Increase | ||
|
|
||
| | 📦 Package | 📏 Base Size | 📏 Source Size | 📊 Size Change | | ||
| | --- | --- | --- | --- | | ||
| | my-package | 100 kB | 200 kB | +100 kB |", | ||
| ] | ||
| `; | ||
|
|
||
| exports[`scanForBundleSize > should warn about an increase even when a decrease in another package cancels it out in total 1`] = ` | ||
| [ | ||
| "## ⚠️ Package Size Increase | ||
|
|
||
| These packages exceed the size increase threshold of 50 kB: | ||
|
|
||
| | 📦 Package | 📏 Base Size | 📏 Source Size | 📈 Size Change | | ||
| | --- | --- | --- | --- | | ||
| | pkg-b | 50 kB | 150 kB | +100 kB |", | ||
| ] | ||
| `; | ||
|
|
||
| exports[`scanForBundleSize > should warn about size increase exceeding threshold 1`] = ` | ||
| [ | ||
| "## ⚠️ Package Size Increase | ||
|
|
||
| These packages exceed the size increase threshold of 50 kB: | ||
|
|
||
| | 📦 Package | 📏 Base Size | 📏 Source Size | 📈 Size Change | | ||
| | --- | --- | --- | --- | | ||
| | my-package | 100 kB | 200 kB | +100 kB |", | ||
| ] | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| import {describe, expect, it} from 'vitest'; | ||
| import {scanForBundleSize} from '../../src/checks/bundle-size.js'; | ||
| import type {PackInfo} from '../../src/packs.js'; | ||
|
|
||
| function makePack(packageName: string, size: number): PackInfo { | ||
| return { | ||
| name: `${packageName}-1.0.0.tgz`, | ||
| packageName, | ||
| path: `/tmp/${packageName}-1.0.0.tgz`, | ||
| size | ||
| }; | ||
| } | ||
|
|
||
| describe('scanForBundleSize', () => { | ||
| it('should do nothing when no packs are provided', async () => { | ||
| const messages: string[] = []; | ||
| await scanForBundleSize(messages, [], [], 50000); | ||
| expect(messages).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should report no bundle size change when diff is 0', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 100000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should report no bundle size change with threshold=-1 when diff is 0', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 100000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, -1); | ||
|
|
||
| expect(messages).toHaveLength(1); | ||
| expect(messages[0]).toContain('No bundle size changes'); | ||
| expect(messages).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should not report anything when diff is 0 and threshold is not -1', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 100000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should never warn about a pure size decrease, no matter how large', async () => { | ||
| const messages: string[] = []; | ||
| // sizeChange is signed: (sourceSize - baseSize) = negative for a shrink | ||
| // A massive decrease should never cross a positive threshold | ||
| const basePacks = [makePack('my-package', 1000000)]; | ||
| const sourcePacks = [makePack('my-package', 1)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should warn even when net total change is negative due to a large decrease masking an increase', async () => { | ||
| const messages: string[] = []; | ||
| // pkg-a shrinks by 500 KB, pkg-b grows by 100 KB → net = -400 KB | ||
| // Without filtering to increases only, -400 KB < 50 KB threshold → silent (wrong) | ||
| const basePacks = [makePack('pkg-a', 500000), makePack('pkg-b', 50000)]; | ||
| const sourcePacks = [makePack('pkg-a', 0), makePack('pkg-b', 150000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(1); | ||
| expect(messages[0]).toContain('pkg-b'); | ||
| expect(messages[0]).not.toContain('pkg-a'); | ||
| }); | ||
|
|
||
| it('should sum multiple increases when checking against the threshold', async () => { | ||
| const messages: string[] = []; | ||
| // Each increase is 30 KB (below the 50 KB threshold individually) | ||
| // but combined they are 60 KB (above threshold) → should warn | ||
| const basePacks = [makePack('pkg-a', 100000), makePack('pkg-b', 100000)]; | ||
| const sourcePacks = [makePack('pkg-a', 130000), makePack('pkg-b', 130000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(1); | ||
| expect(messages[0]).toContain('pkg-a'); | ||
| expect(messages[0]).toContain('pkg-b'); | ||
| }); | ||
|
|
||
| it('should warn about size increase exceeding threshold', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 200000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should not warn about size increase below threshold', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 120000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should warn about an increase even when a decrease in another package cancels it out in total', async () => { | ||
| const messages: string[] = []; | ||
| // pkg-a shrinks by 100 KB, pkg-b grows by 100 KB → net = 0, but pkg-b exceeds threshold | ||
| const basePacks = [makePack('pkg-a', 200000), makePack('pkg-b', 50000)]; | ||
| const sourcePacks = [makePack('pkg-a', 100000), makePack('pkg-b', 150000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(1); | ||
| expect(messages[0]).toContain('pkg-b'); | ||
| expect(messages[0]).not.toContain('pkg-a'); | ||
| expect(messages).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should not report no-change when changes exist but are below threshold', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 120000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, 50000); | ||
|
|
||
| expect(messages).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should celebrate size decrease when threshold is -1', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 200000)]; | ||
| const sourcePacks = [makePack('my-package', 100000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, -1); | ||
|
|
||
| expect(messages).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should show both decreases and increases when threshold is -1', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('pkg-a', 200000), makePack('pkg-b', 50000)]; | ||
| const sourcePacks = [makePack('pkg-a', 100000), makePack('pkg-b', 150000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, -1); | ||
|
|
||
| expect(messages).toHaveLength(1); | ||
| expect(messages).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should show only increases when threshold is -1 and no decreases', async () => { | ||
| const messages: string[] = []; | ||
| const basePacks = [makePack('my-package', 100000)]; | ||
| const sourcePacks = [makePack('my-package', 200000)]; | ||
|
|
||
| await scanForBundleSize(messages, basePacks, sourcePacks, -1); | ||
|
|
||
| expect(messages).toMatchSnapshot(); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.