Skip to content

Commit 204b40d

Browse files
committed
chore: update
1 parent 468071c commit 204b40d

File tree

3 files changed

+26
-79
lines changed

3 files changed

+26
-79
lines changed

packages/devtools/src/app/components/data/ModuleDetailsLoader.vue

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import type { ModuleInfo, RolldownModuleTransformInfo, SessionContext } from '~~/shared/types'
33
import { useRpc } from '#imports'
44
import { computedAsync } from '@vueuse/core'
5-
import { computed, nextTick, ref, watchEffect } from 'vue'
5+
import { nextTick, ref, watchEffect } from 'vue'
66
import { settings } from '~~/app/state/settings'
7-
import { getContentByteSize } from '~~/app/utils/format'
87
98
const props = defineProps<{
109
session: SessionContext
@@ -45,41 +44,6 @@ const info = computedAsync(async () => {
4544
} as ModuleInfo
4645
})
4746
48-
const durations = computed(() => {
49-
const data = info.value
50-
const _resolveIds = data?.resolve_ids.reduce((t, node) => {
51-
t += node.duration
52-
return t
53-
}, 0) ?? 0
54-
const _loads = data?.loads?.reduce((t, node) => {
55-
t += node.duration
56-
return t
57-
}, 0) ?? 0
58-
const _transforms = data?.transforms.reduce((t, node) => {
59-
t += node.duration
60-
return t
61-
}, 0) ?? 0
62-
const total = _resolveIds + _loads + _transforms
63-
return {
64-
resolveIds: _resolveIds,
65-
loads: _loads,
66-
transforms: _transforms,
67-
total,
68-
}
69-
})
70-
71-
const sourceCodeSize = computed(() => {
72-
const data = info.value?.transforms
73-
const source = data?.[0]?.content_from ?? ''
74-
return getContentByteSize(source)
75-
})
76-
77-
const transformedCodeSize = computed(() => {
78-
const data = info.value?.transforms?.filter(t => t.content_to)?.reverse()
79-
const source = data?.[0]?.content_to ?? ''
80-
return getContentByteSize(source)
81-
})
82-
8347
function selectFlowNode(v: boolean) {
8448
flowNodeSelected.value = v
8549
}
@@ -98,39 +62,7 @@ function selectFlowNode(v: boolean) {
9862
>
9963
<DisplayModuleId :id="module" px2 pt1 :session />
10064
<div text-xs font-mono flex="~ items-center gap-3" ml2>
101-
<DisplayDuration
102-
:duration="durations.resolveIds" flex="~ gap-1 items-center"
103-
:title="`resolveId hooks cost: ${durations.resolveIds}ms`"
104-
>
105-
<span i-ph-magnifying-glass-duotone inline-block />
106-
</DisplayDuration>
107-
<DisplayDuration
108-
:duration="durations.loads" flex="~ gap-1 items-center"
109-
:title="`load hooks cost: ${durations.loads}ms`"
110-
>
111-
<span i-ph-upload-simple-duotone inline-block />
112-
</DisplayDuration>
113-
<DisplayDuration
114-
:duration="durations.transforms" flex="~ gap-1 items-center"
115-
:title="`transform hooks cost: ${durations.transforms}ms`"
116-
>
117-
<span i-ph-magic-wand-duotone inline-block />
118-
</DisplayDuration>
119-
<span op40>|</span>
120-
<DisplayDuration
121-
:duration="durations.total" flex="~ gap-1 items-center"
122-
:title="`Total build cost: ${durations.total}ms`"
123-
>
124-
<span i-ph-clock-duotone inline-block />
125-
</DisplayDuration>
126-
<template v-if="sourceCodeSize && transformedCodeSize">
127-
<span op40>|</span>
128-
<div flex="~ gap-1 items-center">
129-
<DisplayFileSizeBadge title="Source code size" :bytes="sourceCodeSize" />
130-
<span i-carbon-arrow-right op50 />
131-
<DisplayFileSizeBadge title="Transformed code size" :bytes="transformedCodeSize" />
132-
</div>
133-
</template>
65+
<ModulesBuildMetrics v-if="info" :metrics="info.build_metrics" />
13466
</div>
13567
<div flex="~ gap-2">
13668
<button

packages/devtools/src/app/components/modules/DetailedList.vue

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
<script setup lang="ts">
22
import type { ModuleListItem, SessionContext } from '~~/shared/types'
3+
import { computed } from 'vue'
34
4-
defineProps<{
5+
const props = defineProps<{
56
session: SessionContext
67
modules: ModuleListItem[]
78
}>()
9+
10+
const filteredTransformsMap = computed(() => {
11+
const map = new Map<string, Exclude<ModuleListItem['buildMetrics'], undefined>['transforms']>()
12+
for (const mod of props.modules) {
13+
const t = mod.buildMetrics?.transforms.filter(i => i.source_code_size !== i.transformed_code_size).filter(i => i.transformed_code_size)
14+
map.set(mod.id, t!)
15+
}
16+
return map
17+
})
818
</script>
919

1020
<template>
@@ -19,8 +29,19 @@ defineProps<{
1929
:link="true"
2030
>
2131
<template #detail>
22-
<div flex="~ gap-1" text-xs>
23-
{{ mod.buildMetrics?.transforms.filter(i => i.source_code_size !== i.transformed_code_size).filter(i => i.transformed_code_size).map(i => i.plugin_name) }}
32+
<div flex="~ gap-1 wrap" text-xs>
33+
<ul flex="~ auto text-xs wrap">
34+
<template v-for="(p, i) of filteredTransformsMap.get(mod.id)" :key="i">
35+
<li v-if="p.source_code_size !== p.transformed_code_size && p.transformed_code_size" flex="~ items-center">
36+
<DisplayPluginName
37+
:name="p.plugin_name"
38+
class="font-mono ws-nowrap op-50"
39+
/>
40+
<span v-if="i !== filteredTransformsMap.get(mod.id)!.length - 1" op20>|</span>
41+
</li>
42+
</template>
43+
</ul>
44+
2445
<div flex="~ auto gap-1" of-hidden />
2546
<div flex="~ none gap-1 wrap justify-end">
2647
<span>

packages/devtools/src/app/utils/format.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ export function bytesToHumanSize(bytes: number, digits = 2) {
88
return [(+(bytes / 1024 ** i).toFixed(digits)).toLocaleString(), sizes[i]]
99
}
1010

11-
export function getContentByteSize(content: string) {
12-
if (!content)
13-
return 0
14-
return new TextEncoder().encode(content).length
15-
}
16-
1711
export function toTree(modules: ModuleDest[], name: string) {
1812
const node: ModuleTreeNode = { name, children: {}, items: [] }
1913

0 commit comments

Comments
 (0)