File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
packages/plugin-bundle-stats/src/lib/runner/audits/details Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,10 @@ function pruneTree(
190190 options : Required < PruningOptions > ,
191191) : TreeNode {
192192 const { maxChildren, maxDepth, startDepth = 0 } = options ;
193+
194+ // Sort children by bytes in descending order before pruning
195+ node . children . sort ( ( a , b ) => b . bytes - a . bytes ) ;
196+
193197 if ( node . children . length > maxChildren ) {
194198 const remainingChildren = node . children . slice ( maxChildren ) ;
195199 const remainingBytes = remainingChildren . reduce (
@@ -282,6 +286,9 @@ export function createTree(
282286 const { title, groups, pruning } = options ;
283287 let nodes = convertToTree ( statsSlice ) ;
284288 nodes = applyGrouping ( nodes , groups ) ;
289+
290+ // Sort nodes by bytes in descending order at the root level
291+ nodes . sort ( ( a , b ) => b . bytes - a . bytes ) ;
285292
286293 const tempRoot : TreeNode = {
287294 name : 'temp-root' ,
You can’t perform that action at this time.
0 commit comments