fw-07 step 03 — Incremental rebuild and HMR

Tasks

  1. Cache keyed on filename only. Produce a wrong bundle. Then mtime. Then content hash. Then content hash plus resolved dependency hashes. Note that only the last is correct.
  2. Add config and plugin versions to the key; explain why an "unrelated" change legitimately invalidates everything.
  3. Measure incremental rebuild time across the four key strategies.
  4. HMR concepts. Define what must be true for a module to be replaceable: identify changed modules, choose a propagation boundary, preserve state, and dispose the previous module's side effects.
  5. Build the leak: a module that registers a listener without disposing. Watch listeners accumulate across hot updates. Connect to fw-02's effect cleanup.

Done when

  • Four cache-key strategies implemented, with the failure of each of the first three shown
  • HMR listener leak reproduced and then disposed correctly
  • You can state the general rule about re-running code and undoing the previous run