@@ -24,7 +24,7 @@ use for_each_entry_module::for_each_entry_module;
2424use futures:: future:: BoxFuture ;
2525use get_module_build_info:: get_module_rsc_information;
2626use is_metadata_route:: is_metadata_route;
27- use itertools :: Itertools ;
27+ use lazy_regex :: Lazy ;
2828use loader_util:: { get_actions_from_build_info, is_client_component_entry_module, is_css_mod} ;
2929use regex:: Regex ;
3030use rspack_collections:: Identifiable ;
@@ -47,6 +47,18 @@ use serde::Serialize;
4747use serde_json:: json;
4848use sugar_path:: SugarPath ;
4949
50+ static NEXT_DIST_ESM_REGEX : Lazy < Regex > =
51+ Lazy :: new ( || Regex :: new ( "[\\ /]next[\\ /]dist[\\ /]esm[\\ /]" ) . unwrap ( ) ) ;
52+
53+ static NEXT_DIST : Lazy < String > = Lazy :: new ( || {
54+ format ! (
55+ "{}next{}dist{}" ,
56+ std:: path:: MAIN_SEPARATOR ,
57+ std:: path:: MAIN_SEPARATOR ,
58+ std:: path:: MAIN_SEPARATOR
59+ )
60+ } ) ;
61+
5062#[ derive( Clone , Serialize ) ]
5163pub struct Action {
5264 pub workers : HashMap < String , ModuleInfo > ,
@@ -641,7 +653,6 @@ impl FlightClientEntryPlugin {
641653
642654 let mut should_invalidate = false ;
643655
644- // client_imports key 缺少
645656 let mut modules: Vec < _ > = client_imports
646657 . keys ( )
647658 . map ( |client_import_path| {
@@ -668,10 +679,7 @@ impl FlightClientEntryPlugin {
668679 for ( request, ids) in & modules {
669680 let module_json = if self . is_edge_server {
670681 serde_json:: to_string ( & json ! ( {
671- "request" : request. replace(
672- r"/next/dist/esm/" ,
673- & format!( "/next/dist/{}" , std:: path:: MAIN_SEPARATOR )
674- ) ,
682+ "request" : NEXT_DIST_ESM_REGEX . replace( request, & * NEXT_DIST ) ,
675683 "ids" : ids
676684 } ) )
677685 . unwrap ( )
@@ -722,7 +730,7 @@ impl FlightClientEntryPlugin {
722730 }
723731
724732 let client_component_ssr_entry_dep = EntryDependency :: new (
725- client_browser_loader ,
733+ client_server_loader . to_string ( ) ,
726734 compilation. options . context . clone ( ) ,
727735 Some ( WEBPACK_LAYERS . server_side_rendering . to_string ( ) ) ,
728736 false ,
@@ -1045,10 +1053,7 @@ impl FlightClientEntryPlugin {
10451053 merged_css_imports. extend ( component_info. css_imports ) ;
10461054
10471055 client_entries_to_inject. push ( ClientEntry {
1048- // compiler: compiler.clone(),
1049- // compilation: compilation.clone(),
10501056 entry_name : name. to_string ( ) ,
1051- // client_component_imports keys 缺少很多
10521057 client_imports : component_info. client_component_imports ,
10531058 bundle_path : bundle_path. clone ( ) ,
10541059 absolute_page_path : entry_request. to_string_lossy ( ) . to_string ( ) ,
@@ -1061,8 +1066,6 @@ impl FlightClientEntryPlugin {
10611066 && bundle_path == "app/not-found"
10621067 {
10631068 client_entries_to_inject. push ( ClientEntry {
1064- // compiler: compiler.clone(),
1065- // compilation: compilation.clone(),
10661069 entry_name : name. to_string ( ) ,
10671070 client_imports : HashMap :: default ( ) ,
10681071 bundle_path : format ! ( "app{}" , UNDERSCORE_NOT_FOUND_ROUTE_ENTRY ) ,
@@ -1126,8 +1129,6 @@ impl FlightClientEntryPlugin {
11261129 . inject_action_entry (
11271130 compilation,
11281131 ActionEntry {
1129- // compiler: compiler.clone(),
1130- // compilation: compilation.clone(),
11311132 actions : action_entry_imports,
11321133 entry_name : name. clone ( ) ,
11331134 bundle_path : name,
@@ -1217,8 +1218,6 @@ impl FlightClientEntryPlugin {
12171218 . inject_action_entry (
12181219 compilation,
12191220 ActionEntry {
1220- // compiler: compiler.clone(),
1221- // compilation: compilation.clone(),
12221221 actions : remaining_action_entry_imports,
12231222 entry_name : entry_name. clone ( ) ,
12241223 bundle_path : entry_name. clone ( ) ,
0 commit comments