Repository navigation
feat(bundlecheck): Add SQLite cache for results - #486
Merged
Merged
Conversation
Introduce a persistent SQLite cache for bundlecheck using better-sqlite3 (packages and lockfile updated). Added packages/bundlecheck/src/cache.ts implementing init/get/set/clear/close, key normalization, FIFO eviction (max 100 entries) and helper functions. Integrate cache into CLI and trend flows: compute normalized cache keys (resolving `latest`, using exported getExternals), read from cache unless --force, store results after bundling, and add a displayResult helper for formatted output. Add a --force flag to defaults and parse to bypass cache. Export getExternals from bundler. Add comprehensive tests (cache.test.ts) and adjust trend tests to mock cache to avoid interference.
There was a problem hiding this comment.
Pull request overview
This pull request introduces a persistent SQLite-based caching mechanism for bundle size results in the bundlecheck tool. The cache stores results keyed by package name, version, exports, platform, gzip level, externals configuration, and noExternal flag. The implementation includes automatic FIFO eviction when the cache exceeds 100 entries and adds a --force flag to bypass the cache.
Changes:
- Added SQLite caching with better-sqlite3 to store and retrieve bundle check results, reducing redundant package installations and bundling operations
- Integrated cache lookups into both single-package checks and trend analysis workflows
- Added
--forceflag to allow users to bypass the cache and force fresh calculations
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Added better-sqlite3 (12.6.2) and @types/better-sqlite3 (7.6.13) with their transitive dependencies |
| packages/bundlecheck/package.json | Added better-sqlite3 as a production dependency and @types/better-sqlite3 as a dev dependency |
| packages/bundlecheck/src/cache.ts | New file implementing cache initialization, normalization, CRUD operations (get/set/clear/close), FIFO eviction logic, and helper functions |
| packages/bundlecheck/src/bundler.ts | Exported getExternals function to support cache key computation in other modules |
| packages/bundlecheck/src/defaults.ts | Added force: false to default flags configuration |
| packages/bundlecheck/src/parse.ts | Added --force/-f flag definition with description and example usage |
| packages/bundlecheck/src/bundlecheck.ts | Integrated cache with version resolution for "latest", cache key computation, cache lookup before bundling, cache storage after bundling, and extracted displayResult helper function |
| packages/bundlecheck/src/trend.ts | Integrated cache into trend analysis with per-version cache checks and storage, respecting the --force flag |
| packages/bundlecheck/src/tests/cache.test.ts | Comprehensive test suite for cache functionality including normalization, CRUD operations, eviction, and edge cases |
| packages/bundlecheck/src/tests/trend.test.ts | Added cache module mocks to prevent test interference |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduce a persistent SQLite cache for bundlecheck using better-sqlite3 (packages and lockfile updated). Added packages/bundlecheck/src/cache.ts implementing init/get/set/clear/close, key normalization, FIFO eviction (max 100 entries) and helper functions. Integrate cache into CLI and trend flows: compute normalized cache keys (resolving
latest, using exported getExternals), read from cache unless --force, store results after bundling, and add a displayResult helper for formatted output. Add a --force flag to defaults and parse to bypass cache. Export getExternals from bundler. Add comprehensive tests (cache.test.ts) and adjust trend tests to mock cache to avoid interference.