turbopack_ecmascript/hmr/mod.rs
1use turbo_tasks::Vc;
2use turbopack_core::version::VersionedContent;
3
4use crate::{chunk::EcmascriptChunkContentEntries, hmr::version::EcmascriptChunkVersion};
5
6/// Diffing and merging of Ecmascript chunk contents for hot module replacement.
7///
8/// Each module covers both the single-chunk and the merged (multi-chunk) case,
9/// the latter being what a chunk list produces a single update from.
10pub mod content;
11pub mod merger;
12pub mod update;
13pub mod version;
14
15/// An Ecmascript chunk content that participates in HMR.
16///
17/// Exists so the version/diff/merge machinery can be written once against the
18/// trait rather than duplicated per runtime. The turbo-tasks value types cannot
19/// be generic, so the runtimes keep their own content structs and implement this
20/// to expose the two things the shared machinery needs.
21#[turbo_tasks::value_trait]
22pub trait EcmascriptHmrChunkContent: VersionedContent {
23 /// The per-module code and hashes making up this chunk.
24 #[turbo_tasks::function]
25 fn entries(self: Vc<Self>) -> Vc<EcmascriptChunkContentEntries>;
26
27 /// The same value as [`VersionedContent::version`], but with the concrete
28 /// type the diffing machinery needs instead of `Box<dyn Version>`.
29 #[turbo_tasks::function]
30 fn ecmascript_chunk_version(self: Vc<Self>) -> Vc<EcmascriptChunkVersion>;
31}