Build: auto-invalidate WASM cache when island dependencies change #46

Closed
opened 2026-03-19 00:48:11 +00:00 by mik-tf · 1 comment
Owner

Problem

make dist uses Docker named volumes (hero-wasm-target, hero-cargo-registry, hero-cargo-git) to cache WASM compilation. When island Cargo.toml dependencies change (e.g. adding pulldown-cmark), cargo inside the container may not detect the change and reuse stale artifacts.

This caused a wasted debug cycle in Session 18 — the markdown rendering fix was compiled on the host but wasm-pack used cached old WASM.

Current workaround

docker volume rm hero-wasm-target before make dist

Fix options

  1. Hash check: In build-local.sh, hash all island Cargo.toml files and compare with a stored hash in the volume. If changed, clean the volume automatically.
  2. Always clean: Add --force or remove pkg/ directories before wasm-pack runs in build-wasm.sh
  3. Document: Add a note in hero_services/README.md or Makefile help about the cache

Option 1 is best — automatic invalidation with no manual steps.

## Problem `make dist` uses Docker named volumes (`hero-wasm-target`, `hero-cargo-registry`, `hero-cargo-git`) to cache WASM compilation. When island Cargo.toml dependencies change (e.g. adding `pulldown-cmark`), cargo inside the container may not detect the change and reuse stale artifacts. This caused a wasted debug cycle in Session 18 — the markdown rendering fix was compiled on the host but wasm-pack used cached old WASM. ## Current workaround `docker volume rm hero-wasm-target` before `make dist` ## Fix options 1. **Hash check**: In `build-local.sh`, hash all island `Cargo.toml` files and compare with a stored hash in the volume. If changed, clean the volume automatically. 2. **Always clean**: Add `--force` or remove `pkg/` directories before wasm-pack runs in `build-wasm.sh` 3. **Document**: Add a note in `hero_services/README.md` or Makefile help about the cache Option 1 is best — automatic invalidation with no manual steps.
Author
Owner

Fixed

Added automatic WASM cache invalidation in build-local.sh (option 1 from the issue).

How it works

  1. Before the WASM build step, hash all Cargo.toml files from hero_os/ and hero_archipelagos/
  2. Compare with stored hash in dist/.wasm-deps-hash
  3. If different → docker volume rm hero-wasm-target (auto-clean)
  4. If same → reuse cache (fast path)

Result

  • make dist now auto-detects dependency changes and rebuilds WASM when needed
  • No more manual docker volume rm or make dist-clean-wasm for dep changes
  • make dist-clean-wasm still available as manual override

Signed-off-by: mik-tf

## Fixed Added automatic WASM cache invalidation in `build-local.sh` (option 1 from the issue). ### How it works 1. Before the WASM build step, hash all `Cargo.toml` files from `hero_os/` and `hero_archipelagos/` 2. Compare with stored hash in `dist/.wasm-deps-hash` 3. If different → `docker volume rm hero-wasm-target` (auto-clean) 4. If same → reuse cache (fast path) ### Result - `make dist` now auto-detects dependency changes and rebuilds WASM when needed - No more manual `docker volume rm` or `make dist-clean-wasm` for dep changes - `make dist-clean-wasm` still available as manual override Signed-off-by: mik-tf
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/home#46
No description provided.