turbopack_core/source.rs
1use turbo_tasks::{ResolvedVc, Vc};
2
3use crate::{asset::Asset, ident::AssetIdent};
4
5/// (Unparsed) Source Code. Source Code is processed into [Module]s by the
6/// [AssetContext]. All [Source]s have content and an identifier.
7#[turbo_tasks::value_trait]
8pub trait Source: Asset {
9 /// The identifier of the [Source]. It's expected to be unique and capture
10 /// all properties of the [Source].
11 #[turbo_tasks::function]
12 fn ident(&self) -> Vc<AssetIdent>;
13}
14
15#[turbo_tasks::value(transparent)]
16pub struct OptionSource(Option<ResolvedVc<Box<dyn Source>>>);
17
18#[turbo_tasks::value(transparent)]
19pub struct Sources(Vec<ResolvedVc<Box<dyn Source>>>);
20
21// TODO All Vc::try_resolve_downcast::<Box<dyn Source>> calls should be removed