@@ -13,7 +13,7 @@ use serde::Serialize;
13
13
14
14
use super :: {
15
15
ExportInfoGetter , ExportInfoTargetValue , ExportProvided , ExportsInfo , ExportsInfoData ,
16
- FindTargetRetEnum , FindTargetRetValue , ResolvedExportInfoTarget ,
16
+ ExportsInfoGetter , FindTargetRetEnum , FindTargetRetValue , ResolvedExportInfoTarget ,
17
17
ResolvedExportInfoTargetWithCircular , TerminalBinding , UnResolvedExportInfoTarget , UsageState ,
18
18
NEXT_EXPORT_INFO_UKEY ,
19
19
} ;
@@ -88,13 +88,14 @@ impl ExportInfo {
88
88
return Some ( TerminalBinding :: ExportInfo ( * self ) ) ;
89
89
}
90
90
let target = info. get_target ( mg) ?;
91
+
91
92
let exports_info = mg. get_exports_info ( & target. module ) ;
92
93
let Some ( export) = target. export else {
93
94
return Some ( TerminalBinding :: ExportsInfo ( exports_info) ) ;
94
95
} ;
95
- exports_info
96
- . get_read_only_export_info_recursive ( mg , & export)
97
- . map ( TerminalBinding :: ExportInfo )
96
+ ExportsInfoGetter :: prefetch ( & exports_info, mg , Some ( & export ) )
97
+ . get_read_only_export_info_recursive ( & export)
98
+ . map ( |data| TerminalBinding :: ExportInfo ( data . id ) )
98
99
}
99
100
100
101
pub fn update_hash_with_visited (
@@ -234,9 +235,8 @@ impl ExportInfoData {
234
235
if valid_target_module_filter ( & target. module ) {
235
236
return FindTargetRetEnum :: Value ( target) ;
236
237
}
237
- let exports_info = mg. get_exports_info ( & target. module ) ;
238
+ let exports_info = mg. get_prefetched_exports_info ( & target. module , None ) ;
238
239
let export_info = exports_info. get_export_info_without_mut_module_graph (
239
- mg,
240
240
& target. export . as_ref ( ) . expect ( "should have export" ) [ 0 ] ,
241
241
) ;
242
242
let export_info_hash_key = export_info. as_hash_key ( ) ;
@@ -372,11 +372,11 @@ impl ExportInfoData {
372
372
// and the Static variant represents the most situation which FlagDependencyExportsPlugin can
373
373
// analyze the exports statically.
374
374
#[ derive( Debug ) ]
375
- pub enum MaybeDynamicTargetExportInfo {
376
- Static ( ExportInfo ) ,
375
+ pub enum MaybeDynamicTargetExportInfo < ' a > {
376
+ Static ( & ' a ExportInfoData ) ,
377
377
Dynamic {
378
378
export_name : Atom ,
379
- other_export_info : ExportInfo ,
379
+ other_export_info : & ' a ExportInfoData ,
380
380
data : ExportInfoData ,
381
381
} ,
382
382
}
@@ -390,28 +390,26 @@ pub enum MaybeDynamicTargetExportInfoHashKey {
390
390
} ,
391
391
}
392
392
393
- impl MaybeDynamicTargetExportInfo {
393
+ impl < ' a > MaybeDynamicTargetExportInfo < ' a > {
394
394
pub fn as_hash_key ( & self ) -> MaybeDynamicTargetExportInfoHashKey {
395
395
match self {
396
396
MaybeDynamicTargetExportInfo :: Static ( export_info) => {
397
- MaybeDynamicTargetExportInfoHashKey :: ExportInfo ( * export_info)
397
+ MaybeDynamicTargetExportInfoHashKey :: ExportInfo ( export_info. id ( ) )
398
398
}
399
399
MaybeDynamicTargetExportInfo :: Dynamic {
400
400
export_name,
401
401
other_export_info,
402
402
..
403
403
} => MaybeDynamicTargetExportInfoHashKey :: TemporaryData {
404
404
export_name : export_name. clone ( ) ,
405
- other_export_info : * other_export_info,
405
+ other_export_info : other_export_info. id ( ) ,
406
406
} ,
407
407
}
408
408
}
409
409
410
- pub fn provided < ' a > ( & ' a self , mg : & ' a ModuleGraph ) -> Option < & ' a ExportProvided > {
410
+ pub fn provided ( & ' a self ) -> Option < & ' a ExportProvided > {
411
411
match self {
412
- MaybeDynamicTargetExportInfo :: Static ( export_info) => {
413
- ExportInfoGetter :: provided ( export_info. as_data ( mg) )
414
- }
412
+ MaybeDynamicTargetExportInfo :: Static ( export_info) => ExportInfoGetter :: provided ( export_info) ,
415
413
MaybeDynamicTargetExportInfo :: Dynamic { data, .. } => data. provided . as_ref ( ) ,
416
414
}
417
415
}
@@ -432,8 +430,7 @@ impl MaybeDynamicTargetExportInfo {
432
430
) -> FindTargetRetEnum {
433
431
match self {
434
432
MaybeDynamicTargetExportInfo :: Static ( export_info) => {
435
- let data = export_info. as_data ( mg) ;
436
- data. find_target_impl ( mg, valid_target_module_filter, visited)
433
+ export_info. find_target_impl ( mg, valid_target_module_filter, visited)
437
434
}
438
435
MaybeDynamicTargetExportInfo :: Dynamic { data, .. } => {
439
436
data. find_target_impl ( mg, valid_target_module_filter, visited)
@@ -461,8 +458,7 @@ impl MaybeDynamicTargetExportInfo {
461
458
) -> Option < ResolvedExportInfoTargetWithCircular > {
462
459
match self {
463
460
MaybeDynamicTargetExportInfo :: Static ( export_info) => {
464
- let export_info_data = export_info. as_data ( mg) ;
465
- export_info_data. get_target_proxy ( mg, resolve_filter, already_visited)
461
+ export_info. get_target_proxy ( mg, resolve_filter, already_visited)
466
462
}
467
463
MaybeDynamicTargetExportInfo :: Dynamic { data, .. } => {
468
464
if !data. target_is_set || data. target . is_empty ( ) {
@@ -478,14 +474,10 @@ impl MaybeDynamicTargetExportInfo {
478
474
}
479
475
}
480
476
481
- fn get_max_target < ' a > (
482
- & ' a self ,
483
- mg : & ' a ModuleGraph ,
484
- ) -> Cow < ' a , HashMap < Option < DependencyId > , ExportInfoTargetValue > > {
477
+ fn get_max_target ( & self ) -> Cow < HashMap < Option < DependencyId > , ExportInfoTargetValue > > {
485
478
match self {
486
479
MaybeDynamicTargetExportInfo :: Static ( export_info) => {
487
- let data = export_info. as_data ( mg) ;
488
- ExportInfoGetter :: get_max_target ( data)
480
+ ExportInfoGetter :: get_max_target ( export_info)
489
481
}
490
482
MaybeDynamicTargetExportInfo :: Dynamic { data, .. } => ExportInfoGetter :: get_max_target ( data) ,
491
483
}
@@ -497,11 +489,11 @@ impl MaybeDynamicTargetExportInfo {
497
489
resolve_filter : ResolveFilterFnTy ,
498
490
) -> Option < ResolvedExportInfoTarget > {
499
491
let data = match self {
500
- MaybeDynamicTargetExportInfo :: Static ( export_info) => export_info. as_data ( mg ) ,
492
+ MaybeDynamicTargetExportInfo :: Static ( export_info) => * export_info,
501
493
MaybeDynamicTargetExportInfo :: Dynamic { data, .. } => data,
502
494
} ;
503
495
let target = data. get_target_with_filter ( mg, resolve_filter) ?;
504
- let max_target = self . get_max_target ( mg ) ;
496
+ let max_target = self . get_max_target ( ) ;
505
497
let original_target = max_target
506
498
. values ( )
507
499
. next ( )
@@ -567,8 +559,8 @@ fn resolve_target(
567
559
return Some ( ResolvedExportInfoTargetWithCircular :: Target ( target) ) ;
568
560
} ;
569
561
570
- let exports_info = mg. get_exports_info ( & target. module ) ;
571
- let export_info = exports_info. get_export_info_without_mut_module_graph ( mg , name) ;
562
+ let exports_info = mg. get_prefetched_exports_info ( & target. module , None ) ;
563
+ let export_info = exports_info. get_export_info_without_mut_module_graph ( name) ;
572
564
let export_info_hash_key = export_info. as_hash_key ( ) ;
573
565
if already_visited. contains ( & export_info_hash_key) {
574
566
return Some ( ResolvedExportInfoTargetWithCircular :: Circular ) ;
0 commit comments