[backport] [turbopack] Fix HMR for dynamic imports evaluated from layouts (#97317)
Backports #97213 ("[turbopack] Fix HMR for dynamic imports evaluated
from layouts") to `next-16-3`.
Async chunks that the caller had already expanded (e.g. those reachable
from concatenated chunk
groups) were not tracked in the chunk list, so an edit inside one of
them produced no HMR update at
all. This shows up with the common `await
import(\`../../messages/${locale}.json\`)` pattern in a
layout.
Cherry-picked from 04e9933b with no
conflicts. All 8 files are
byte-identical to canary.
### Verification on this branch
- `cargo fmt --check -p turbopack-nodejs` — clean
- `cargo check -p next-api`, `cargo clippy -p next-api` — clean (these
build `turbopack-nodejs`
with its real feature set)
- `pnpm build-all` — 18/18 tasks
- `test/development/app-dir/layout-dynamic-import-hmr` — passes with
Turbopack and with webpack
- `test/development/acceptance-app/{app-hmr-changes,ReactRefreshModule}`
— 2/2 pass
The new test was confirmed to actually cover the fix: reverting only the
two Rust files (keeping the
fixture) makes it fail with `Expected: "updated" / Received:
"original"`, and restoring them makes it
pass again.
Note: `cargo check -p turbopack-nodejs` in isolation fails on
`turbopack-node/src/pool_stats.rs`
with an unresolved `tokio`. That reproduces identically on unmodified
`next-16-3` and is present on
canary too (`mod pool_stats;` is ungated while `tokio` is optional
behind `process_pool`/
`worker_pool`), so it is pre-existing and unrelated to this backport.
<!-- NEXT_JS_LLM -->
Co-authored-by:
Sam Poder <sampoder@berkeley.edu>
Showing
Please
register
or
sign in
to comment