@@ -29,11 +29,10 @@ use rspack_hook::{plugin, plugin_hook};
2929use rspack_util:: fx_hash:: { FxHashMap as HashMap , FxHashSet as HashSet } ;
3030use utils:: {
3131 collect_expose_requirements, compose_id_with_separator, ensure_shared_entry, is_hot_file,
32- parse_consume_shared_identifier, parse_container_exposes_from_identifier,
33- parse_provide_shared_identifier, record_shared_usage, strip_ext,
32+ parse_consume_shared_identifier, parse_provide_shared_identifier, record_shared_usage, strip_ext,
3433} ;
3534
36- use crate :: container:: remote_module:: RemoteModule ;
35+ use crate :: container:: { container_entry_module :: ContainerEntryModule , remote_module:: RemoteModule } ;
3736
3837#[ plugin]
3938#[ derive( Debug ) ]
@@ -198,54 +197,47 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
198197 ( exposes, shared, remote_list)
199198 } else {
200199 let module_graph = compilation. get_module_graph ( ) ;
201- let context = & compilation. options . context ;
202200
203201 let mut exposes_map: HashMap < String , StatsExpose > = HashMap :: default ( ) ;
204202 let mut shared_map: HashMap < String , StatsShared > = HashMap :: default ( ) ;
205203 let mut shared_usage_links: Vec < ( String , String ) > = Vec :: new ( ) ;
206204 let mut consume_module_ids: HashMap < String , Vec < ModuleIdentifier > > = HashMap :: default ( ) ;
207205 let mut remote_module_ids: Vec < ModuleIdentifier > = Vec :: new ( ) ;
208206 let mut container_entry_module: Option < ModuleIdentifier > = None ;
209- let mut module_ids_by_name : HashMap < String , ModuleIdentifier > = HashMap :: default ( ) ;
210- let mut self_issued_module_ids : HashMap < String , ModuleIdentifier > = HashMap :: default ( ) ;
207+ for ( _ , module ) in module_graph . modules ( ) . into_iter ( ) {
208+ let module_identifier = module . identifier ( ) ;
211209
212- for ( module_id, module) in module_graph. modules ( ) . into_iter ( ) {
213- let module_identifier = module_id;
214- let module_name = module. readable_identifier ( context) . to_string ( ) ;
215- if !module_name. is_empty ( ) {
216- module_ids_by_name. insert ( module_name. clone ( ) , module_identifier) ;
217- if let Some ( issuer_module) = module_graph. get_issuer ( & module_identifier) {
218- let issuer_name = issuer_module. readable_identifier ( context) . to_string ( ) ;
219- if issuer_name == module_name {
220- self_issued_module_ids. insert ( issuer_name, module_identifier) ;
221- }
210+ if let Some ( container_entry) = module
211+ . as_ref ( )
212+ . as_any ( )
213+ . downcast_ref :: < ContainerEntryModule > ( )
214+ {
215+ container_entry_module = Some ( module_identifier) ;
216+ for ( expose_key, options) in container_entry. exposes ( ) {
217+ let expose_name = options
218+ . name
219+ . clone ( )
220+ . filter ( |name| !name. is_empty ( ) )
221+ . unwrap_or_else ( || expose_key. trim_start_matches ( "./" ) . to_string ( ) ) ;
222+ let Some ( import) = options. import . iter ( ) . find ( |request| !request. is_empty ( ) ) else {
223+ continue ;
224+ } ;
225+ let id_comp = compose_id_with_separator ( & container_name, & expose_name) ;
226+ let expose_file_key = strip_ext ( import) ;
227+ exposes_map. entry ( expose_file_key) . or_insert ( StatsExpose {
228+ path : expose_key. clone ( ) ,
229+ id : id_comp,
230+ name : expose_name,
231+ requires : Vec :: new ( ) ,
232+ assets : StatsAssetsGroup :: default ( ) ,
233+ } ) ;
222234 }
235+ continue ;
223236 }
224237
225238 let module_type = module. module_type ( ) ;
226239 let identifier = module_identifier. to_string ( ) ;
227240
228- if identifier. starts_with ( "container entry" ) {
229- container_entry_module = Some ( module_identifier) ;
230- if let Some ( exposes) = parse_container_exposes_from_identifier ( & identifier) {
231- for ( expose_key, import_name, import_file) in exposes {
232- let expose_name = import_name
233- . filter ( |name| !name. is_empty ( ) )
234- . unwrap_or_else ( || expose_key. trim_start_matches ( "./" ) . to_string ( ) ) ;
235- let id_comp = compose_id_with_separator ( & container_name, & expose_name) ;
236- let expose_file_key = strip_ext ( & import_file) ;
237- exposes_map. entry ( expose_file_key) . or_insert ( StatsExpose {
238- path : expose_key. clone ( ) ,
239- id : id_comp,
240- name : expose_name,
241- requires : Vec :: new ( ) ,
242- assets : StatsAssetsGroup :: default ( ) ,
243- } ) ;
244- }
245- }
246- continue ;
247- }
248-
249241 if matches ! ( module_type, ModuleType :: Remote ) {
250242 remote_module_ids. push ( module_identifier) ;
251243 }
@@ -271,12 +263,7 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
271263 if let Some ( ( pkg, required) ) = parse_consume_shared_identifier ( & identifier) {
272264 let mut target_ids: Vec < ModuleIdentifier > = Vec :: new ( ) ;
273265 if let Some ( issuer_module) = module_graph. get_issuer ( & module_identifier) {
274- let issuer_name = issuer_module. readable_identifier ( context) . to_string ( ) ;
275- if let Some ( target) = self_issued_module_ids. get ( & issuer_name) {
276- target_ids. push ( * target) ;
277- } else if let Some ( target) = module_ids_by_name. get ( & issuer_name) {
278- target_ids. push ( * target) ;
279- }
266+ target_ids. push ( issuer_module. identifier ( ) ) ;
280267 }
281268 if target_ids. is_empty ( ) {
282269 target_ids. push ( module_identifier) ;
0 commit comments