|
| 1 | +<script lang="ts" setup> |
| 2 | +import type { ChunkImport, Chunk as ChunkInfo } from '@rolldown/debug' |
| 3 | +import type { SessionContext } from '../../../shared/types/data' |
| 4 | +import { useRoute } from '#app/composables/router' |
| 5 | +import { useAsyncState } from '@vueuse/core' |
| 6 | +import { useRpc } from '../../../modules/rpc/runtime/composables/rpc' |
| 7 | +
|
| 8 | +const props = defineProps<{ |
| 9 | + chunkImport: ChunkImport |
| 10 | + session: SessionContext |
| 11 | + importer: ChunkInfo |
| 12 | +}>() |
| 13 | +
|
| 14 | +const route = useRoute() |
| 15 | +
|
| 16 | +const rpc = useRpc() |
| 17 | +const { state: chunk } = useAsyncState( |
| 18 | + async () => { |
| 19 | + return await rpc.value!['vite:rolldown:get-chunk-info']?.({ |
| 20 | + session: props.session.id, |
| 21 | + id: props.chunkImport.chunk_id, |
| 22 | + }) |
| 23 | + }, |
| 24 | + null, |
| 25 | +) |
| 26 | +</script> |
| 27 | + |
| 28 | +<template> |
| 29 | + <!-- <VisualLoading /> --> |
| 30 | + <NuxtLink v-if="chunk" flex="~ items-center" :to="{ path: route.path, query: { chunk: chunk.chunk_id } }"> |
| 31 | + <!-- Icon, Name, Reason --> |
| 32 | + <div flex="~ gap-2 items-center" :title="`Chunk #${chunk.chunk_id}`"> |
| 33 | + <div v-if="chunkImport.kind === 'import-statement'" i-ph-file-duotone /> |
| 34 | + <div v-if="chunkImport.kind === 'dynamic-import'" i-ph-lightning-duotone /> |
| 35 | + <div>{{ chunk.name || '[unnamed]' }}</div> |
| 36 | + <DisplayBadge :text="chunk.reason" /> |
| 37 | + |
| 38 | + <!-- Import Kind --> |
| 39 | + <DisplayBadge v-if="chunkImport.kind === 'import-statement'" text="statement" :color="210" /> |
| 40 | + <DisplayBadge v-if="chunkImport.kind === 'dynamic-import'" text="dynamic" :color="30" /> |
| 41 | + </div> |
| 42 | + |
| 43 | + <div flex-auto /> |
| 44 | + |
| 45 | + <div text-sm flex="~ items-center gap-2"> |
| 46 | + <span op50 font-mono>#{{ chunk.chunk_id }}</span> |
| 47 | + <div flex="~ gap-1 items-center"> |
| 48 | + <div i-carbon-document-import /> |
| 49 | + {{ chunk.imports.length }} |
| 50 | + </div> |
| 51 | + <div flex="~ gap-1 items-center"> |
| 52 | + <div i-ph-package-duotone /> |
| 53 | + {{ chunk.modules.length }} |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </NuxtLink> |
| 57 | +</template> |
| 58 | + |
| 59 | +<style> |
| 60 | +
|
| 61 | +</style> |
0 commit comments