turbopack_core/
raw_output.rs

1use turbo_tasks::{ResolvedVc, Vc};
2use turbo_tasks_fs::FileSystemPath;
3
4use crate::{
5    asset::{Asset, AssetContent},
6    output::{OutputAsset, OutputAssetsReference},
7    source::Source,
8};
9
10/// A module where source code doesn't need to be parsed but can be used as is.
11/// This module has no references to other modules.
12#[turbo_tasks::value]
13pub struct RawOutput {
14    path: FileSystemPath,
15    source: ResolvedVc<Box<dyn Source>>,
16}
17
18#[turbo_tasks::value_impl]
19impl OutputAssetsReference for RawOutput {}
20
21#[turbo_tasks::value_impl]
22impl OutputAsset for RawOutput {
23    #[turbo_tasks::function]
24    fn path(&self) -> Vc<FileSystemPath> {
25        self.path.clone().cell()
26    }
27}
28
29#[turbo_tasks::value_impl]
30impl Asset for RawOutput {
31    #[turbo_tasks::function]
32    fn content(&self) -> Vc<AssetContent> {
33        self.source.content()
34    }
35}
36
37#[turbo_tasks::value_impl]
38impl RawOutput {
39    #[turbo_tasks::function]
40    pub fn new(path: FileSystemPath, source: ResolvedVc<Box<dyn Source>>) -> Vc<RawOutput> {
41        RawOutput { path, source }.cell()
42    }
43}