next.js
1df25862 - turbopack: fix incremental build when module factories are restored from persistent cache (#92569)

Commit
2 days ago
turbopack: fix incremental build when module factories are restored from persistent cache (#92569) ### What? Fix an incremental build bug in Turbopack where module factories restored from the persistent cache would skip a necessary code conversion step, producing incorrect output. ### Why? `cell_persisted()` previously returned `Vc<Code>` by immediately calling `to_code()` on the newly created `PersistedCode` cell. This meant the returned `Vc<Code>` was a local, non-persisted cell — so it triggered a recomputation of the task that produces the `Vc<Code>`, which recomputes the actual code and doesn't restore it from the PersistentCode. ### How? - Changed `cell_persisted()` to return `ResolvedVc<PersistedCode>` instead of `Vc<Code>`, so callers explicitly hold a handle to the persisted cell rather than a pre-converted `Code`. - Made `PersistedCode::to_code()` `pub` so callers can invoke the conversion when they actually need a `Vc<Code>`. - Updated `module_factory()` and `module_factory_with_code_generation_issue()` to return `ResolvedVc<PersistedCode>` all the way up the call chain, deferring the `to_code()` call to the final `code()` method that produces a `Vc<Code>` for the chunk pipeline. This ensures that on a cache-warm incremental build, turbo-tasks sees the `PersistedCode` task as a dependency and correctly re-runs the `to_code()` conversion when needed, rather than serving a stale or missing `Code` value. <!-- NEXT_JS_LLM_PR -->
Author
Parents
Loading