Skip to content

refactor: share buffer.js between main-thread and worker bundles#55

Merged
jacaudi merged 4 commits into
mainfrom
refactor/buffer-build-sharing
Apr 12, 2026
Merged

refactor: share buffer.js between main-thread and worker bundles#55
jacaudi merged 4 commits into
mainfrom
refactor/buffer-build-sharing

Conversation

@jacaudi
Copy link
Copy Markdown
Owner

@jacaudi jacaudi commented Apr 11, 2026

Summary

  • Delete byte-identical duplicate src/js/worker/buffer.js — the worker bundle now sources buffer.js from src/js/lib/ via WORKER_FILES so the file exists in exactly one place.
  • Normalize WORKER_FILES to carry its own subdirectory per entry (matching MAIN_FILES style), keeping the mapper a plain readFileSync with no special-cases.
  • Add test-buffer-build-sharing.js to guard the worker blob: it reads the built app/index.html, extracts the ww_js_script template literal, and asserts bufferToHex + hexToArrayBuffer are present.
  • Add a one-line guard comment at the top of lib/buffer.js noting it's embedded in both bundles (keep DOM-free).

Test plan

  • docker run --rm -v \$(pwd):/work -w /work node:22-alpine sh -c "node scripts/build.js && node --test app/tests/test-*.js" — 168/168 passing
  • Worker blob in app/index.html still contains bufferToHex and hexToArrayBuffer (new regression test)
  • No lingering references to src/js/worker/buffer.js in the codebase
  • app/index.html build output byte-identical comparison test still passes

🤖 Generated with Claude Code

jacaudi and others added 4 commits April 11, 2026 03:43
Routes buffer.js via the entry itself (lib/buffer.js) to match the
MAIN_FILES style and drops the ternary branch in the mapper. Also
renames the worker-files existence test to drop the hardcoded count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jacaudi jacaudi merged commit 19103c1 into main Apr 12, 2026
13 checks passed
jacaudi added a commit that referenced this pull request Apr 13, 2026
Empty commit to trigger semantic-release. The five refactor PRs that
landed after v0.7.2 (buffer sharing, query-string parser rewrite,
secureOverwriteBuffer simplification, doStuff/undoStuff unification,
ECDH P-521 hygiene pass) use conventional commit types that don't
bump the version, so this commit ships them as v0.7.3.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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