You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Turbopack: aggregate client HMR into one subscription
This uses the infrastructure for a single firehose feed of HMR events introduced
in #94948. It replaces the chunk list subscriber and per-chunk-list fan-out of
\`project.hmrEvents\` subscriptions with a single \`projectClientHmrEvents\` sub
scription that diffs every client chunk list under the client root in one tick.
For now, unlike the server side, updates are *not* merged into one instruction.
The browser identifies each update by chunk list path (\`resource.path\`), so th
e napi layer emits one \`ClientUpdateInstruction\` per changed chunk list and th
e existing per-resource HMR dispatcher routes each one to its callback.
Rust:
- \`aggregate_hmr.rs\`: new \`ClientChunkListUpdate\` / \`ClientChunkListUpdateK
ind\` / \`ClientHmrUpdates\` to model per-chunk-list updates while preserving ch
unk list identity.
- \`versioned_content_map.rs\`: \`hmr_chunks_in_path\` filters to entries that d
owncast to \`EcmascriptDevChunkListContent\` for \`HmrTarget::Client\`, the only
shape the browser HMR runtime can apply.
- \`project.rs\`:
- \`hmr_version_state\` handles \`HmrTarget::Client\` by snapshotting chunk li
sts.
- \`client_hmr_update\` returns one entry per chunk list with a non-empty diff
. \`Total\`/\`Missing\` becomes a per-resource \`Restart\`; the rest of the batc
h is still delivered. The first tick returns an empty result so the seed transi
tion can advance \`VersionState\` without the JS consumer applying anything.
- \`ClientHmrUpdates::to\` exposes the aggregate \`to\` version on the same st
ruct as \`updates\` so the napi subscriber can advance state even when no chunk
lists changed.
NAPI:
- \`projectClientHmrEvents\` returns a single subscription emitting \`{ updates:
ClientUpdateInstruction[] }\`. Issues are mirrored on every entry; when there a
re issues but no updates, a sentinel \`issues\`-only frame is emitted under \`__
next_client_hmr__\`.
JS:
- \`hot-reloader-turbopack.ts\` subscribes once via \`clientHmrEvents()\` instea
d of fanning out per \`turbopack-subscribe\`. The browser still emits \`turbopa
ck-subscribe\`/\`-unsubscribe\` frames on chunk list registration; they're now
accepted as no-ops for protocol compat.
- \`turbopack-utils.ts\` drops the per-client \`subscriptions\` map and \`unsubs
cribeFromHmrEvents\` hook.
0 commit comments