@@ -54,7 +54,7 @@ type Actions = HashMap<String, Action>;
5454#[ derive( Clone , Serialize ) ]
5555pub struct ModuleInfo {
5656 pub module_id : String ,
57- pub is_async : bool ,
57+ pub r#async : bool ,
5858}
5959
6060#[ derive( Default , Clone ) ]
@@ -449,12 +449,6 @@ pub struct Manifest {
449449 pub edge : Actions ,
450450}
451451
452- #[ derive( Serialize ) ]
453- pub struct LoaderParams {
454- pub modules : String ,
455- pub server : bool ,
456- }
457-
458452#[ plugin]
459453#[ derive( Debug ) ]
460454pub struct FlightClientEntryPlugin {
@@ -638,6 +632,7 @@ impl FlightClientEntryPlugin {
638632
639633 let mut should_invalidate = false ;
640634
635+ // client_imports key 缺少
641636 let mut modules: Vec < _ > = client_imports
642637 . keys ( )
643638 . map ( |client_import_path| {
@@ -658,61 +653,43 @@ impl FlightClientEntryPlugin {
658653 // server is using the ESM build (when using the Edge runtime), we need to
659654 // replace them.
660655 let client_browser_loader = {
661- let modules = if self . is_edge_server {
662- modules
663- . iter ( )
664- . map ( |( request, ids) | {
665- serde_json:: to_string ( & json ! ( {
666- "request" : request. replace(
667- r"/next/dist/esm/" ,
668- & format!( "/next/dist/{}" , std:: path:: MAIN_SEPARATOR )
669- ) ,
670- "ids" : ids
671- } ) )
672- . unwrap ( )
673- } )
674- . join ( "," )
675- } else {
676- modules
677- . iter ( )
678- . map ( |( request, ids) | {
679- serde_json:: to_string ( & json ! ( {
680- "request" : request,
681- "ids" : ids
682- } ) )
683- . unwrap ( )
684- } )
685- . join ( "," )
686- } ;
687- let params = LoaderParams {
688- modules,
689- server : false ,
690- } ;
691- format ! (
692- "next-flight-client-entry-loader?{}!" ,
693- serde_urlencoded:: to_string( params) . unwrap( )
694- )
695- } ;
696-
697- let client_server_loader = {
698- let modules = modules
699- . iter ( )
700- . map ( |( request, ids) | {
656+ let mut serializer = form_urlencoded:: Serializer :: new ( String :: new ( ) ) ;
657+ for ( request, ids) in & modules {
658+ let module_json = if self . is_edge_server {
659+ serde_json:: to_string ( & json ! ( {
660+ "request" : request. replace(
661+ r"/next/dist/esm/" ,
662+ & format!( "/next/dist/{}" , std:: path:: MAIN_SEPARATOR )
663+ ) ,
664+ "ids" : ids
665+ } ) )
666+ . unwrap ( )
667+ } else {
701668 serde_json:: to_string ( & json ! ( {
702669 "request" : request,
703670 "ids" : ids
704671 } ) )
705672 . unwrap ( )
706- } )
707- . join ( "," ) ;
708- let params = LoaderParams {
709- modules,
710- server : true ,
711- } ;
712- format ! (
713- "next-flight-client-entry-loader?{}!" ,
714- serde_urlencoded:: to_string( params) . unwrap( )
715- )
673+ } ;
674+ serializer. append_pair ( "modules" , & module_json) ;
675+ }
676+ serializer. append_pair ( "server" , "false" ) ;
677+
678+ format ! ( "next-flight-client-entry-loader?{}!" , serializer. finish( ) )
679+ } ;
680+
681+ let client_server_loader = {
682+ let mut serializer = form_urlencoded:: Serializer :: new ( String :: new ( ) ) ;
683+ for ( request, ids) in & modules {
684+ let module_json = serde_json:: to_string ( & json ! ( {
685+ "request" : request,
686+ "ids" : ids
687+ } ) )
688+ . unwrap ( ) ;
689+ serializer. append_pair ( "modules" , & module_json) ;
690+ }
691+ serializer. append_pair ( "server" , "true" ) ;
692+ format ! ( "next-flight-client-entry-loader?{}!" , serializer. finish( ) )
716693 } ;
717694
718695 // Add for the client compilation
@@ -825,7 +802,7 @@ impl FlightClientEntryPlugin {
825802 bundle_path. to_string ( ) ,
826803 ModuleInfo {
827804 module_id : "" . to_string ( ) , // TODO: What's the meaning of this?
828- is_async : false ,
805+ r#async : false ,
829806 } ,
830807 ) ;
831808
@@ -1060,6 +1037,7 @@ impl FlightClientEntryPlugin {
10601037 // compiler: compiler.clone(),
10611038 // compilation: compilation.clone(),
10621039 entry_name : name. to_string ( ) ,
1040+ // client_component_imports keys 缺少很多
10631041 client_imports : component_info. client_component_imports ,
10641042 bundle_path : bundle_path. clone ( ) ,
10651043 absolute_page_path : entry_request. to_string_lossy ( ) . to_string ( ) ,
@@ -1293,7 +1271,7 @@ impl FlightClientEntryPlugin {
12931271 . or_insert_with ( Default :: default) ;
12941272 let module_info = ModuleInfo {
12951273 module_id : module_id. to_string ( ) ,
1296- is_async : ModuleGraph :: is_async ( & compilation, module_identifier) ,
1274+ r#async : ModuleGraph :: is_async ( & compilation, module_identifier) ,
12971275 } ;
12981276 if from_client {
12991277 module_pair. client = Some ( module_info) ;
@@ -1458,7 +1436,7 @@ async fn after_emit(&self, compilation: &mut Compilation) -> Result<()> {
14581436
14591437 let module_info = ModuleInfo {
14601438 module_id : module_id. to_string ( ) ,
1461- is_async : ModuleGraph :: is_async ( & compilation, & module. identifier ( ) ) ,
1439+ r#async : ModuleGraph :: is_async ( & compilation, & module. identifier ( ) ) ,
14621440 } ;
14631441
14641442 if self . is_edge_server {
@@ -1492,7 +1470,7 @@ async fn after_emit(&self, compilation: &mut Compilation) -> Result<()> {
14921470
14931471 let module_info = ModuleInfo {
14941472 module_id : module_id. to_string ( ) ,
1495- is_async : ModuleGraph :: is_async ( & compilation, & module. identifier ( ) ) ,
1473+ r#async : ModuleGraph :: is_async ( & compilation, & module. identifier ( ) ) ,
14961474 } ;
14971475
14981476 if self . is_edge_server {
0 commit comments