Skip to content

feat: share hash cache across entries#18

Merged
maastrich merged 1 commit intomainfrom
feat/shared-cache
Apr 24, 2026
Merged

feat: share hash cache across entries#18
maastrich merged 1 commit intomainfrom
feat/shared-cache

Conversation

@maastrich
Copy link
Copy Markdown
Owner

Summary

  • HashupOptions gains cache?: HashupCache and resolver?: Resolver. Pass them across calls to dedupe work — files imported by multiple named entries are read + hashed exactly once.
  • CLI config mode threads one shared cache + resolver through every entry automatically.
  • New exports: createHashupCache(), collectReachable(), and the HashupCache type.
  • result.files continues to report only the current call's reachable set (entry + extras + their transitive non-node_modules imports), walked iteratively via the new deps map. Accurate whether the cache is shared or not.

Hash stability

Byte-identical to 0.5.0. The 48adf62a… inline snapshot in tests/examples.test.ts still matches — shared cache is a pure dedupe.

Breaking

Targeted to direct hashFile callers: the cache parameter type changes from Map<string, string[]> to HashupCache. hashup() callers are unaffected — the new option is additive. Minor bump (pre-1.0).

Test plan

  • New tests/shared-cache.test.ts — cache size invariant (second identical call grows by zero), cross-entry overlap reduces total work, extras stay tracked as roots, collectReachable handles 50k-deep chains and cycles iteratively
  • tests/examples.test.ts inline snapshot unchanged
  • vp test — 116/116 passing
  • vp check clean
  • Smoke tested against bfront — same hash as 0.5.0 on Toaster/index.ts

🤖 Generated with Claude Code

Add HashupCache (hashes + deps maps) plus createHashupCache() and
collectReachable() helpers. hashup() gains cache?/resolver? options;
config mode threads one shared pair through every named entry.
Per-call files still reflect only that call's reachable closure.

hashFile's cache parameter type changes from Map<string, string[]>
to HashupCache — targeted break for direct hashFile callers only.
hashup() itself is backward compatible.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

📖 Docs preview: https://maastrich.github.io/hashup/branches/pr-18/

@maastrich maastrich merged commit 2bfc65a into main Apr 24, 2026
3 checks passed
@maastrich maastrich deleted the feat/shared-cache branch April 24, 2026 10:15
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.

1 participant