@@ -40,7 +40,6 @@ use turbopack_binding::{
4040 turbopack:: {
4141 core:: {
4242 asset:: { Asset , AssetContent } ,
43- changed:: any_content_changed_of_output_assets,
4443 chunk:: { ChunkableModule , ChunkingContext , EvaluatableAssets } ,
4544 file_source:: FileSource ,
4645 output:: { OutputAsset , OutputAssets } ,
@@ -487,15 +486,19 @@ impl AppEndpoint {
487486 async fn output ( self : Vc < Self > ) -> Result < Vc < AppEndpointOutput > > {
488487 let this = self . await ?;
489488
490- let ( app_entry, ty) = match this. ty {
491- AppEndpointType :: Page { ty : _, loader_tree } => {
492- ( self . app_page_entry ( loader_tree) , "page" )
493- }
489+ let ( app_entry, ty, ssr_and_client) = match this. ty {
490+ AppEndpointType :: Page { ty, loader_tree } => (
491+ self . app_page_entry ( loader_tree) ,
492+ "page" ,
493+ matches ! ( ty, AppPageEndpointType :: Html ) ,
494+ ) ,
494495 // NOTE(alexkirsz) For routes, technically, a lot of the following code is not needed,
495496 // as we know we won't have any client references. However, for now, for simplicity's
496497 // sake, we just do the same thing as for pages.
497- AppEndpointType :: Route { path } => ( self . app_route_entry ( path) , "route" ) ,
498- AppEndpointType :: Metadata { metadata } => ( self . app_metadata_entry ( metadata) , "route" ) ,
498+ AppEndpointType :: Route { path } => ( self . app_route_entry ( path) , "route" , false ) ,
499+ AppEndpointType :: Metadata { metadata } => {
500+ ( self . app_metadata_entry ( metadata) , "route" , false )
501+ }
499502 } ;
500503
501504 let node_root = this. app_project . project ( ) . node_root ( ) ;
@@ -562,82 +565,86 @@ impl AppEndpoint {
562565 . entry ( Vc :: upcast ( app_entry. rsc_entry ) )
563566 . await ?;
564567
565- let client_references_chunks = get_app_client_references_chunks (
566- client_reference_types,
567- this. app_project . project ( ) . client_chunking_context ( ) ,
568- this. app_project . project ( ) . ssr_chunking_context ( ) ,
569- ) ;
570- let client_references_chunks_ref = client_references_chunks. await ?;
571-
572- let mut entry_client_chunks = vec ! [ ] ;
573- // TODO(alexkirsz) In which manifest does this go?
574- let mut entry_ssr_chunks = vec ! [ ] ;
575- for client_reference in app_entry_client_references. iter ( ) {
576- let client_reference_chunks = client_references_chunks_ref
577- . get ( client_reference. ty ( ) )
578- . expect ( "client reference should have corresponding chunks" ) ;
579- entry_client_chunks
580- . extend ( client_reference_chunks. client_chunks . await ?. iter ( ) . copied ( ) ) ;
581- entry_ssr_chunks. extend ( client_reference_chunks. ssr_chunks . await ?. iter ( ) . copied ( ) ) ;
582- }
568+ if ssr_and_client {
569+ let client_references_chunks = get_app_client_references_chunks (
570+ client_reference_types,
571+ this. app_project . project ( ) . client_chunking_context ( ) ,
572+ this. app_project . project ( ) . ssr_chunking_context ( ) ,
573+ ) ;
574+ let client_references_chunks_ref = client_references_chunks. await ?;
575+
576+ let mut entry_client_chunks = vec ! [ ] ;
577+ // TODO(alexkirsz) In which manifest does this go?
578+ let mut entry_ssr_chunks = vec ! [ ] ;
579+ for client_reference in app_entry_client_references. iter ( ) {
580+ let client_reference_chunks = client_references_chunks_ref
581+ . get ( client_reference. ty ( ) )
582+ . expect ( "client reference should have corresponding chunks" ) ;
583+ entry_client_chunks
584+ . extend ( client_reference_chunks. client_chunks . await ?. iter ( ) . copied ( ) ) ;
585+ entry_ssr_chunks. extend ( client_reference_chunks. ssr_chunks . await ?. iter ( ) . copied ( ) ) ;
586+ }
583587
584- client_assets. extend ( entry_client_chunks. iter ( ) . copied ( ) ) ;
585- server_assets. extend ( entry_ssr_chunks. iter ( ) . copied ( ) ) ;
588+ client_assets. extend ( entry_client_chunks. iter ( ) . copied ( ) ) ;
589+ server_assets. extend ( entry_ssr_chunks. iter ( ) . copied ( ) ) ;
586590
587- let entry_client_chunks_paths = entry_client_chunks
588- . iter ( )
589- . map ( |chunk| chunk. ident ( ) . path ( ) )
590- . try_join ( )
591- . await ?;
592- let mut entry_client_chunks_paths: Vec < _ > = entry_client_chunks_paths
593- . iter ( )
594- . map ( |path| {
595- client_relative_path_ref
596- . get_path_to ( path)
597- . expect ( "asset path should be inside client root" )
598- . to_string ( )
599- } )
600- . collect ( ) ;
601- entry_client_chunks_paths. extend ( client_shared_chunks_paths. iter ( ) . cloned ( ) ) ;
591+ let entry_client_chunks_paths = entry_client_chunks
592+ . iter ( )
593+ . map ( |chunk| chunk. ident ( ) . path ( ) )
594+ . try_join ( )
595+ . await ?;
596+ let mut entry_client_chunks_paths: Vec < _ > = entry_client_chunks_paths
597+ . iter ( )
598+ . map ( |path| {
599+ client_relative_path_ref
600+ . get_path_to ( path)
601+ . expect ( "asset path should be inside client root" )
602+ . to_string ( )
603+ } )
604+ . collect ( ) ;
605+ entry_client_chunks_paths. extend ( client_shared_chunks_paths. iter ( ) . cloned ( ) ) ;
602606
603- let app_build_manifest = AppBuildManifest {
604- pages : [ ( app_entry. original_name . clone ( ) , entry_client_chunks_paths) ]
605- . into_iter ( )
606- . collect ( ) ,
607- } ;
608- let manifest_path_prefix = get_asset_prefix_from_pathname ( & app_entry. pathname ) ;
609- let app_build_manifest_output = Vc :: upcast ( VirtualOutputAsset :: new (
610- node_root. join ( format ! (
611- "server/app{manifest_path_prefix}/{ty}/app-build-manifest.json" ,
612- ) ) ,
613- AssetContent :: file (
614- File :: from ( serde_json:: to_string_pretty ( & app_build_manifest) ?) . into ( ) ,
615- ) ,
616- ) ) ;
617- server_assets. push ( app_build_manifest_output) ;
607+ let app_build_manifest = AppBuildManifest {
608+ pages : [ ( app_entry. original_name . clone ( ) , entry_client_chunks_paths) ]
609+ . into_iter ( )
610+ . collect ( ) ,
611+ } ;
612+ let manifest_path_prefix = get_asset_prefix_from_pathname ( & app_entry. pathname ) ;
613+ let app_build_manifest_output = Vc :: upcast ( VirtualOutputAsset :: new (
614+ node_root. join ( format ! (
615+ "server/app{manifest_path_prefix}/{ty}/app-build-manifest.json" ,
616+ ) ) ,
617+ AssetContent :: file (
618+ File :: from ( serde_json:: to_string_pretty ( & app_build_manifest) ?) . into ( ) ,
619+ ) ,
620+ ) ) ;
621+ server_assets. push ( app_build_manifest_output) ;
618622
619- let build_manifest = BuildManifest {
620- root_main_files : client_shared_chunks_paths,
621- ..Default :: default ( )
622- } ;
623- let build_manifest_output = Vc :: upcast ( VirtualOutputAsset :: new (
624- node_root. join ( format ! (
625- "server/app{manifest_path_prefix}/{ty}/build-manifest.json" ,
626- ) ) ,
627- AssetContent :: file ( File :: from ( serde_json:: to_string_pretty ( & build_manifest) ?) . into ( ) ) ,
628- ) ) ;
629- server_assets. push ( build_manifest_output) ;
630-
631- let entry_manifest = ClientReferenceManifest :: build_output (
632- node_root,
633- client_relative_path,
634- app_entry. original_name . clone ( ) ,
635- client_references,
636- client_references_chunks,
637- this. app_project . project ( ) . client_chunking_context ( ) ,
638- Vc :: upcast ( this. app_project . project ( ) . ssr_chunking_context ( ) ) ,
639- ) ;
640- server_assets. push ( entry_manifest) ;
623+ let build_manifest = BuildManifest {
624+ root_main_files : client_shared_chunks_paths,
625+ ..Default :: default ( )
626+ } ;
627+ let build_manifest_output = Vc :: upcast ( VirtualOutputAsset :: new (
628+ node_root. join ( format ! (
629+ "server/app{manifest_path_prefix}/{ty}/build-manifest.json" ,
630+ ) ) ,
631+ AssetContent :: file (
632+ File :: from ( serde_json:: to_string_pretty ( & build_manifest) ?) . into ( ) ,
633+ ) ,
634+ ) ) ;
635+ server_assets. push ( build_manifest_output) ;
636+
637+ let entry_manifest = ClientReferenceManifest :: build_output (
638+ node_root,
639+ client_relative_path,
640+ app_entry. original_name . clone ( ) ,
641+ client_references,
642+ client_references_chunks,
643+ this. app_project . project ( ) . client_chunking_context ( ) ,
644+ Vc :: upcast ( this. app_project . project ( ) . ssr_chunking_context ( ) ) ,
645+ ) ;
646+ server_assets. push ( entry_manifest) ;
647+ }
641648
642649 fn create_app_paths_manifest (
643650 node_root : Vc < FileSystemPath > ,
@@ -897,13 +904,21 @@ impl Endpoint for AppEndpoint {
897904 }
898905
899906 #[ turbo_tasks:: function]
900- fn server_changed ( self : Vc < Self > ) -> Vc < Completion > {
901- any_content_changed_of_output_assets ( self . output ( ) . server_assets ( ) )
907+ async fn server_changed ( self : Vc < Self > ) -> Result < Vc < Completion > > {
908+ Ok ( self
909+ . await ?
910+ . app_project
911+ . project ( )
912+ . server_changed ( self . output ( ) . server_assets ( ) ) )
902913 }
903914
904915 #[ turbo_tasks:: function]
905- fn client_changed ( self : Vc < Self > ) -> Vc < Completion > {
906- any_content_changed_of_output_assets ( self . output ( ) . client_assets ( ) )
916+ async fn client_changed ( self : Vc < Self > ) -> Result < Vc < Completion > > {
917+ Ok ( self
918+ . await ?
919+ . app_project
920+ . project ( )
921+ . client_changed ( self . output ( ) . client_assets ( ) ) )
907922 }
908923}
909924
0 commit comments