@@ -43,9 +43,11 @@ const { state, isLoading } = useAsyncState(
4343 null ,
4444)
4545
46+ const normalizedChunks = computed (() => props .chunks || state .value )
47+
4648const imports = computed ((): RolldownChunkImport [] => {
4749 return props .chunk .imports .map ((importChunk ) => {
48- const chunk = ( props . chunks || state . value ) ?.find (c => c .chunk_id === importChunk .chunk_id )
50+ const chunk = normalizedChunks . value ?.find (c => c .chunk_id === importChunk .chunk_id )
4951
5052 return {
5153 ... importChunk ,
@@ -56,6 +58,20 @@ const imports = computed((): RolldownChunkImport[] => {
5658 }
5759 })
5860})
61+
62+ const importers = computed ((): RolldownChunkImport [] => {
63+ return normalizedChunks .value ?.filter (c => c .imports .some (i => i .chunk_id === props .chunk .chunk_id )).map ((chunk ) => {
64+ const importChunk = chunk .imports .find (i => i .chunk_id === props .chunk .chunk_id )!
65+
66+ return {
67+ ... importChunk ,
68+ name: chunk .name || ' [unnamed]' ,
69+ reason: chunk .reason || ' common' ,
70+ imports: chunk .imports .length || 0 ,
71+ modules: chunk .modules .length || 0 ,
72+ }
73+ }) || []
74+ })
5975 </script >
6076
6177<template >
@@ -100,22 +116,22 @@ const imports = computed((): RolldownChunkImport[] => {
100116 </div >
101117 </details >
102118
103- <!-- TODO: imports seems to be "imported-by" instead of "imports", maybe something wrong on Rolldown side? -- >
104- <!-- TODO: We might want to display both "imports" and "imported-by" relationship -->
105- <details v-if =" showImports && chunk.imports.length > 0 " open = " true " >
106- <summary op50 >
107- <span >Imports ({{ chunk.imports.length }})</ span >
108- </ summary >
109- < VisualLoading v-if = " isLoading " / >
110- < div v-else flex = " ~ col gap-1 " mt2 ws-nowrap >
111- < DisplayChunkImports
112- v-for = " chunkImport in imports "
113- :key = " chunkImport.chunk_id "
114- :chunk = " chunkImport "
115- hover = " bg-active "
116- border = " ~ base rounded " px2 py1 w-full
117- />
118- </div >
119- </details >
119+ <VisualLoading v-if = " isLoading " / >
120+
121+ <template v-else- if =" showImports " >
122+ <details v-if = " chunk.imports.length " open = " true " >
123+ <summary op50 >
124+ < span >Imports ({{ chunk.imports.length }})</ span >
125+ </ summary >
126+ < ChunksImports :imports = " imports " / >
127+ </ details >
128+
129+ < details v-if = " importers.length " open = " true " >
130+ < summary op50 >
131+ < span >Importers ({{ importers.length }})</ span >
132+ </ summary >
133+ < ChunksImports :imports = " importers " />
134+ </details >
135+ </template >
120136 </div >
121137</template >
0 commit comments