@@ -12,7 +12,9 @@ use turbo_tasks::{
12
12
} ;
13
13
use turbo_tasks_fs:: FileSystemPath ;
14
14
use turbopack:: css:: chunk:: CssChunkPlaceable ;
15
- use turbopack_core:: { module:: Module , reference:: primary_referenced_modules} ;
15
+ use turbopack_core:: {
16
+ chunk:: ChunkingType , module:: Module , reference:: primary_chunkable_referenced_modules,
17
+ } ;
16
18
17
19
use crate :: {
18
20
next_client_reference:: {
@@ -402,79 +404,86 @@ impl Visit<VisitClientReferenceNode> for VisitClientReference {
402
404
}
403
405
} ;
404
406
405
- let referenced_modules = primary_referenced_modules ( * parent_module) . await ?;
407
+ let referenced_modules = primary_chunkable_referenced_modules ( * parent_module) . await ?;
406
408
407
- let referenced_modules = referenced_modules. iter ( ) . map ( |module| async move {
408
- if let Some ( client_reference_module) =
409
- ResolvedVc :: try_downcast_type :: < EcmascriptClientReferenceModule > ( * module)
410
- . await ?
411
- {
412
- return Ok ( VisitClientReferenceNode {
413
- state : node. state ,
414
- ty : VisitClientReferenceNodeType :: ClientReference (
415
- ClientReference {
416
- server_component : node. state . server_component ( ) ,
417
- ty : ClientReferenceType :: EcmascriptClientReference (
418
- client_reference_module,
419
- ) ,
420
- } ,
421
- client_reference_module. ident ( ) . to_string ( ) . await ?,
422
- ) ,
423
- } ) ;
424
- }
409
+ let referenced_modules = referenced_modules
410
+ . iter ( )
411
+ . flat_map ( |( chunking_type, modules) | match chunking_type {
412
+ ChunkingType :: Traced => None ,
413
+ _ => Some ( modules. iter ( ) ) ,
414
+ } )
415
+ . flatten ( )
416
+ . map ( |module| async move {
417
+ if let Some ( client_reference_module) =
418
+ ResolvedVc :: try_downcast_type :: < EcmascriptClientReferenceModule > ( * module)
419
+ . await ?
420
+ {
421
+ return Ok ( VisitClientReferenceNode {
422
+ state : node. state ,
423
+ ty : VisitClientReferenceNodeType :: ClientReference (
424
+ ClientReference {
425
+ server_component : node. state . server_component ( ) ,
426
+ ty : ClientReferenceType :: EcmascriptClientReference (
427
+ client_reference_module,
428
+ ) ,
429
+ } ,
430
+ client_reference_module. ident ( ) . to_string ( ) . await ?,
431
+ ) ,
432
+ } ) ;
433
+ }
425
434
426
- if let Some ( client_reference_module) =
427
- ResolvedVc :: try_downcast_type :: < CssClientReferenceModule > ( * module) . await ?
428
- {
429
- return Ok ( VisitClientReferenceNode {
430
- state : node. state ,
431
- ty : VisitClientReferenceNodeType :: ClientReference (
432
- ClientReference {
433
- server_component : node. state . server_component ( ) ,
434
- ty : ClientReferenceType :: CssClientReference (
435
- client_reference_module. await ?. client_module ,
436
- ) ,
435
+ if let Some ( client_reference_module) =
436
+ ResolvedVc :: try_downcast_type :: < CssClientReferenceModule > ( * module) . await ?
437
+ {
438
+ return Ok ( VisitClientReferenceNode {
439
+ state : node. state ,
440
+ ty : VisitClientReferenceNodeType :: ClientReference (
441
+ ClientReference {
442
+ server_component : node. state . server_component ( ) ,
443
+ ty : ClientReferenceType :: CssClientReference (
444
+ client_reference_module. await ?. client_module ,
445
+ ) ,
446
+ } ,
447
+ client_reference_module. ident ( ) . to_string ( ) . await ?,
448
+ ) ,
449
+ } ) ;
450
+ }
451
+
452
+ if let Some ( server_component_asset) =
453
+ ResolvedVc :: try_downcast_type :: < NextServerComponentModule > ( * module) . await ?
454
+ {
455
+ return Ok ( VisitClientReferenceNode {
456
+ state : VisitClientReferenceNodeState :: InServerComponent {
457
+ server_component : server_component_asset,
437
458
} ,
438
- client_reference_module. ident ( ) . to_string ( ) . await ?,
439
- ) ,
440
- } ) ;
441
- }
459
+ ty : VisitClientReferenceNodeType :: ServerComponentEntry (
460
+ server_component_asset,
461
+ server_component_asset. ident ( ) . to_string ( ) . await ?,
462
+ ) ,
463
+ } ) ;
464
+ }
442
465
443
- if let Some ( server_component_asset) =
444
- ResolvedVc :: try_downcast_type :: < NextServerComponentModule > ( * module) . await ?
445
- {
446
- return Ok ( VisitClientReferenceNode {
447
- state : VisitClientReferenceNodeState :: InServerComponent {
448
- server_component : server_component_asset,
449
- } ,
450
- ty : VisitClientReferenceNodeType :: ServerComponentEntry (
451
- server_component_asset,
452
- server_component_asset. ident ( ) . to_string ( ) . await ?,
453
- ) ,
454
- } ) ;
455
- }
466
+ if ResolvedVc :: try_downcast_type :: < NextServerUtilityModule > ( * module)
467
+ . await ?
468
+ . is_some ( )
469
+ {
470
+ return Ok ( VisitClientReferenceNode {
471
+ state : VisitClientReferenceNodeState :: InServerUtil ,
472
+ ty : VisitClientReferenceNodeType :: ServerUtilEntry (
473
+ * module,
474
+ module. ident ( ) . to_string ( ) . await ?,
475
+ ) ,
476
+ } ) ;
477
+ }
456
478
457
- if ResolvedVc :: try_downcast_type :: < NextServerUtilityModule > ( * module)
458
- . await ?
459
- . is_some ( )
460
- {
461
- return Ok ( VisitClientReferenceNode {
462
- state : VisitClientReferenceNodeState :: InServerUtil ,
463
- ty : VisitClientReferenceNodeType :: ServerUtilEntry (
479
+ Ok ( VisitClientReferenceNode {
480
+ state : node. state ,
481
+ ty : VisitClientReferenceNodeType :: Internal (
464
482
* module,
465
483
module. ident ( ) . to_string ( ) . await ?,
466
484
) ,
467
- } ) ;
468
- }
469
-
470
- Ok ( VisitClientReferenceNode {
471
- state : node. state ,
472
- ty : VisitClientReferenceNodeType :: Internal (
473
- * module,
474
- module. ident ( ) . to_string ( ) . await ?,
475
- ) ,
476
- } )
477
- } ) ;
485
+ } )
486
+ } ) ;
478
487
479
488
let assets = referenced_modules. try_join ( ) . await ?;
480
489
0 commit comments