Skip to content

Commit e4a78e0

Browse files
committed
chore: update
1 parent 059fee8 commit e4a78e0

8 files changed

Lines changed: 27 additions & 11 deletions

File tree

packages/vite/src/app/components/chunks/BaseInfo.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { computed } from 'vue'
77
const props = withDefaults(defineProps<{
88
chunk: RolldownChunkInfo | RolldownChunkImport
99
link?: boolean
10+
basic?: boolean
1011
}>(), {
1112
link: false,
13+
basic: false,
1214
})
1315
const route = useRoute()
1416
const normalizedImports = computed(() => Array.isArray(props.chunk.imports) ? props.chunk.imports.length : props.chunk.imports)
@@ -32,7 +34,7 @@ const normalizedModules = computed(() => Array.isArray(props.chunk.modules) ? pr
3234

3335
<div flex-auto />
3436

35-
<div flex="~ items-center gap-2">
37+
<div v-if="!basic" flex="~ items-center gap-2">
3638
<span op50 font-mono>#{{ chunk.chunk_id }}</span>
3739
<div flex="~ gap-1 items-center" :title="`${normalizedImports} imports`">
3840
<div i-ph-file-arrow-up-duotone />

packages/vite/src/app/components/chunks/FlatList.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ withDefaults(defineProps<{
55
chunks: Array<RolldownChunkInfo & { id: string }>
66
session: SessionContext
77
link?: boolean
8+
basic?: boolean
89
}>(), {
910
link: true,
11+
basic: false,
1012
})
1113
1214
const emit = defineEmits<{
@@ -21,7 +23,7 @@ const emit = defineEmits<{
2123
>
2224
<template #default="{ item }">
2325
<div flex pb2 @click="emit('select', item)">
24-
<ChunksBaseInfo :chunk="item" :link="link" w-full font-mono border="~ rounded base" px2 py1 text-sm hover="bg-active" flex="~ gap-4 items-center">
26+
<ChunksBaseInfo :chunk="item" :basic="basic" :link="link" w-full font-mono border="~ rounded base" px2 py1 text-sm hover="bg-active" flex="~ gap-4 items-center">
2527
<template #left-after>
2628
<DisplayBadge v-if="item.is_initial" text="initial" />
2729
</template>

packages/vite/src/app/components/chunks/Graph.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import { createModuleGraph } from '~/composables/moduleGraph'
99
type ChunkInfo = RolldownChunkInfo & {
1010
id: string
1111
}
12-
const props = defineProps<{
12+
const props = withDefaults(defineProps<{
1313
session: SessionContext
1414
chunks: ChunkInfo[]
15-
}>()
15+
entryId?: string
16+
}>(), {
17+
entryId: '',
18+
})
1619
1720
const chunks = computed(() => props.chunks)
1821
const route = useRoute()
@@ -32,7 +35,7 @@ createModuleGraph<ChunkInfo, ChunkImport>({
3235
width.value = window.innerWidth
3336
height.value = window.innerHeight
3437
35-
const entryChunks = chunks.value.filter(chunk => chunk.reason === 'entry')
38+
const entryChunks = chunks.value.filter(chunk => props.entryId ? chunk.id === props.entryId : chunk.reason === 'entry')
3639
3740
const seen = new Set<ChunkInfo>()
3841
const root = hierarchy<ModuleGraphNode<ChunkInfo, ChunkImport>>(

packages/vite/src/app/components/data/PathSelector.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { useGraphPathSelector } from '~/composables/graph-path-selector'
77
const props = defineProps<{
88
session: SessionContext
99
data: T[]
10-
importId: string
10+
importIdKey: string
11+
searchKeys?: string[]
1112
}>()
1213
1314
const emit = defineEmits<{
@@ -34,6 +35,7 @@ const dataMap = computed(() => {
3435
})
3536
3637
const startSelector: GraphPathSelector<T> = useGraphPathSelector<T>({
38+
searchKeys: props.searchKeys,
3739
getModules: () => {
3840
if (!startSelector.state.value.search) {
3941
return props.data
@@ -58,7 +60,7 @@ function getAllImports(moduleId: string, visited = new Set<string>()): T[] {
5860
const res: T[] = []
5961
6062
for (const importItem of module.imports) {
61-
const importedModule = dataMap.value.get(`${importItem[props.importId]}`)
63+
const importedModule = dataMap.value.get(`${importItem[props.importIdKey]}`)
6264
if (!importedModule)
6365
continue
6466
@@ -72,6 +74,7 @@ function getAllImports(moduleId: string, visited = new Set<string>()): T[] {
7274
}
7375
7476
const endSelector = useGraphPathSelector<T>({
77+
searchKeys: props.searchKeys,
7578
getModules: () => {
7679
return startSelector.state.value.selected ? getAllImports(startSelector.state.value.selected) : []
7780
},

packages/vite/src/app/composables/graph-path-selector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface GraphPathSelector<T> {
1414
}
1515

1616
export function useGraphPathSelector<T extends { id: string }>(options: {
17+
searchKeys?: string[]
1718
getModules: () => T[]
1819
}): GraphPathSelector<T> {
1920
const state = ref<{
@@ -32,7 +33,7 @@ export function useGraphPathSelector<T extends { id: string }>(options: {
3233
modules,
3334
() => new Fuse(modules.value, {
3435
includeScore: true,
35-
keys: ['id'],
36+
keys: options.searchKeys || ['id'],
3637
ignoreLocation: true,
3738
threshold: 0.4,
3839
}),

packages/vite/src/app/composables/moduleGraph.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ export const createLinkVertical = linkVertical()
7676
.y(d => d[1])
7777

7878
export function generateModuleGraphLink<M, I>(link: ModuleGraphLink<M, I>, spacing?: ModuleGraphSpacing) {
79+
if (!link.target || !link.source) {
80+
return null
81+
}
7982
if (!spacing) {
8083
if (link.target.x! <= link.source.x!) {
8184
return createLinkVertical({

packages/vite/src/app/pages/session/[session]/chunks.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const searched = computed<Array<RolldownChunkInfo & { id: string }>>(() => {
7777
.map(r => r.item)
7878
})
7979
80-
const { pathSelectorVisible, selectPathNodes, togglePathSelector, normalizedGraph } = useGraphPathManager<RolldownChunkInfo & { id: string }>({
80+
const { pathSelectorVisible, pathNodes, selectPathNodes, togglePathSelector, normalizedGraph } = useGraphPathManager<RolldownChunkInfo & { id: string }>({
8181
onToggle: (visible) => {
8282
searchValue.value.search = visible ? false : ''
8383
},
@@ -97,12 +97,13 @@ function toggleDisplay(type: ClientSettings['chunkViewType']) {
9797
<div absolute left-4 top-4 z-panel-nav>
9898
<DataSearchPanel v-model="searchValue" :rules="[]">
9999
<template v-if="pathSelectorVisible" #search>
100-
<DataPathSelector :session="session" :data="searched" import-id="chunk_id" @select="selectPathNodes" @close="togglePathSelector(false)">
100+
<DataPathSelector :session="session" :data="searched" import-id-key="chunk_id" :search-keys="['name']" @select="selectPathNodes" @close="togglePathSelector(false)">
101101
<template #list="{ select, data }">
102102
<ChunksFlatList
103103
:session="session"
104104
:chunks="data"
105105
:link="false"
106+
:basic="true"
106107
@select="select"
107108
/>
108109
</template>
@@ -162,6 +163,7 @@ function toggleDisplay(type: ClientSettings['chunkViewType']) {
162163
class="pt32"
163164
:session="session"
164165
:chunks="normalizedGraph"
166+
:entry-id="pathNodes.start"
165167
/>
166168
</template>
167169
</div>

packages/vite/src/app/pages/session/[session]/graph/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function toggleDisplay(type: ClientSettings['moduleGraphViewType']) {
138138
<div absolute left-4 top-4 z-panel-nav>
139139
<DataSearchPanel v-model="searchValue" :rules="searchFilterTypes">
140140
<template v-if="pathSelectorVisible" #search>
141-
<DataPathSelector :session="session" :data="searched" import-id="module_id" @select="selectPathNodes" @close="togglePathSelector(false)">
141+
<DataPathSelector :session="session" :data="searched" import-id-key="module_id" :search-keys="['id']" @select="selectPathNodes" @close="togglePathSelector(false)">
142142
<template #list="{ select, data }">
143143
<ModulesFlatList
144144
v-if="data?.length"

0 commit comments

Comments
 (0)