turbopack_core/
raw_module.rs

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