File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
packages/vite/src/app/components/data Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { Chunk as ChunkInfo } from ' @rolldown/debug'
33import type { SessionContext } from ' ~~/shared/types'
4+ import { computed } from ' vue'
45
5- withDefaults (defineProps <{
6+ const props = withDefaults (defineProps <{
67 chunk: ChunkInfo
78 session: SessionContext
89 showModules? : boolean
@@ -11,6 +12,20 @@ withDefaults(defineProps<{
1112 showModules: true ,
1213 showImports: true ,
1314})
15+
16+ const modulesMap = computed (() => {
17+ const map = new Map ()
18+ for (const module of props .session .modulesList ) {
19+ map .set (module .id , module )
20+ }
21+ return map
22+ })
23+
24+ const chunkSize = computed (() => props .chunk .modules .reduce ((total , moduleId ) => {
25+ const moduleInfo = modulesMap .value .get (moduleId )
26+ const transforms = moduleInfo ?.buildMetrics ?.transforms
27+ return transforms ?.length ? total + transforms [transforms .length - 1 ]! .transformed_code_size : total
28+ }, 0 ))
1429 </script >
1530
1631<template >
@@ -20,7 +35,7 @@ withDefaults(defineProps<{
2035 <div i-ph-shapes-duotone />
2136 <div >{{ chunk.name || '[unnamed]' }}</div >
2237 <DisplayBadge :text =" chunk.reason" />
23- <!-- TODO: Estimated Chunk Size -- >
38+ <DisplayFileSizeBadge :bytes = " chunkSize " text-sm / >
2439 </div >
2540
2641 <div flex-auto />
You can’t perform that action at this time.
0 commit comments