@@ -197,7 +197,7 @@ function getAssetModulesByChunk(statsAsset, modulesByChunk) {
197197/** @typedef {Record<string, Record<string, boolean>> } ChunkToInitialByEntrypoint */
198198
199199/**
200- * @param {StatsCompilation | undefined } bundleStats bundle stats
200+ * @param {StatsCompilation } bundleStats bundle stats
201201 * @returns {ChunkToInitialByEntrypoint } chunk to initial by entrypoint
202202 */
203203function getChunkToInitialByEntrypoint ( bundleStats ) {
@@ -419,16 +419,11 @@ function getViewerData(bundleStats, bundleDir, opts) {
419419 }
420420 }
421421
422- const rootChunkToInitialByEntrypoint =
423- getChunkToInitialByEntrypoint ( bundleStats ) ;
424-
425- /** @typedef {{ size: number, parsedSize?: number, gzipSize?: number, brotliSize?: number, zstdSize?: number, modules: StatsModule[], tree: Folder, isInitialByEntrypoint: Record<string, boolean> } } Asset */
422+ /** @typedef {{ size: number, parsedSize?: number, gzipSize?: number, brotliSize?: number, zstdSize?: number, modules: StatsModule[], tree: Folder } } Asset */
426423
427424 const assets = bundleStats . assets . reduce ( ( result , statAsset ) => {
428425 /** @type {StatsModule[] } */
429426 let assetModules ;
430- /** @type {Record<string, boolean> } */
431- let isInitialByEntrypoint ;
432427
433428 if ( statAsset . isChild ) {
434429 // Preserve child-compilation matching because child assets use a different module list.
@@ -440,14 +435,10 @@ function getViewerData(bundleStats, bundleDir, opts) {
440435 assetModules = modules . filter ( ( statModule ) =>
441436 assetHasModule ( statAsset , statModule ) ,
442437 ) ;
443- isInitialByEntrypoint =
444- getChunkToInitialByEntrypoint ( assetBundles ) [ statAsset . name ] ?? { } ;
445438 } else {
446439 assetModules = /** @type {StatsModule[] } */ (
447440 rootAssetModules . get ( statAsset ) || [ ]
448441 ) ;
449- isInitialByEntrypoint =
450- rootChunkToInitialByEntrypoint [ statAsset . name ] ?? { } ;
451442 }
452443
453444 // A module that is a part of more than one asset is one stats object. Every asset that
@@ -458,7 +449,6 @@ function getViewerData(bundleStats, bundleDir, opts) {
458449
459450 const asset = ( result [ statAsset . name ] = /** @type {Asset } */ ( {
460451 size : statAsset . size ,
461- isInitialByEntrypoint,
462452 } ) ) ;
463453 const assetSources =
464454 bundlesSources && Object . hasOwn ( bundlesSources , statAsset . name )
@@ -536,6 +526,8 @@ function getViewerData(bundleStats, bundleDir, opts) {
536526 return result ;
537527 } , /** @type {Record<string, Asset> } */ ( { } ) ) ;
538528
529+ const chunkToInitialByEntrypoint = getChunkToInitialByEntrypoint ( bundleStats ) ;
530+
539531 return Object . entries ( assets ) . map ( ( [ filename , asset ] ) => ( {
540532 label : filename ,
541533 isAsset : true ,
@@ -549,7 +541,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
549541 brotliSize : asset . brotliSize ,
550542 zstdSize : asset . zstdSize ,
551543 groups : Object . values ( asset . tree . children ) . map ( ( i ) => i . toChartData ( ) ) ,
552- isInitialByEntrypoint : asset . isInitialByEntrypoint ,
544+ isInitialByEntrypoint : chunkToInitialByEntrypoint [ filename ] ?? { } ,
553545 } ) ) ;
554546}
555547
0 commit comments