diff --git a/packages/next-swc/crates/next-build/src/next_app/app_client_reference.rs b/packages/next-swc/crates/next-build/src/next_app/app_client_reference.rs index aca7bd2104b22..d57e11478330b 100644 --- a/packages/next-swc/crates/next-build/src/next_app/app_client_reference.rs +++ b/packages/next-swc/crates/next-build/src/next_app/app_client_reference.rs @@ -7,8 +7,8 @@ use turbo_tasks::TryJoinIterExt; use turbopack_binding::turbopack::{ build::BuildChunkingContextVc, core::{ - asset::{AssetVc, AssetsVc}, chunk::{ChunkableModule, ChunkingContext}, + output::{OutputAssetVc, OutputAssetsVc}, }, ecmascript::chunk::EcmascriptChunkingContextVc, }; @@ -22,7 +22,7 @@ pub async fn compute_app_client_references_chunks( app_client_reference_types: &HashSet, client_chunking_context: EcmascriptChunkingContextVc, ssr_chunking_context: BuildChunkingContextVc, - all_chunks: &mut Vec, + all_chunks: &mut Vec, ) -> Result> { let app_client_references_chunks: IndexMap<_, _> = app_client_reference_types .iter() @@ -50,7 +50,7 @@ pub async fn compute_app_client_references_chunks( .as_root_chunk(client_chunking_context.into()); ClientReferenceChunks { client_chunks: client_chunking_context.chunk_group(client_entry_chunk), - ssr_chunks: AssetsVc::empty(), + ssr_chunks: OutputAssetsVc::empty(), } } }, @@ -82,7 +82,7 @@ pub async fn compute_app_client_references_chunks( /// Contains the chunks corresponding to a client reference. pub struct ClientReferenceChunks { /// Chunks to be loaded on the client. - pub client_chunks: AssetsVc, + pub client_chunks: OutputAssetsVc, /// Chunks to be loaded on the server for SSR. - pub ssr_chunks: AssetsVc, + pub ssr_chunks: OutputAssetsVc, } diff --git a/packages/next-swc/crates/next-build/src/next_app/app_entries.rs b/packages/next-swc/crates/next-build/src/next_app/app_entries.rs index 7b0eda099dc19..27264f09411b5 100644 --- a/packages/next-swc/crates/next-build/src/next_app/app_entries.rs +++ b/packages/next-swc/crates/next-build/src/next_app/app_entries.rs @@ -29,13 +29,15 @@ use turbopack_binding::{ turbopack::{ build::BuildChunkingContextVc, core::{ - asset::{Asset, AssetVc, AssetsVc}, + asset::{Asset, AssetVc}, chunk::{ availability_info::AvailabilityInfo, ChunkingContext, EvaluatableAssetsVc, ModuleId as TurbopackModuleId, }, compile_time_info::CompileTimeInfoVc, file_source::FileSourceVc, + output::{OutputAssetVc, OutputAssetsVc}, + raw_output::RawOutputVc, virtual_source::VirtualSourceVc, }, ecmascript::{ @@ -285,7 +287,7 @@ pub async fn compute_app_entries_chunks( app_build_manifest: &mut AppBuildManifest, build_manifest: &mut BuildManifest, app_paths_manifest: &mut AppPathsManifest, - all_chunks: &mut Vec, + all_chunks: &mut Vec, ) -> Result<()> { let node_root_ref = node_root.await?; @@ -519,7 +521,7 @@ pub async fn compute_app_entries_chunks( }) .into(), ); - all_chunks.push(client_reference_manifest_source.into()); + all_chunks.push(RawOutputVc::new(client_reference_manifest_source.into()).into()); } Ok(()) @@ -553,9 +555,9 @@ pub async fn get_app_shared_client_chunk( pub async fn get_app_client_shared_chunks( app_client_runtime_entries: EvaluatableAssetsVc, client_chunking_context: EcmascriptChunkingContextVc, -) -> Result { +) -> Result { if app_client_runtime_entries.await?.is_empty() { - return Ok(AssetsVc::empty()); + return Ok(OutputAssetsVc::empty()); } let app_client_shared_chunk = diff --git a/packages/next-swc/crates/next-build/src/next_build.rs b/packages/next-swc/crates/next-build/src/next_build.rs index 61f7fd3e0007e..8d7a0e207b081 100644 --- a/packages/next-swc/crates/next-build/src/next_build.rs +++ b/packages/next-swc/crates/next-build/src/next_build.rs @@ -35,6 +35,7 @@ use turbopack_binding::{ chunk::ChunkingContext, environment::ServerAddrVc, issue::{IssueReporter, IssueReporterVc, IssueSeverity, IssueVc}, + output::{OutputAssetVc, OutputAssetsVc}, reference::AssetReference, virtual_fs::VirtualFileSystemVc, }, @@ -501,12 +502,12 @@ async fn handle_issues + CollectiblesSource + Copy>( /// Emits all assets transitively reachable from the given chunks, that are /// inside the node root or the client root. async fn emit_all_assets( - chunks: Vec, + chunks: Vec, node_root: &FileSystemPath, client_relative_path: FileSystemPathVc, client_output_path: FileSystemPathVc, ) -> Result { - let all_assets = all_assets_from_entries(AssetsVc::cell(chunks)).await?; + let all_assets = all_assets_from_entries(OutputAssetsVc::cell(chunks)).await?; Ok(CompletionsVc::all( all_assets .iter() @@ -547,11 +548,14 @@ fn emit_rebase(asset: AssetVc, from: FileSystemPathVc, to: FileSystemPathVc) -> /// Walks the asset graph from multiple assets and collect all referenced /// assets. #[turbo_tasks::function] -async fn all_assets_from_entries(entries: AssetsVc) -> Result { +async fn all_assets_from_entries(entries: OutputAssetsVc) -> Result { Ok(AssetsVc::cell( AdjacencyMap::new() .skip_duplicates() - .visit(entries.await?.iter().copied(), get_referenced_assets) + .visit( + entries.await?.iter().copied().map(Into::into), + get_referenced_assets, + ) .await .completed()? .into_inner() diff --git a/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs b/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs index 2b81cf8541f61..2772f5846cdd7 100644 --- a/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs +++ b/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs @@ -27,11 +27,12 @@ use turbopack_binding::{ turbopack::{ build::BuildChunkingContextVc, core::{ - asset::{Asset, AssetVc}, + asset::Asset, chunk::{ChunkableModule, ChunkingContext, EvaluatableAssetsVc}, compile_time_info::CompileTimeInfoVc, context::{AssetContext, AssetContextVc}, file_source::FileSourceVc, + output::OutputAssetVc, reference_type::{EntryReferenceSubType, ReferenceType}, source::SourceVc, }, @@ -349,7 +350,7 @@ pub async fn compute_page_entries_chunks( client_relative_path: &FileSystemPath, pages_manifest: &mut PagesManifest, build_manifest: &mut BuildManifest, - all_chunks: &mut Vec, + all_chunks: &mut Vec, ) -> Result<()> { for page_entry in page_entries.entries.iter() { let page_entry = page_entry.await?; diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs index 8455313381c6a..7325f3629d2c3 100644 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs @@ -9,7 +9,7 @@ use turbopack_binding::{ }, turbopack::{ core::{ - asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, + asset::{Asset, AssetContentVc, AssetVc}, chunk::{ availability_info::AvailabilityInfo, ChunkDataVc, ChunkGroupReferenceVc, ChunkItem, ChunkItemVc, ChunkVc, ChunkableModule, ChunkableModuleVc, ChunkingContext, @@ -17,6 +17,7 @@ use turbopack_binding::{ }, ident::AssetIdentVc, module::{Module, ModuleVc}, + output::OutputAssetsVc, reference::AssetReferencesVc, }, ecmascript::{ @@ -68,7 +69,7 @@ impl WithChunksAssetVc { } #[turbo_tasks::function] - async fn chunks(self) -> Result { + async fn chunks(self) -> Result { let this = self.await?; Ok(this.chunking_context.chunk_group(self.entry_chunk())) } diff --git a/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs b/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs index 4ad161b043c7f..b96247a89347e 100644 --- a/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs @@ -5,7 +5,7 @@ use turbopack_binding::{ turbo::tasks_fs::FileSystemPathVc, turbopack::{ core::{ - asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, + asset::{Asset, AssetContentVc, AssetVc}, chunk::{ availability_info::AvailabilityInfo, ChunkDataVc, ChunkItem, ChunkItemVc, ChunkVc, ChunkableModule, ChunkableModuleReference, ChunkableModuleReferenceVc, @@ -14,6 +14,7 @@ use turbopack_binding::{ }, ident::AssetIdentVc, module::{Module, ModuleVc}, + output::OutputAssetsVc, proxied_asset::ProxiedAssetVc, reference::{ AssetReference, AssetReferenceVc, AssetReferencesVc, SingleAssetReferenceVc, @@ -122,7 +123,7 @@ struct WithClientChunksChunkItem { #[turbo_tasks::value_impl] impl WithClientChunksChunkItemVc { #[turbo_tasks::function] - async fn chunks(self) -> Result { + async fn chunks(self) -> Result { let this = self.await?; let inner = this.inner.await?; Ok(this @@ -131,25 +132,26 @@ impl WithClientChunksChunkItemVc { } #[turbo_tasks::function] - async fn client_chunks(self) -> Result { + async fn client_chunks(self) -> Result { let this = self.await?; let inner = this.inner.await?; let chunks = self.chunks(); let output_root = this.context.output_root().await?; let mut client_chunks = Vec::new(); - for chunk in &*chunks.await? { + for &chunk in &*chunks.await? { let extension = chunk.ident().path().extension().await?; // Only expose CSS chunks as client chunks. if &*extension == "css" { if let Some(path) = output_root.get_path_to(&*chunk.ident().path().await?) { - client_chunks - .push(ProxiedAssetVc::new(*chunk, inner.server_root.join(path)).into()); + client_chunks.push( + ProxiedAssetVc::new(chunk.into(), inner.server_root.join(path)).into(), + ); } } } - Ok(AssetsVc::cell(client_chunks)) + Ok(OutputAssetsVc::cell(client_chunks)) } #[turbo_tasks::function] @@ -227,7 +229,7 @@ impl ChunkItem for WithClientChunksChunkItem { let client_chunks = client_chunks.await?; let client_chunk = StringVc::cell("client chunk".to_string()); for &chunk in client_chunks.iter() { - references.push(SingleAssetReferenceVc::new(chunk, client_chunk).into()); + references.push(SingleAssetReferenceVc::new(chunk.into(), client_chunk).into()); } for chunk_data in &*self_vc.chunks_data().await? { references.extend(chunk_data.references().await?.iter().copied()); diff --git a/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs b/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs index 9c5963a8965ea..cd16eeda2cecb 100644 --- a/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs +++ b/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs @@ -1,10 +1,11 @@ use anyhow::{bail, Result}; use turbo_tasks::primitives::StringVc; use turbopack_binding::turbopack::core::{ - asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, + asset::{Asset, AssetContentVc, AssetVc}, chunk::{ChunkableModule, ChunkableModuleVc, ChunkingContext, ChunkingContextVc}, ident::AssetIdentVc, module::{Module, ModuleVc}, + output::OutputAssetsVc, reference::AssetReferencesVc, }; @@ -31,7 +32,7 @@ impl NextDynamicEntryModuleVc { pub async fn client_chunks( self, client_chunking_context: ChunkingContextVc, - ) -> Result { + ) -> Result { let this = self.await?; let Some(client_entry_module) = diff --git a/packages/next-swc/crates/next-core/src/page_loader.rs b/packages/next-swc/crates/next-core/src/page_loader.rs index daa039404dbf5..e967dfa57d17e 100644 --- a/packages/next-swc/crates/next-core/src/page_loader.rs +++ b/packages/next-swc/crates/next-core/src/page_loader.rs @@ -7,7 +7,7 @@ use turbopack_binding::{ turbo::tasks_fs::{rope::RopeBuilder, File, FileContent, FileSystemPathVc}, turbopack::{ core::{ - asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, + asset::{Asset, AssetContentVc, AssetVc}, chunk::{ ChunkDataVc, ChunkableModule, ChunkingContext, ChunkingContextVc, ChunksDataVc, EvaluatableAssetVc, EvaluatableAssetsVc, @@ -15,6 +15,7 @@ use turbopack_binding::{ context::{AssetContext, AssetContextVc}, ident::AssetIdentVc, module::ModuleVc, + output::OutputAssetsVc, reference::{AssetReferencesVc, SingleAssetReferenceVc}, reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, source::SourceVc, @@ -95,7 +96,7 @@ pub async fn create_page_loader_entry_module( #[turbo_tasks::value_impl] impl PageLoaderAssetVc { #[turbo_tasks::function] - async fn get_page_chunks(self) -> Result { + async fn get_page_chunks(self) -> Result { let this = &*self.await?; let page_loader_entry_asset = @@ -161,10 +162,13 @@ impl Asset for PageLoaderAsset { let chunks = self_vc.get_page_chunks().await?; let mut references = Vec::with_capacity(chunks.len()); - for chunk in chunks.iter() { + for &chunk in chunks.iter() { references.push( - SingleAssetReferenceVc::new(*chunk, page_loader_chunk_reference_description()) - .into(), + SingleAssetReferenceVc::new( + chunk.into(), + page_loader_chunk_reference_description(), + ) + .into(), ); }