@@ -50,7 +50,7 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
5050 * @property {number } postOrderIndex next post order index
5151 * @property {boolean } chunkLoading has a chunk loading mechanism
5252 * @property {boolean } asyncChunks create async chunks
53- * @property {string } blockId is the block key
53+ * @property {Module | null } depModule the module that is the dependency of the block
5454 * @property {boolean } circular Whether to deduplicate to avoid circular references
5555 */
5656
@@ -363,8 +363,8 @@ const visitModules = (
363363 /** @type {NamedChunkGroup } */
364364 const namedAsyncEntrypoints = new Map ( ) ;
365365
366- /** @type {Map<string , ChunkGroupInfo> } */
367- const idAsyncEntrypoints = new Map ( ) ;
366+ /** @type {Map<Module , ChunkGroupInfo> } */
367+ const depModuleAsyncEntrypoints = new Map ( ) ;
368368
369369 /** @type {Set<ChunkGroupInfo> } */
370370 const outdatedOrderIndexChunkGroups = new Set ( ) ;
@@ -395,7 +395,7 @@ const visitModules = (
395395 ) ;
396396 /** @type {ChunkGroupInfo } */
397397 const chunkGroupInfo = {
398- blockId : "" ,
398+ depModule : null ,
399399 circular : false ,
400400 initialized : false ,
401401 chunkGroup,
@@ -505,13 +505,16 @@ const visitModules = (
505505 let c ;
506506 /** @type {Entrypoint | undefined } */
507507 let entrypoint ;
508+ /** @type {Module | null } */
509+ const depModule = moduleGraph . getModule ( b . dependencies [ 0 ] ) ;
508510 const entryOptions = b . groupOptions && b . groupOptions . entryOptions ;
509511 if ( cgi === undefined ) {
510512 const chunkName = ( b . groupOptions && b . groupOptions . name ) || b . chunkName ;
511513 if ( entryOptions ) {
512- cgi =
513- namedAsyncEntrypoints . get ( /** @type {string } */ ( chunkName ) ) ||
514- idAsyncEntrypoints . get ( /** @type {string } */ ( b . identifier ( ) ) ) ;
514+ cgi = namedAsyncEntrypoints . get ( /** @type {string } */ ( chunkName ) ) ;
515+ if ( ! cgi && ! b . circular && depModule ) {
516+ cgi = depModuleAsyncEntrypoints . get ( depModule ) ;
517+ }
515518 if ( ! cgi ) {
516519 entrypoint = compilation . addAsyncEntrypoint (
517520 entryOptions ,
@@ -522,7 +525,7 @@ const visitModules = (
522525 maskByChunk . set ( entrypoint . chunks [ 0 ] , ZERO_BIGINT ) ;
523526 entrypoint . index = nextChunkGroupIndex ++ ;
524527 cgi = {
525- blockId : b . identifier ( ) ,
528+ depModule ,
526529 circular : b . circular ,
527530 chunkGroup : entrypoint ,
528531 initialized : false ,
@@ -561,9 +564,9 @@ const visitModules = (
561564 ( cgi )
562565 ) ;
563566 }
564- if ( b . circular ) {
565- idAsyncEntrypoints . set (
566- b . identifier ( ) ,
567+ if ( ! b . circular && depModule ) {
568+ depModuleAsyncEntrypoints . set (
569+ depModule ,
567570 /** @type {ChunkGroupInfo } */ ( cgi )
568571 ) ;
569572 }
@@ -609,7 +612,7 @@ const visitModules = (
609612 maskByChunk . set ( c . chunks [ 0 ] , ZERO_BIGINT ) ;
610613 c . index = nextChunkGroupIndex ++ ;
611614 cgi = {
612- blockId : b . identifier ( ) ,
615+ depModule ,
613616 circular : b . circular ,
614617 initialized : false ,
615618 chunkGroup : c ,
@@ -689,7 +692,7 @@ const visitModules = (
689692 ] ) ;
690693 } else if (
691694 entrypoint !== undefined &&
692- ( chunkGroupInfo . circular || chunkGroupInfo . blockId !== b . identifier ( ) )
695+ ( chunkGroupInfo . circular || chunkGroupInfo . depModule !== depModule )
693696 ) {
694697 chunkGroupInfo . chunkGroup . addAsyncEntrypoint ( entrypoint ) ;
695698 }
0 commit comments