next.js
affb856d - Turbopack: Fix experimental server hmr for pages router (#90398)

Commit
49 days ago
Turbopack: Fix experimental server hmr for pages router (#90398) This is cherry-picked from #90389, which also serves as a test case for server hmr being enabled by default. This fixes a number of issues with server hmr, most notably that pages router updates weren’t reflected: 1. **Pages Router pages weren't clearing the chunk cache** — the old condition (which just checked the cli flag) meant the chunk cache was only cleared when server HMR was entirely absent. Once server HMR was enabled, Pages Router pages (which don't use the Turbopack module registry) got stale. 2. **`deleteCache` was skipped for files with server HMR subscriptions** — this left stale entries in `evalManifest`'s `sharedCache`, causing "Could not find module in React Client Manifest" errors when new `'use client'` components were added. 3. **`clearModuleContext` was skipped for middleware and edge routes** — server HMR subscriptions include edge runtime chunks, but `__turbopack_server_hmr_apply__` can't reach those sandboxes. They need `clearModuleContext` called explicitly. 4. **Chunk cache wasn't cleared for `.env`/config changes** — when `force: true` (no code change), module-level env captures stayed stale. Now `__next__clear_chunk_cache__()` is called unconditionally when `force` is set.
Author
Parents
Loading