1+ #![ feature( let_chains) ]
2+
13mod constants;
24mod for_each_entry_module;
35mod get_module_build_info;
@@ -20,7 +22,7 @@ use constants::{
2022use derive_more:: Debug ;
2123use for_each_entry_module:: for_each_entry_module;
2224use futures:: future:: BoxFuture ;
23- use get_module_build_info:: get_module_build_info ;
25+ use get_module_build_info:: get_module_rsc_information ;
2426use is_metadata_route:: is_metadata_route;
2527use itertools:: Itertools ;
2628use loader_util:: { get_actions_from_build_info, is_client_component_entry_module, is_css_mod} ;
@@ -289,26 +291,31 @@ fn get_module_resource(module: &dyn Module) -> String {
289291}
290292
291293pub fn get_assumed_source_type ( module : & dyn Module , source_type : String ) -> String {
292- let build_info = get_module_build_info ( module) ;
293- let detected_client_entry_type = build_info. rsc . client_entry_type ;
294- let client_refs = build_info. rsc . client_refs . unwrap_or ( vec ! [ ] ) ;
294+ let rsc = get_module_rsc_information ( module) ;
295+ let detected_client_entry_type = rsc
296+ . as_ref ( )
297+ . and_then ( |rsc| rsc. client_entry_type . as_deref ( ) ) ;
298+ let client_refs: & [ String ] = rsc
299+ . as_ref ( )
300+ . and_then ( |rsc| rsc. client_refs . as_ref ( ) . map ( |r| r. as_slice ( ) ) )
301+ . unwrap_or_default ( ) ;
295302
296303 // It's tricky to detect the type of a client boundary, but we should always
297304 // use the `module` type when we can, to support `export *` and `export from`
298305 // syntax in other modules that import this client boundary.
299306
300307 if source_type == "auto" {
301- if detected_client_entry_type == Some ( "auto" . to_string ( ) ) {
308+ if detected_client_entry_type == Some ( "auto" ) {
302309 if client_refs. is_empty ( ) {
303310 // If there's zero export detected in the client boundary, and it's the
304311 // `auto` type, we can safely assume it's a CJS module because it doesn't
305312 // have ESM exports.
306313 return "commonjs" . to_string ( ) ;
307- } else if !client_refs. contains ( & "*" . to_string ( ) ) {
314+ } else if !client_refs. iter ( ) . any ( |e| e == "*" ) {
308315 // Otherwise, we assume it's an ESM module.
309316 return "module" . to_string ( ) ;
310317 }
311- } else if detected_client_entry_type == Some ( "cjs" . to_string ( ) ) {
318+ } else if detected_client_entry_type == Some ( "cjs" ) {
312319 return "commonjs" . to_string ( ) ;
313320 }
314321 }
@@ -323,9 +330,9 @@ fn add_client_import(
323330 imported_identifiers : & [ String ] ,
324331 is_first_visit_module : bool ,
325332) {
326- let build_info = get_module_build_info ( module) ;
327- let client_entry_type = build_info . rsc . client_entry_type ;
328- let is_cjs_module = client_entry_type == Some ( "cjs" . to_string ( ) ) ;
333+ let rsc = get_module_rsc_information ( module) ;
334+ let client_entry_type = rsc . and_then ( | rsc| rsc . client_entry_type ) ;
335+ let is_cjs_module = matches ! ( client_entry_type, Some ( t ) if t == "cjs" ) ;
329336 let assumed_source_type = get_assumed_source_type (
330337 module,
331338 if is_cjs_module {
@@ -1090,7 +1097,7 @@ impl FlightClientEntryPlugin {
10901097 add_client_entry_and_ssr_modules_list. push ( injected) ;
10911098 }
10921099
1093- if is_app_route_route ( name. as_str ( ) ) {
1100+ if ! is_app_route_route ( name. as_str ( ) ) {
10941101 // Create internal app
10951102 add_client_entry_and_ssr_modules_list. push ( self . inject_client_entry_and_ssr_modules (
10961103 compilation,
@@ -1450,7 +1457,10 @@ async fn after_emit(&self, compilation: &mut Compilation) -> Result<()> {
14501457 }
14511458 }
14521459 }
1453-
1460+ if mod_resource. contains ( "app/style.css" ) {
1461+ dbg ! ( module. get_layer( ) ) ;
1462+ dbg ! ( module. identifier( ) ) ;
1463+ }
14541464 if module. get_layer ( ) . map ( |layer| layer. as_str ( ) )
14551465 != Some ( WEBPACK_LAYERS . server_side_rendering )
14561466 {
@@ -1500,6 +1510,18 @@ async fn after_emit(&self, compilation: &mut Compilation) -> Result<()> {
15001510 ChunkGraph :: get_module_id ( & compilation. module_ids_artifact , * module_identifier)
15011511 {
15021512 record_module ( module_id, module_identifier) ;
1513+
1514+ if let Some ( module) = module_graph. module_by_identifier ( module_identifier)
1515+ && let Some ( module) = module. as_concatenated_module ( )
1516+ {
1517+ for m in module. get_modules ( ) {
1518+ if let Some ( module_id) =
1519+ ChunkGraph :: get_module_id ( & compilation. module_ids_artifact , m. id )
1520+ {
1521+ record_module ( module_id, & m. id ) ;
1522+ }
1523+ }
1524+ }
15031525 }
15041526 }
15051527 }
0 commit comments