[Turbopack] handle state serialization (#69670)
### What? State need some special handling for persistent caching. In particular we need to differ between two kind of states: * Persistent State: It will be stored in the persistent cache and value will be kept between builds. * Transient State: It's only valid for a session and will reset when restoring the persistent cache. We didn't have the separating before, so this PR introduces a new type `TransientState<T>` next to `State<T>` which handles transient state. The value will always be an `Option<T>` and resets to `None` when restoring the persistent cache. This also means all task that depend on transient state will be invalidated on restoring. Transient State can also be used when the value is not serializable. e. g. this is the case for the `last_successful_parse` state in ecmascript modules. We use that to avoid large structure changes to the module graph when introducing parse errors to modules. Using transient state for that means we only apply this optimization on a session, and it resets when restoring from persistent cache.
Showing
This diff is collapsed.
Please
register
or
sign in
to comment