@@ -48,7 +48,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
4848 }
4949
5050 // Picking only `*.js or *.mjs` assets from bundle that has non-empty `chunks` array
51- bundleStats . assets = _ . filter ( bundleStats . assets , asset => {
51+ bundleStats . assets = bundleStats . assets . filter ( asset => {
5252 // Filter out non 'asset' type asset if type is provided (Webpack 5 add a type to indicate asset types)
5353 if ( asset . type && asset . type !== 'asset' ) {
5454 return false ;
@@ -82,7 +82,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
8282 }
8383
8484 bundlesSources [ statAsset . name ] = _ . pick ( bundleInfo , 'src' , 'runtimeSrc' ) ;
85- _ . assign ( parsedModules , bundleInfo . modules ) ;
85+ Object . assign ( parsedModules , bundleInfo . modules ) ;
8686 }
8787
8888 if ( _ . isEmpty ( bundlesSources ) ) {
@@ -92,7 +92,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
9292 }
9393 }
9494
95- const assets = _ . transform ( bundleStats . assets , ( result , statAsset ) => {
95+ const assets = bundleStats . assets . reduce ( ( result , statAsset ) => {
9696 // If asset is a childAsset, then calculate appropriate bundle modules by looking through stats.children
9797 const assetBundles = statAsset . isChild ? getChildAssetBundles ( bundleStats , statAsset . name ) : bundleStats ;
9898 const modules = assetBundles ? getBundleModules ( assetBundles ) : [ ] ;
@@ -144,22 +144,21 @@ function getViewerData(bundleStats, bundleDir, opts) {
144144
145145 asset . modules = assetModules ;
146146 asset . tree = createModulesTree ( asset . modules ) ;
147+ return result ;
147148 } , { } ) ;
148149
149- return _ . transform ( assets , ( result , asset , filename ) => {
150- result . push ( {
151- label : filename ,
152- isAsset : true ,
153- // Not using `asset.size` here provided by Webpack because it can be very confusing when `UglifyJsPlugin` is used.
154- // In this case all module sizes from stats file will represent unminified module sizes, but `asset.size` will
155- // be the size of minified bundle.
156- // Using `asset.size` only if current asset doesn't contain any modules (resulting size equals 0)
157- statSize : asset . tree . size || asset . size ,
158- parsedSize : asset . parsedSize ,
159- gzipSize : asset . gzipSize ,
160- groups : _ . invokeMap ( asset . tree . children , 'toChartData' )
161- } ) ;
162- } , [ ] ) ;
150+ return Object . entries ( assets ) . map ( ( [ filename , asset ] ) => ( {
151+ label : filename ,
152+ isAsset : true ,
153+ // Not using `asset.size` here provided by Webpack because it can be very confusing when `UglifyJsPlugin` is used.
154+ // In this case all module sizes from stats file will represent unminified module sizes, but `asset.size` will
155+ // be the size of minified bundle.
156+ // Using `asset.size` only if current asset doesn't contain any modules (resulting size equals 0)
157+ statSize : asset . tree . size || asset . size ,
158+ parsedSize : asset . parsedSize ,
159+ gzipSize : asset . gzipSize ,
160+ groups : _ . invokeMap ( asset . tree . children , 'toChartData' )
161+ } ) ) ;
163162}
164163
165164function readStatsFromFile ( filename ) {
@@ -169,7 +168,7 @@ function readStatsFromFile(filename) {
169168}
170169
171170function getChildAssetBundles ( bundleStats , assetName ) {
172- return _ . find ( bundleStats . children , ( c ) =>
171+ return ( bundleStats . children || [ ] ) . find ( ( c ) =>
173172 _ ( c . assetsByChunkName )
174173 . values ( )
175174 . flatten ( )
@@ -191,8 +190,8 @@ function getBundleModules(bundleStats) {
191190
192191function assetHasModule ( statAsset , statModule ) {
193192 // Checking if this module is the part of asset chunks
194- return _ . some ( statModule . chunks , moduleChunk =>
195- _ . includes ( statAsset . chunks , moduleChunk )
193+ return statModule . chunks . some ( moduleChunk =>
194+ statAsset . chunks . includes ( moduleChunk )
196195 ) ;
197196}
198197
@@ -207,7 +206,7 @@ function isRuntimeModule(statModule) {
207206function createModulesTree ( modules ) {
208207 const root = new Folder ( '.' ) ;
209208
210- _ . each ( modules , module => root . addModule ( module ) ) ;
209+ modules . forEach ( module => root . addModule ( module ) ) ;
211210 root . mergeNestedFolders ( ) ;
212211
213212 return root ;
0 commit comments