From e61d0930aaf391ab43152f65b993f4da58140fa7 Mon Sep 17 00:00:00 2001 From: Sakana <15715093608@163.com> Date: Thu, 5 Nov 2026 16:25:12 +0800 Subject: [PATCH] feat(rolldown): expose unchanged comparison members and metric scope --- .../src/app/components/compare/TabView.vue | 91 +++++++++++++++---- .../utils/__tests__/compare-modules.test.ts | 45 +++++++++ .../src/shared/utils/compare-modules.ts | 14 +++ 3 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 packages/rolldown/src/shared/utils/__tests__/compare-modules.test.ts create mode 100644 packages/rolldown/src/shared/utils/compare-modules.ts diff --git a/packages/rolldown/src/app/components/compare/TabView.vue b/packages/rolldown/src/app/components/compare/TabView.vue index 241d2e29..075e041a 100644 --- a/packages/rolldown/src/app/components/compare/TabView.vue +++ b/packages/rolldown/src/app/components/compare/TabView.vue @@ -7,10 +7,11 @@ import type { } from '~~/shared/types' import { bytesToHumanSize } from '@vitejs/devtools-ui/utils/format' import { computed, ref, watch } from 'vue' +import { filterComparedModules, getComparedModuleCount } from '~~/shared/utils/compare-modules' import { useRoute, useRouter } from '#app/composables/router' type CompareTab = 'overview' | 'plugins' | 'chunks' | 'modules' | 'assets' | 'packages' -type DiffMode = 'changed' | 'added' | 'removed' +type DiffMode = 'changed' | 'added' | 'removed' | 'all' | 'unchanged' type DiffFormat = 'bytes' | 'duration' | 'number' type SummaryTone = 'increase' | 'decrease' @@ -195,18 +196,18 @@ const sessionSummaries = computed(() => { }, ]) case 'modules': { - return props.sessions.map((session, index) => { + return props.sessions.map((_session, index) => { const codeSize = sumCompareSide(props.details?.modules, index, item => item.previous, item => item.current) const codeSizeA = sumCompareSide(props.details?.modules, 0, item => item.previous, item => item.current) return [ { - label: 'Modules', - value: session.modules.toLocaleString(), + label: 'Compared Modules', + value: getComparedModuleCount(props.details?.modules, index).toLocaleString(), icon: 'i-ph-graph-duotone', - tone: getSummaryTone(index, session.modules, sessionA?.modules), + tone: getSummaryTone(index, getComparedModuleCount(props.details?.modules, index), getComparedModuleCount(props.details?.modules, 0)), }, { - label: 'Code Size', + label: 'Transformed Code Size', value: formatBytesSummary(codeSize), icon: 'i-ph-file-code-duotone', tone: getSummaryTone(index, codeSize, codeSizeA), @@ -273,17 +274,10 @@ const sessionSummaries = computed(() => { const assetDiffs = computed(() => changedEntries(props.details?.assets)) const chunkDiffs = computed(() => changedEntries(props.details?.chunks)) -const moduleDiffs = computed(() => { - const chunk = moduleChunkFilter.value - const search = moduleSearch.value.trim().toLowerCase() - return changedEntries(props.details?.modules).filter((item) => { - if (chunk && !item.previousChunkKeys.includes(chunk) && !item.currentChunkKeys.includes(chunk)) - return false - if (search && !item.name.toLowerCase().includes(search) && !item.package?.toLowerCase().includes(search)) - return false - return true - }) -}) +const moduleDiffs = computed(() => filterComparedModules(props.details?.modules, { + chunk: moduleChunkFilter.value, + search: moduleSearch.value, +})) const packageDiffs = computed(() => changedEntries(props.details?.packages)) const pluginDiffs = computed(() => changedEntries(props.details?.plugins)) @@ -416,12 +410,18 @@ const activeRows = computed(() => { } }) +const unchangedRows = computed(() => activeRows.value.filter(item => item.status === 'unchanged')) + const changedRows = computed(() => activeRows.value.filter(item => item.status === 'changed')) const addedRows = computed(() => activeRows.value.filter(item => item.status === 'added')) const removedRows = computed(() => activeRows.value.filter(item => item.status === 'removed')) const activeDiffRows = computed(() => { switch (activeDiffMode.value) { + case 'all': + return moduleRows.value + case 'unchanged': + return unchangedRows.value case 'added': return addedRows.value case 'removed': @@ -469,9 +469,34 @@ const diffModeOptions = computed diffModeOptions.value.filter(item => item.id !== 'all' && item.id !== 'unchanged')) +const memberModeOptions = computed(() => diffModeOptions.value.filter(item => item.id === 'all' || item.id === 'unchanged')) + const activeDiffOption = computed(() => diffModeOptions.value.find(item => item.id === activeDiffMode.value)) watch( @@ -487,6 +512,10 @@ const activeDiffFormat = computed(() => activeRows.value[0]?.format || 'bytes') const activeDiffEmptyText = computed(() => { switch (activeDiffMode.value) { + case 'all': + return 'No matching chunk members' + case 'unchanged': + return 'No unchanged members' case 'added': return 'No added entries' case 'removed': @@ -712,9 +741,33 @@ function sumDelta(rows: SplitDiffRow[]) { + +