Skip to main content

turbopack_core/
emit_collect.rs

1use turbo_rcstr::RcStr;
2use turbo_tasks::{ValueToString, Vc};
3
4use crate::{
5    chunk::{ChunkItem, ChunkingContext},
6    compile_time_info::CompileTimeDefineValue,
7    module::{Module, Modules},
8    module_graph::ModuleGraph,
9    reference::ModuleReference,
10};
11
12/// A module that can collect other emitted modules during the collect phase.
13#[turbo_tasks::value_trait]
14pub trait CollectingModule: Module {
15    /// The namespace that this module is interested in
16    #[turbo_tasks::function]
17    fn namespace(self: Vc<Self>) -> Vc<RcStr>;
18
19    #[turbo_tasks::function]
20    fn as_chunk_item(
21        self: Vc<Self>,
22        module_graph: Vc<ModuleGraph>,
23        chunking_context: Vc<Box<dyn ChunkingContext>>,
24        entry_chunk_group: Vc<Modules>,
25    ) -> Vc<Box<dyn ChunkItem>>;
26}
27
28#[turbo_tasks::value_trait]
29pub trait EmittedModuleReference: ModuleReference + ValueToString {
30    #[turbo_tasks::function]
31    fn data(self: Vc<Self>) -> Vc<CompileTimeDefineValue>;
32}