|
1 |
| -use anyhow::Result; |
2 | 1 | use turbo_rcstr::RcStr;
|
3 | 2 | use turbo_tasks::{ResolvedVc, Vc};
|
4 | 3 | use turbopack_core::{
|
5 | 4 | asset::{Asset, AssetContent},
|
6 |
| - chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext}, |
| 5 | + chunk::ChunkingContext, |
7 | 6 | ident::AssetIdent,
|
8 | 7 | module::Module,
|
9 |
| - module_graph::ModuleGraph, |
10 |
| - output::{OutputAsset, OutputAssets}, |
| 8 | + output::OutputAsset, |
11 | 9 | source::Source,
|
12 | 10 | };
|
13 |
| -use turbopack_css::{ |
14 |
| - chunk::{CssChunkItem, CssChunkItemContent, CssChunkType}, |
15 |
| - embed::CssEmbed, |
16 |
| -}; |
17 |
| -use turbopack_ecmascript::{ |
18 |
| - chunk::{EcmascriptChunkPlaceable, EcmascriptExports}, |
19 |
| - utils::StringifyJs, |
20 |
| -}; |
| 11 | +use turbopack_css::embed::CssEmbed; |
21 | 12 |
|
22 | 13 | use crate::output_asset::StaticOutputAsset;
|
23 | 14 |
|
@@ -65,102 +56,13 @@ impl Asset for StaticUrlCssModule {
|
65 | 56 | }
|
66 | 57 |
|
67 | 58 | #[turbo_tasks::value_impl]
|
68 |
| -impl ChunkableModule for StaticUrlCssModule { |
69 |
| - #[turbo_tasks::function] |
70 |
| - async fn as_chunk_item( |
71 |
| - self: ResolvedVc<Self>, |
72 |
| - _module_graph: Vc<ModuleGraph>, |
73 |
| - chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, |
74 |
| - ) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { |
75 |
| - Ok(Vc::upcast(StaticUrlCssChunkItem::cell( |
76 |
| - StaticUrlCssChunkItem { |
77 |
| - module: self, |
78 |
| - chunking_context, |
79 |
| - static_asset: self |
80 |
| - .static_output_asset(*ResolvedVc::upcast(chunking_context)) |
81 |
| - .to_resolved() |
82 |
| - .await?, |
83 |
| - }, |
84 |
| - ))) |
85 |
| - } |
86 |
| -} |
87 |
| - |
88 |
| -#[turbo_tasks::value_impl] |
89 |
| -impl EcmascriptChunkPlaceable for StaticUrlCssModule { |
90 |
| - #[turbo_tasks::function] |
91 |
| - fn get_exports(&self) -> Vc<EcmascriptExports> { |
92 |
| - EcmascriptExports::Value.into() |
93 |
| - } |
94 |
| -} |
95 |
| - |
96 |
| -#[turbo_tasks::value] |
97 |
| -struct StaticUrlCssChunkItem { |
98 |
| - module: ResolvedVc<StaticUrlCssModule>, |
99 |
| - chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, |
100 |
| - static_asset: ResolvedVc<StaticOutputAsset>, |
101 |
| -} |
102 |
| - |
103 |
| -#[turbo_tasks::value_impl] |
104 |
| -impl ChunkItem for StaticUrlCssChunkItem { |
105 |
| - #[turbo_tasks::function] |
106 |
| - fn asset_ident(&self) -> Vc<AssetIdent> { |
107 |
| - self.module.ident() |
108 |
| - } |
109 |
| - |
110 |
| - #[turbo_tasks::function] |
111 |
| - fn references(&self) -> Vc<OutputAssets> { |
112 |
| - Vc::cell(vec![ResolvedVc::upcast(self.static_asset)]) |
113 |
| - } |
114 |
| - |
115 |
| - #[turbo_tasks::function] |
116 |
| - fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { |
117 |
| - *ResolvedVc::upcast(self.chunking_context) |
118 |
| - } |
119 |
| - |
120 |
| - #[turbo_tasks::function] |
121 |
| - async fn ty(&self) -> Result<Vc<Box<dyn ChunkType>>> { |
122 |
| - Ok(Vc::upcast(Vc::<CssChunkType>::default().resolve().await?)) |
123 |
| - } |
124 |
| - |
125 |
| - #[turbo_tasks::function] |
126 |
| - fn module(&self) -> Vc<Box<dyn Module>> { |
127 |
| - *ResolvedVc::upcast(self.module) |
128 |
| - } |
129 |
| -} |
130 |
| - |
131 |
| -#[turbo_tasks::value_impl] |
132 |
| -impl CssChunkItem for StaticUrlCssChunkItem { |
133 |
| - #[turbo_tasks::function] |
134 |
| - fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { |
135 |
| - *self.chunking_context |
136 |
| - } |
137 |
| - |
138 |
| - #[turbo_tasks::function] |
139 |
| - async fn content(&self) -> Result<Vc<CssChunkItemContent>> { |
140 |
| - Ok(CssChunkItemContent { |
141 |
| - import_context: None, |
142 |
| - imports: Vec::new(), |
143 |
| - source_map: None, |
144 |
| - inner_code: format!( |
145 |
| - "/* embedded static asset {path} */", |
146 |
| - path = StringifyJs( |
147 |
| - &self |
148 |
| - .chunking_context |
149 |
| - .asset_url(self.static_asset.path()) |
150 |
| - .await? |
151 |
| - ) |
152 |
| - ) |
153 |
| - .into(), |
154 |
| - } |
155 |
| - .into()) |
156 |
| - } |
157 |
| -} |
158 |
| - |
159 |
| -#[turbo_tasks::value_impl] |
160 |
| -impl CssEmbed for StaticUrlCssChunkItem { |
| 59 | +impl CssEmbed for StaticUrlCssModule { |
161 | 60 | #[turbo_tasks::function]
|
162 |
| - fn embedded_asset(&self) -> Vc<Box<dyn OutputAsset>> { |
163 |
| - *ResolvedVc::upcast(self.static_asset) |
| 61 | + fn embedded_asset( |
| 62 | + self: Vc<Self>, |
| 63 | + chunking_context: Vc<Box<dyn ChunkingContext>>, |
| 64 | + ) -> Vc<Box<dyn OutputAsset>> { |
| 65 | + Vc::upcast(self.static_output_asset(chunking_context)) |
164 | 66 | }
|
165 | 67 | }
|
166 | 68 |
|
|
0 commit comments