Skip to content

feat(bundlecheck): Add SQLite cache for results - #486

Merged
aversini merged 3 commits into
mainfrom
feat(bundlecheck)-Add-SQLite-cache-for-results
Jan 31, 2026
Merged

aversini merged 3 commits into
mainfrom
feat(bundlecheck)-Add-SQLite-cache-for-results

Conversation

@aversini

Copy link
Copy Markdown
Collaborator

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --force flag 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

Comment thread packages/bundlecheck/src/cache.ts
Comment thread packages/bundlecheck/src/cache.ts
Comment thread packages/bundlecheck/src/cache.ts
Comment thread packages/bundlecheck/src/cache.ts Outdated
Comment thread packages/bundlecheck/src/cache.ts Outdated
Comment thread packages/bundlecheck/src/cache.ts
Comment thread packages/bundlecheck/package.json
Comment thread packages/bundlecheck/src/cache.ts
Comment thread packages/bundlecheck/src/__tests__/cache.test.ts
Comment thread packages/bundlecheck/src/cache.ts
@aversini
aversini merged commit f9d519d into main Jan 31, 2026
6 checks passed
@aversini
aversini deleted the feat(bundlecheck)-Add-SQLite-cache-for-results branch January 31, 2026 20:31
@aversini aversini mentioned this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants