diff --git a/crates/next-api/src/middleware.rs b/crates/next-api/src/middleware.rs index 0fb10243c7bdc..e6c290742af3f 100644 --- a/crates/next-api/src/middleware.rs +++ b/crates/next-api/src/middleware.rs @@ -8,7 +8,7 @@ use next_core::{ util::{parse_config_from_source, MiddlewareMatcherKind}, }; use tracing::Instrument; -use turbo_tasks::{Completion, RcStr, Value, Vc}; +use turbo_tasks::{Completion, RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_fs::{self, File, FileContent, FileSystemPath}; use turbopack_core::{ asset::AssetContent, @@ -36,8 +36,8 @@ pub struct MiddlewareEndpoint { project: Vc, asset_context: Vc>, source: Vc>, - app_dir: Option>, - ecmascript_client_reference_transition_name: Option>, + app_dir: Option>, + ecmascript_client_reference_transition_name: Option>, } #[turbo_tasks::value_impl] @@ -47,8 +47,8 @@ impl MiddlewareEndpoint { project: Vc, asset_context: Vc>, source: Vc>, - app_dir: Option>, - ecmascript_client_reference_transition_name: Option>, + app_dir: Option>, + ecmascript_client_reference_transition_name: Option>, ) -> Vc { Self { project, @@ -85,9 +85,11 @@ impl MiddlewareEndpoint { let mut evaluatable_assets = get_server_runtime_entries( Value::new(ServerContextType::Middleware { - app_dir: self.app_dir, + app_dir: self.app_dir.as_deref().copied(), ecmascript_client_reference_transition_name: self - .ecmascript_client_reference_transition_name, + .ecmascript_client_reference_transition_name + .as_deref() + .copied(), }), self.project.next_mode(), ) diff --git a/crates/next-api/src/pages.rs b/crates/next-api/src/pages.rs index 388c6eda68408..e2887ed623c28 100644 --- a/crates/next-api/src/pages.rs +++ b/crates/next-api/src/pages.rs @@ -139,7 +139,7 @@ impl PagesProject { Ok(()) } - if let Some(api) = api { + if let Some(api) = *api { add_dir_to_routes(&mut routes, *api, |pathname, original_name, page| { Route::PageApi { endpoint: Vc::upcast(PageEndpoint::new( @@ -174,7 +174,7 @@ impl PagesProject { )), }; - if let Some(pages) = pages { + if let Some(pages) = *pages { add_dir_to_routes(&mut routes, *pages, make_page_route).await?; } diff --git a/crates/next-core/src/app_page_loader_tree.rs b/crates/next-core/src/app_page_loader_tree.rs index 379b1934b9eff..f043b4f3e6669 100644 --- a/crates/next-core/src/app_page_loader_tree.rs +++ b/crates/next-core/src/app_page_loader_tree.rs @@ -344,7 +344,7 @@ impl AppPageLoaderTreeBuilder { .await?; self.write_modules_entry(AppDirModuleType::DefaultPage, *default) .await?; - self.write_modules_entry(AppDirModuleType::GlobalError, *global_error) + self.write_modules_entry(AppDirModuleType::GlobalError, global_error.map(|err| *err)) .await?; let modules_code = replace(&mut self.loader_tree_code, temp_loader_tree_code); @@ -373,7 +373,7 @@ impl AppPageLoaderTreeBuilder { if let Some(global_error) = modules.global_error { let module = self .base - .process_source(Vc::upcast(FileSource::new(global_error))); + .process_source(Vc::upcast(FileSource::new(*global_error))); self.base.inner_assets.insert(GLOBAL_ERROR.into(), module); }; diff --git a/crates/next-core/src/app_structure.rs b/crates/next-core/src/app_structure.rs index c813281a65463..350e5e51d9b91 100644 --- a/crates/next-core/src/app_structure.rs +++ b/crates/next-core/src/app_structure.rs @@ -36,7 +36,7 @@ pub struct AppDirModules { #[serde(skip_serializing_if = "Option::is_none")] pub error: Option>, #[serde(skip_serializing_if = "Option::is_none")] - pub global_error: Option>, + pub global_error: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub loading: Option>, #[serde(skip_serializing_if = "Option::is_none")] @@ -46,7 +46,7 @@ pub struct AppDirModules { #[serde(skip_serializing_if = "Option::is_none")] pub default: Option>, #[serde(skip_serializing_if = "Option::is_none")] - pub route: Option>, + pub route: Option>, #[serde(skip_serializing_if = "Metadata::is_empty", default)] pub metadata: Metadata, } @@ -199,7 +199,7 @@ impl GlobalMetadata { #[derive(Debug)] pub struct DirectoryTree { /// key is e.g. "dashboard", "(dashboard)", "@slot" - pub subdirectories: BTreeMap>, + pub subdirectories: BTreeMap>, pub modules: AppDirModules, } @@ -302,12 +302,12 @@ async fn get_directory_tree_internal( "page" => modules.page = Some(*file), "layout" => modules.layout = Some(*file), "error" => modules.error = Some(*file), - "global-error" => modules.global_error = Some(*file), + "global-error" => modules.global_error = Some(file), "loading" => modules.loading = Some(*file), "template" => modules.template = Some(*file), "not-found" => modules.not_found = Some(*file), "default" => modules.default = Some(*file), - "route" => modules.route = Some(*file), + "route" => modules.route = Some(file), _ => {} } } @@ -363,7 +363,9 @@ async fn get_directory_tree_internal( DirectoryEntry::Directory(dir) => { // appDir ignores paths starting with an underscore if !basename.starts_with('_') { - let result = get_directory_tree(*dir, page_extensions); + let result = get_directory_tree(*dir, page_extensions) + .to_resolved() + .await?; subdirectories.insert(basename.clone(), result); } } @@ -1232,7 +1234,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( app_dir, global_metadata, subdir_name.clone(), - subdirectory, + *subdirectory, child_app_page.clone(), *root_layouts, ) diff --git a/crates/next-core/src/next_client_reference/visit_client_reference.rs b/crates/next-core/src/next_client_reference/visit_client_reference.rs index 024f897586f16..1b67ba5064907 100644 --- a/crates/next-core/src/next_client_reference/visit_client_reference.rs +++ b/crates/next-core/src/next_client_reference/visit_client_reference.rs @@ -7,7 +7,7 @@ use turbo_tasks::{ debug::ValueDebugFormat, graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow, VisitedNodes}, trace::TraceRawVcs, - FxIndexMap, FxIndexSet, RcStr, ReadRef, TryJoinIterExt, ValueToString, Vc, + FxIndexMap, FxIndexSet, RcStr, ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc, }; use turbo_tasks_fs::FileSystemPath; use turbopack::css::CssModuleAsset; @@ -121,7 +121,7 @@ impl ClientReferenceGraphResult { #[turbo_tasks::function] pub async fn client_reference_graph( - entries: Vec>>, + entries: Vec>>, visited_nodes: Vc, ) -> Result> { async move { @@ -143,11 +143,11 @@ pub async fn client_reference_graph( .map(|module| async move { Ok(VisitClientReferenceNode { state: if let Some(server_component) = - Vc::try_resolve_downcast_type::(module) + ResolvedVc::try_downcast_type::(module) .await? { VisitClientReferenceNodeState::InServerComponent { - server_component, + server_component: *server_component, } } else { VisitClientReferenceNodeState::Entry { @@ -190,10 +190,10 @@ pub async fn client_reference_graph( } } VisitClientReferenceNodeType::ServerUtilEntry(server_util, _) => { - server_utils.push(*server_util); + server_utils.push(**server_util); } VisitClientReferenceNodeType::ServerComponentEntry(server_component, _) => { - server_component_entries.push(*server_component); + server_component_entries.push(**server_component); } } } @@ -219,7 +219,7 @@ pub struct ServerEntries { } #[turbo_tasks::function] -pub async fn find_server_entries(entry: Vc>) -> Result> { +pub async fn find_server_entries(entry: ResolvedVc>) -> Result> { let graph = AdjacencyMap::new() .skip_duplicates() .visit( @@ -244,10 +244,10 @@ pub async fn find_server_entries(entry: Vc>) -> Result { - server_utils.push(*server_util); + server_utils.push(**server_util); } VisitClientReferenceNodeType::ServerComponentEntry(server_component, _) => { - server_component_entries.push(*server_component); + server_component_entries.push(**server_component); } VisitClientReferenceNodeType::Internal(_, _) | VisitClientReferenceNodeType::ClientReference(_, _) => {} @@ -303,9 +303,9 @@ impl VisitClientReferenceNodeState { )] enum VisitClientReferenceNodeType { ClientReference(ClientReference, ReadRef), - ServerComponentEntry(Vc, ReadRef), - ServerUtilEntry(Vc>, ReadRef), - Internal(Vc>, ReadRef), + ServerComponentEntry(ResolvedVc, ReadRef), + ServerUtilEntry(ResolvedVc>, ReadRef), + Internal(ResolvedVc>, ReadRef), } impl Visit for VisitClientReference { @@ -343,15 +343,17 @@ impl Visit for VisitClientReference { VisitClientReferenceNodeType::ClientReference(..) => return Ok(vec![]), VisitClientReferenceNodeType::Internal(module, _) => module, VisitClientReferenceNodeType::ServerUtilEntry(module, _) => module, - VisitClientReferenceNodeType::ServerComponentEntry(module, _) => Vc::upcast(module), + VisitClientReferenceNodeType::ServerComponentEntry(module, _) => { + ResolvedVc::upcast(module) + } }; - let referenced_modules = primary_referenced_modules(parent_module).await?; + let referenced_modules = primary_referenced_modules(*parent_module).await?; let referenced_modules = referenced_modules.iter().map(|module| async move { - let module = module.resolve().await?; + let module = module.to_resolved().await?; if let Some(client_reference_module) = - Vc::try_resolve_downcast_type::(module).await? + ResolvedVc::try_downcast_type::(module).await? { return Ok(VisitClientReferenceNode { state: node.state, @@ -359,14 +361,14 @@ impl Visit for VisitClientReference { ClientReference { server_component: node.state.server_component(), ty: ClientReferenceType::EcmascriptClientReference { - parent_module: Vc::try_resolve_downcast_type::< + parent_module: *ResolvedVc::try_downcast_type::< EcmascriptClientReferenceProxyModule, >( parent_module ) .await? .unwrap(), - module: client_reference_module, + module: *client_reference_module, }, }, client_reference_module.ident().to_string().await?, @@ -375,7 +377,7 @@ impl Visit for VisitClientReference { } if let Some(css_client_reference_asset) = - Vc::try_resolve_downcast_type::(module).await? + ResolvedVc::try_downcast_type::(module).await? { return Ok(VisitClientReferenceNode { state: node.state, @@ -383,7 +385,7 @@ impl Visit for VisitClientReference { ClientReference { server_component: node.state.server_component(), ty: ClientReferenceType::CssClientReference( - css_client_reference_asset, + *css_client_reference_asset, ), }, css_client_reference_asset.ident().to_string().await?, @@ -392,11 +394,11 @@ impl Visit for VisitClientReference { } if let Some(server_component_asset) = - Vc::try_resolve_downcast_type::(module).await? + ResolvedVc::try_downcast_type::(module).await? { return Ok(VisitClientReferenceNode { state: VisitClientReferenceNodeState::InServerComponent { - server_component: server_component_asset, + server_component: *server_component_asset, }, ty: VisitClientReferenceNodeType::ServerComponentEntry( server_component_asset, diff --git a/crates/next-core/src/next_dynamic/visit_dynamic.rs b/crates/next-core/src/next_dynamic/visit_dynamic.rs index 68a20554d011f..568c9222fddf5 100644 --- a/crates/next-core/src/next_dynamic/visit_dynamic.rs +++ b/crates/next-core/src/next_dynamic/visit_dynamic.rs @@ -4,7 +4,7 @@ use anyhow::Result; use tracing::Instrument; use turbo_tasks::{ graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow}, - RcStr, ReadRef, TryJoinIterExt, ValueToString, Vc, + RcStr, ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc, }; use turbopack_core::{ module::{Module, Modules}, @@ -29,7 +29,10 @@ impl NextDynamicEntries { .iter() .copied() .map(|m| async move { - Ok(VisitDynamicNode::Internal(m, m.ident().to_string().await?)) + Ok(VisitDynamicNode::Internal( + m.to_resolved().await?, + m.ident().to_string().await?, + )) }) .try_join() .await?, @@ -50,7 +53,7 @@ impl NextDynamicEntries { // traversal. } VisitDynamicNode::Dynamic(dynamic_asset, _) => { - next_dynamics.push(dynamic_asset); + next_dynamics.push(*dynamic_asset); } } } @@ -66,8 +69,8 @@ struct VisitDynamic; #[derive(Clone, Eq, PartialEq, Hash)] enum VisitDynamicNode { - Dynamic(Vc, ReadRef), - Internal(Vc>, ReadRef), + Dynamic(ResolvedVc, ReadRef), + Internal(ResolvedVc>, ReadRef), } impl Visit for VisitDynamic { @@ -85,16 +88,16 @@ impl Visit for VisitDynamic { let node = node.clone(); async move { let module = match node { - VisitDynamicNode::Dynamic(dynamic_module, _) => Vc::upcast(dynamic_module), + VisitDynamicNode::Dynamic(dynamic_module, _) => ResolvedVc::upcast(dynamic_module), VisitDynamicNode::Internal(module, _) => module, }; - let referenced_modules = primary_referenced_modules(module).await?; + let referenced_modules = primary_referenced_modules(*module).await?; let referenced_modules = referenced_modules.iter().map(|module| async move { - let module = module.resolve().await?; + let module = module.to_resolved().await?; if let Some(next_dynamic_module) = - Vc::try_resolve_downcast_type::(module).await? + ResolvedVc::try_downcast_type::(module).await? { return Ok(VisitDynamicNode::Dynamic( next_dynamic_module, diff --git a/crates/next-core/src/next_image/source_asset.rs b/crates/next-core/src/next_image/source_asset.rs index 34cf0332eaac4..7ed3fa726e731 100644 --- a/crates/next-core/src/next_image/source_asset.rs +++ b/crates/next-core/src/next_image/source_asset.rs @@ -58,7 +58,7 @@ impl Asset for StructuredImageFileSource { let blur_options = blur_options(); match self.blur_placeholder_mode { BlurPlaceholderMode::NextImageUrl => { - let info = get_meta_data(self.image.ident(), content, None).await?; + let info = get_meta_data(self.image.ident(), *content, None).await?; let width = info.width; let height = info.height; let blur_options = blur_options.await?; @@ -86,7 +86,7 @@ impl Asset for StructuredImageFileSource { )?; } BlurPlaceholderMode::DataUrl => { - let info = get_meta_data(self.image.ident(), content, Some(blur_options)).await?; + let info = get_meta_data(self.image.ident(), *content, Some(blur_options)).await?; writeln!( result, "export default {{ src, width: {width}, height: {height}, blurDataURL: \ @@ -102,7 +102,7 @@ impl Asset for StructuredImageFileSource { )?; } BlurPlaceholderMode::None => { - let info = get_meta_data(self.image.ident(), content, None).await?; + let info = get_meta_data(self.image.ident(), *content, None).await?; writeln!( result, "export default {{ src, width: {width}, height: {height} }}", @@ -111,6 +111,6 @@ impl Asset for StructuredImageFileSource { )?; } }; - Ok(AssetContent::File(FileContent::Content(result.build().into()).cell()).cell()) + Ok(AssetContent::File(FileContent::Content(result.build().into()).resolved_cell()).cell()) } } diff --git a/crates/next-core/src/pages_structure.rs b/crates/next-core/src/pages_structure.rs index 284623574bcc9..28d4add714f08 100644 --- a/crates/next-core/src/pages_structure.rs +++ b/crates/next-core/src/pages_structure.rs @@ -67,8 +67,8 @@ pub struct PagesStructure { pub app: Vc, pub document: Vc, pub error: Vc, - pub api: Option>, - pub pages: Option>, + pub api: Option>, + pub pages: Option>, } #[turbo_tasks::value_impl] @@ -197,12 +197,16 @@ async fn get_pages_structure_for_root_directory( } DirectoryEntry::Directory(dir_project_path) => match name.as_str() { "api" => { - api_directory = Some(get_pages_structure_for_directory( - *dir_project_path, - next_router_path.join(name.clone()), - 1, - page_extensions, - )); + api_directory = Some( + get_pages_structure_for_directory( + *dir_project_path, + next_router_path.join(name.clone()), + 1, + page_extensions, + ) + .to_resolved() + .await?, + ); } _ => { children.push(( @@ -232,7 +236,7 @@ async fn get_pages_structure_for_root_directory( items: items.into_iter().map(|(_, v)| v).collect(), children: children.into_iter().map(|(_, v)| v).collect(), } - .cell(), + .resolved_cell(), ) } else { None diff --git a/turbopack/crates/turbopack-core/src/asset.rs b/turbopack/crates/turbopack-core/src/asset.rs index 6e3784ce9abdf..6155fb564ae82 100644 --- a/turbopack/crates/turbopack-core/src/asset.rs +++ b/turbopack/crates/turbopack-core/src/asset.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{Completion, RcStr, Vc}; +use turbo_tasks::{Completion, RcStr, ResolvedVc, Vc}; use turbo_tasks_fs::{ FileContent, FileJsonContent, FileLinesContent, FileSystemPath, LinkContent, LinkType, }; @@ -21,7 +21,7 @@ pub trait Asset { #[turbo_tasks::value(shared)] #[derive(Clone)] pub enum AssetContent { - File(Vc), + File(ResolvedVc), // for the relative link, the target is raw value read from the link // for the absolute link, the target is stripped of the root path while reading // See [LinkContent::Link] for more details. @@ -31,8 +31,8 @@ pub enum AssetContent { #[turbo_tasks::value_impl] impl AssetContent { #[turbo_tasks::function] - pub fn file(file: Vc) -> Vc { - AssetContent::File(file).cell() + pub async fn file(file: ResolvedVc) -> Result> { + Ok(AssetContent::File(file).cell()) } #[turbo_tasks::function] @@ -50,7 +50,7 @@ impl AssetContent { pub async fn file_content(self: Vc) -> Result> { let this = self.await?; match &*this { - AssetContent::File(content) => Ok(*content), + AssetContent::File(content) => Ok(**content), AssetContent::Redirect { .. } => Ok(FileContent::NotFound.cell()), } } @@ -88,7 +88,7 @@ impl AssetContent { pub async fn write(self: Vc, path: Vc) -> Result> { let this = self.await?; Ok(match &*this { - AssetContent::File(file) => path.write(*file), + AssetContent::File(file) => path.write(**file), AssetContent::Redirect { target, link_type } => path.write_link( LinkContent::Link { target: target.clone(), diff --git a/turbopack/crates/turbopack-core/src/chunk/chunking.rs b/turbopack/crates/turbopack-core/src/chunk/chunking.rs index b2f783923cd2a..976e0a2358e6a 100644 --- a/turbopack/crates/turbopack-core/src/chunk/chunking.rs +++ b/turbopack/crates/turbopack-core/src/chunk/chunking.rs @@ -106,7 +106,14 @@ pub async fn make_chunks( } } - Ok(Vc::cell(chunks)) + // Resolve all chunks before returning + let resolved_chunks = chunks + .into_iter() + .map(|chunk| chunk.to_resolved()) + .try_join() + .await?; + + Ok(Vc::cell(resolved_chunks)) } type ChunkItemWithInfo = ( diff --git a/turbopack/crates/turbopack-core/src/chunk/mod.rs b/turbopack/crates/turbopack-core/src/chunk/mod.rs index ebb8e19394cdd..9971d7ce1af1e 100644 --- a/turbopack/crates/turbopack-core/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-core/src/chunk/mod.rs @@ -96,7 +96,7 @@ pub trait ChunkableModule: Module + Asset { } #[turbo_tasks::value(transparent)] -pub struct Chunks(Vec>>); +pub struct Chunks(Vec>>); #[turbo_tasks::value_impl] impl Chunks { diff --git a/turbopack/crates/turbopack-core/src/file_source.rs b/turbopack/crates/turbopack-core/src/file_source.rs index ca0f204f5630c..5a3158d541597 100644 --- a/turbopack/crates/turbopack-core/src/file_source.rs +++ b/turbopack/crates/turbopack-core/src/file_source.rs @@ -54,9 +54,11 @@ impl Asset for FileSource { .cell()), _ => Err(anyhow::anyhow!("Invalid symlink")), }, - FileSystemEntryType::File => Ok(AssetContent::File(self.path.read()).cell()), + FileSystemEntryType::File => { + Ok(AssetContent::File(self.path.read().to_resolved().await?).cell()) + } FileSystemEntryType::NotFound => { - Ok(AssetContent::File(FileContent::NotFound.cell()).cell()) + Ok(AssetContent::File(FileContent::NotFound.resolved_cell()).cell()) } _ => Err(anyhow::anyhow!("Invalid file type {:?}", file_type)), } diff --git a/turbopack/crates/turbopack-css/src/process.rs b/turbopack/crates/turbopack-css/src/process.rs index 8779c1094377b..7c431b3da5a2a 100644 --- a/turbopack/crates/turbopack-css/src/process.rs +++ b/turbopack/crates/turbopack-css/src/process.rs @@ -502,7 +502,7 @@ pub async fn parse_css( Err(_err) => ParseCssResult::Unparseable.cell(), Ok(string) => { process_content( - *file_content, + **file_content, string.into_owned(), fs_path, ident_str, diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs index b8f00b81fc4df..f2f8e6bfdcfb1 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs @@ -2,7 +2,7 @@ use std::io::Write; use anyhow::{bail, Result}; use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, Upcast, ValueToString, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, Upcast, ValueToString, Vc}; use turbo_tasks_fs::{rope::Rope, FileSystemPath}; use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkItemExt, ChunkingContext}, @@ -24,7 +24,7 @@ pub struct EcmascriptChunkItemContent { pub inner_code: Rope, pub source_map: Option>>, pub options: EcmascriptChunkItemOptions, - pub rewrite_source_path: Option>, + pub rewrite_source_path: Option>, pub placeholder_for_future_extensions: (), } @@ -48,7 +48,7 @@ impl EcmascriptChunkItemContent { Ok(EcmascriptChunkItemContent { rewrite_source_path: if *chunking_context.should_use_file_source_map_uris().await? { - Some(chunking_context.context_path()) + Some(chunking_context.context_path().to_resolved().await?) } else { None }, @@ -153,7 +153,7 @@ impl EcmascriptChunkItemContent { let source_map = if let Some(rewrite_source_path) = self.rewrite_source_path { let source_map = self.source_map.map(|m| m.generate_source_map()); match source_map { - Some(map) => fileify_source_map(map, rewrite_source_path) + Some(map) => fileify_source_map(map, *rewrite_source_path) .await? .map(Vc::upcast), None => None, diff --git a/turbopack/crates/turbopack-mdx/src/lib.rs b/turbopack/crates/turbopack-mdx/src/lib.rs index c829091fac8ef..f4d545f02e97e 100644 --- a/turbopack/crates/turbopack-mdx/src/lib.rs +++ b/turbopack/crates/turbopack-mdx/src/lib.rs @@ -224,7 +224,7 @@ impl MdxTransformedAsset { .emit(); Ok(MdxTransformResult { - content: AssetContent::File(FileContent::NotFound.cell()).cell(), + content: AssetContent::File(FileContent::NotFound.resolved_cell()).cell(), } .cell()) } diff --git a/turbopack/crates/turbopack-node/src/transforms/postcss.rs b/turbopack/crates/turbopack-node/src/transforms/postcss.rs index 3072608b4fc27..369cca8e678be 100644 --- a/turbopack/crates/turbopack-node/src/transforms/postcss.rs +++ b/turbopack/crates/turbopack-node/src/transforms/postcss.rs @@ -285,7 +285,7 @@ impl Asset for JsonSource { Ok(AssetContent::file(File::from(value.to_string()).into())) } FileSystemEntryType::NotFound => { - Ok(AssetContent::File(FileContent::NotFound.cell()).cell()) + Ok(AssetContent::File(FileContent::NotFound.resolved_cell()).cell()) } _ => Err(anyhow::anyhow!("Invalid file type {:?}", file_type)), } @@ -356,11 +356,11 @@ pub(crate) async fn config_loader_source( } #[turbo_tasks::function] -fn postcss_executor( +async fn postcss_executor( asset_context: Vc>, project_path: Vc, postcss_config_path: Vc, -) -> Vc { +) -> Result> { let config_asset = asset_context .process( config_loader_source(project_path, postcss_config_path), @@ -368,15 +368,20 @@ fn postcss_executor( ) .module(); - asset_context.process( + Ok(asset_context.process( Vc::upcast(VirtualSource::new( postcss_config_path.join("transform.ts".into()), - AssetContent::File(embed_file("transforms/postcss.ts".into())).cell(), + AssetContent::File( + embed_file("transforms/postcss.ts".into()) + .to_resolved() + .await?, + ) + .cell(), )), Value::new(ReferenceType::Internal(Vc::cell(fxindexmap! { "CONFIG".into() => config_asset }))), - ) + )) } async fn find_config_in_location( @@ -458,7 +463,7 @@ impl PostCssTransformedAsset { }; let FileContent::Content(content) = &*file.await? else { return Ok(ProcessPostCssResult { - content: AssetContent::File(*FileContent::NotFound.resolved_cell()).cell(), + content: AssetContent::File(FileContent::NotFound.resolved_cell()).cell(), assets: Vec::new(), } .cell()); @@ -501,7 +506,7 @@ impl PostCssTransformedAsset { let SingleValue::Single(val) = config_value.try_into_single().await? else { // An error happened, which has already been converted into an issue. return Ok(ProcessPostCssResult { - content: AssetContent::File(*FileContent::NotFound.resolved_cell()).cell(), + content: AssetContent::File(FileContent::NotFound.resolved_cell()).cell(), assets: Vec::new(), } .cell()); @@ -512,7 +517,7 @@ impl PostCssTransformedAsset { // TODO handle SourceMap let file = File::from(processed_css.css); let assets = emitted_assets_to_virtual_sources(processed_css.assets).await?; - let content = AssetContent::File(FileContent::Content(file).cell()).cell(); + let content = AssetContent::File(FileContent::Content(file).resolved_cell()).cell(); Ok(ProcessPostCssResult { content, assets }.cell()) } } diff --git a/turbopack/crates/turbopack-node/src/transforms/util.rs b/turbopack/crates/turbopack-node/src/transforms/util.rs index 658aef1a302c7..303f7512ccc2d 100644 --- a/turbopack/crates/turbopack-node/src/transforms/util.rs +++ b/turbopack/crates/turbopack-node/src/transforms/util.rs @@ -37,7 +37,8 @@ pub async fn emitted_assets_to_virtual_sources( // TODO handle SourceMap VirtualSource::new( ServerFileSystem::new().root().join(file), - AssetContent::File(FileContent::Content(File::from(content)).cell()).cell(), + AssetContent::File(FileContent::Content(File::from(content)).resolved_cell()) + .cell(), ) .to_resolved() }) diff --git a/turbopack/crates/turbopack-node/src/transforms/webpack.rs b/turbopack/crates/turbopack-node/src/transforms/webpack.rs index 117ca8ace9949..77c0d8a4e53aa 100644 --- a/turbopack/crates/turbopack-node/src/transforms/webpack.rs +++ b/turbopack/crates/turbopack-node/src/transforms/webpack.rs @@ -200,7 +200,7 @@ impl WebpackLoadersProcessedAsset { }; let FileContent::Content(content) = &*file.await? else { return Ok(ProcessWebpackLoadersResult { - content: AssetContent::File(FileContent::NotFound.cell()).cell(), + content: AssetContent::File(FileContent::NotFound.resolved_cell()).cell(), assets: Vec::new(), source_map: None, } @@ -245,7 +245,7 @@ impl WebpackLoadersProcessedAsset { let SingleValue::Single(val) = config_value.try_into_single().await? else { // An error happened, which has already been converted into an issue. return Ok(ProcessWebpackLoadersResult { - content: AssetContent::File(FileContent::NotFound.cell()).cell(), + content: AssetContent::File(FileContent::NotFound.resolved_cell()).cell(), assets: Vec::new(), source_map: None, } @@ -273,7 +273,7 @@ impl WebpackLoadersProcessedAsset { .into_iter() .map(|asset| *asset) .collect(); - let content = AssetContent::File(FileContent::Content(file).cell()).cell(); + let content = AssetContent::File(FileContent::Content(file).resolved_cell()).cell(); Ok(ProcessWebpackLoadersResult { content, assets, diff --git a/turbopack/crates/turbopack/src/lib.rs b/turbopack/crates/turbopack/src/lib.rs index 61d90bdee2541..86941f405cec8 100644 --- a/turbopack/crates/turbopack/src/lib.rs +++ b/turbopack/crates/turbopack/src/lib.rs @@ -844,7 +844,7 @@ type OutputAssetSet = HashSet>>; #[turbo_tasks::value(shared)] struct ReferencesList { - referenced_by: HashMap>, OutputAssetSet>, + referenced_by: HashMap>, OutputAssetSet>, } #[turbo_tasks::function] @@ -853,12 +853,16 @@ async fn compute_back_references(aggregated: Vc) -> Result { let mut referenced_by = HashMap::new(); for reference in asset.references().await?.iter() { - referenced_by.insert(*reference, [asset].into_iter().collect()); + referenced_by.insert( + reference.to_resolved().await?, + [asset].into_iter().collect(), + ); } ReferencesList { referenced_by }.into() } AggregatedGraphNodeContent::Children(children) => { - let mut referenced_by = HashMap::>, OutputAssetSet>::new(); + let mut referenced_by = + HashMap::>, OutputAssetSet>::new(); let lists = children .iter() .map(|child| compute_back_references(*child)) @@ -884,7 +888,7 @@ async fn top_references(list: Vc) -> Result> let list = list.await?; const N: usize = 5; let mut top = Vec::<( - &Vc>, + &ResolvedVc>, &HashSet>>, )>::new(); for tuple in list.referenced_by.iter() {