Skip to content

feat(cache): ./elf consumer entry for npm-static builds - #48

Merged
espetro merged 2 commits into
mainfrom
feat/cache-elf-export
Nov 10, 2026
Merged

espetro merged 2 commits into
mainfrom
feat/cache-elf-export

Conversation

@espetro

@espetro espetro commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

What

Adds "./elf": "./dist/esm/index.js" to @cutils/cache (the pattern @cutils/postgres already ships) so scriptc build --npm-static consumers can import @cutils/cache/elf, plus a consumer-side ELF smoke test that guards it.

Audit (deliverable 1)

Packed the tarball, installed into a scratch app, compiled and ran two programs under --npm-static:

  • basic matrix (new Cache() + get/set/has/delete/size) — compiled and ran clean, zero errors
  • full matrix (peek, clear, per-set ttl override, fake-clock expiry via the positional now seam, E_BAD_CACHE_OPTIONS validation, eviction with recency bump) — compiled and ran clean

No SC9001/nullT, no SC2020, no SC1090, no JSDoc gaps: the shipped dist/esm JS is already fully concretely typed (initialized fields, typed params), so no JSDoc annotations were needed. The ./elf export was therefore fixable and shipped rather than documented as unshippable.

Consumer smoke (deliverable 3)

test/consumer-elf.test.sh mirrors postgres's: pnpm pack -> install tarball into build/consumer-smoke/ -> scriptc build app.ts --npm-static @cutils/cache -o app-elf -> run the ELF (get/set/has/delete/peek/TTL-expiry/clear/validation matrix). Wired into pnpm test. Contract documented in packages/cache/AGENTS.md.

Verification

  • pnpm build clean; node --test: 25 pass / 0 fail
  • scriptc coverage gate.ts: 100% static (82/82 statements)
  • bash test/elf.test.sh: OK
  • bash test/consumer-elf.test.sh: OK
  • oxfmt --check + oxlint: clean
  • changeset: @cutils/cache minor

Add the "./elf": "./dist/esm/index.js" export so scriptc's
--npm-static consumers can import @cutils/cache/elf (the postgres
pattern). The shipped dist JS already satisfies the consumer compile
contract with no JSDoc additions: audited by packing the tarball,
installing it into a scratch app, and scriptc build + run of programs
covering new Cache()/get/set/has/delete/peek/size/clear, per-set ttl
override, fake-clock expiry, and option validation — all compile and
run statically with zero errors.

Add test/consumer-elf.test.sh (mirrors postgres's): packs the
package, installs it into build/consumer-smoke/, compiles the
get/set/ttl matrix against @cutils/cache/elf with --npm-static, runs
the ELF. Wire it into pnpm test. Document the consumer compile
contract in packages/cache/AGENTS.md.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cutilsjs with  Cloudflare Pages  Cloudflare Pages

Latest commit: c7b035f
Status: ✅  Deploy successful!
Preview URL: https://cfc2bf0d.cutilsjs.pages.dev
Branch Preview URL: https://feat-cache-elf-export.cutilsjs.pages.dev

View logs

@espetro
espetro merged commit 0e4aa50 into main Nov 10, 2026
3 checks passed
@espetro
espetro deleted the feat/cache-elf-export branch November 10, 2026 01:18
@espetro espetro mentioned this pull request Nov 10, 2026
3 tasks done
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