next.js
8348d73e - Turbopack: narrow async-module emptiness dependencies (#101154)

Commit
20 hours ago
Turbopack: narrow async-module emptiness dependencies (#101154) ### What? Adds `ModuleGraph::has_async_modules()`, a narrow turbo-tasks accessor that reports whether the module graph contains any async module. The browser and Node.js chunking code now use it when deciding whether to include the async-module runtime helpers, instead of reading the full `AsyncModulesInfo` set just to check whether it is empty. ### Why? `AsyncModulesInfo` is a keyed cell holding every async module in the graph. Awaiting the whole value makes the reading task depend on every set member, so adding or removing an async module re-ran the runtime/evaluate-chunk tasks even when the result could not change. These callers only care about the empty/nonempty transition. ### How? The accessor is a memoized task returning a boolean cell. The whole-set read is isolated there; when the set membership changes but stays nonempty, the accessor recomputes the same boolean and downstream chunking tasks are not invalidated. Empty-to-nonempty and nonempty-to-empty changes still invalidate consumers. The existing runtime inclusion rules are unchanged, including the shared-runtime short-circuits and always including the helpers for the inline browser development runtime. The name follows the existing async-module terminology because the set includes async externals, WASM modules and transitive importers, not only modules with top-level await. ### Verification - `cargo test -p turbopack-tests --test snapshot` (136 passed, no snapshot changes; includes top-level-await and runtime snapshots) - `cargo check -p turbopack-core -p turbopack-browser -p turbopack-nodejs` - `cargo clippy -p turbopack-core -p turbopack-browser -p turbopack-nodejs` - `cargo fmt --all -- --check` - Temporary turbo-tasks invalidation harness (not committed): a boolean emptiness accessor over a keyed set re-ran its consumer on empty/nonempty transitions but not on nonempty membership changes; a whole-set control consumer re-ran on each membership change. <!-- NEXT_JS_LLM --> <!-- fleet 3745345b-93f7-4f4b-ae8c-25fbc13c3ae8 --> Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Author
Parents
Loading