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,
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: ResolvedVc<FileSystemPath>,
15    source: ResolvedVc<Box<dyn Source>>,
16}
17
18#[turbo_tasks::value_impl]
19impl OutputAsset for RawOutput {
20    #[turbo_tasks::function]
21    fn path(&self) -> Vc<FileSystemPath> {
22        *self.path
23    }
24}
25
26#[turbo_tasks::value_impl]
27impl Asset for RawOutput {
28    #[turbo_tasks::function]
29    fn content(&self) -> Vc<AssetContent> {
30        self.source.content()
31    }
32}
33
34#[turbo_tasks::value_impl]
35impl RawOutput {
36    #[turbo_tasks::function]
37    pub fn new(
38        path: ResolvedVc<FileSystemPath>,
39        source: ResolvedVc<Box<dyn Source>>,
40    ) -> Vc<RawOutput> {
41        RawOutput { path, source }.cell()
42    }
43}