Skip to content

Commit 0ccbf7a

Browse files
committed
feat: update rolldown
1 parent e86f4c8 commit 0ccbf7a

File tree

12 files changed

+165
-157
lines changed

12 files changed

+165
-157
lines changed

packages/devtools/src/app/components/panel/SelectBuild.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { backend } from '../../state/backend'
33
4-
const builds = await backend.value!.functions['vite:rolldown:list-builds']()
4+
const builds = await backend.value!.functions['vite:rolldown:list-sessions']()
55
</script>
66

77
<template>

packages/devtools/src/app/pages/build/[build]/flow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const selected = ref<{
2121
const { state: info } = useAsyncState(
2222
async () => {
2323
return await backend.value!.functions['vite:rolldown:get-module-info']?.({
24-
build: params.build as string,
24+
session: params.build as string,
2525
module: query.module as string,
2626
})
2727
},

packages/devtools/src/app/pages/build/[build]/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const filtered = computed(() => {
2828
2929
onMounted(async () => {
3030
modules.value = await backend.value!.functions['vite:rolldown:get-module-list']!({
31-
build: params.build,
31+
session: params.build,
3232
})
3333
fuse.setCollection(modules.value)
3434
})

packages/devtools/src/node/rpc/functions/rolldown-get-module-info.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface ModuleInfo {
1616
export interface RolldownResolveInfo {
1717
id: string
1818
plugin_name: string
19+
plugin_index: number
1920
resolved_id: string | null
2021
timestamp_start: number
2122
timestamp_end: number
@@ -25,6 +26,7 @@ export interface RolldownResolveInfo {
2526
export interface RolldownModuleLoadInfo {
2627
id: string
2728
plugin_name: string
29+
plugin_index: number
2830
source: string | null
2931
timestamp_start: number
3032
timestamp_end: number
@@ -34,6 +36,7 @@ export interface RolldownModuleLoadInfo {
3436
export interface RolldownModuleTransformInfo {
3537
id: string
3638
plugin_name: string
39+
plugin_index: number
3740
source_from: string | null
3841
source_to: string | null
3942
timestamp_start: number
@@ -48,10 +51,10 @@ export const rolldownGetModuleInfo = defineRpcFunction({
4851
type: 'query',
4952
setup: ({ cwd }) => {
5053
return {
51-
handler: async ({ build, module }: { build: string, module: string }) => {
52-
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', build, 'log.json'))
54+
handler: async ({ session, module }: { session: string, module: string }) => {
55+
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', session, 'log.json'))
5356
await reader.read()
54-
const events = reader.manager.events.filter(event => event.module_id === module)
57+
const events = reader.manager.events.filter(event => 'module_id' in event && event.module_id === module)
5558

5659
if (!events.length)
5760
return null
@@ -79,6 +82,7 @@ export const rolldownGetModuleInfo = defineRpcFunction({
7982
info.loads.push({
8083
id: event.event_id,
8184
plugin_name: event.plugin_name,
85+
plugin_index: event.plugin_index,
8286
source: event.source,
8387
timestamp_start: +start.timestamp,
8488
timestamp_end: +event.timestamp,
@@ -101,6 +105,7 @@ export const rolldownGetModuleInfo = defineRpcFunction({
101105
info.transforms.push({
102106
id: event.event_id,
103107
plugin_name: event.plugin_name,
108+
plugin_index: event.plugin_index,
104109
source_from: start.source,
105110
source_to: event.transformed_source,
106111
timestamp_start: +start.timestamp,
@@ -113,7 +118,7 @@ export const rolldownGetModuleInfo = defineRpcFunction({
113118
for (const event of events) {
114119
if (event.kind === 'HookResolveIdCallEnd') {
115120
// TODO: use ID to pair start and end
116-
const start = events.find(e => e.kind === 'HookResolveIdCallStart' && e.module_id === event.module_id && e.plugin_index === event.plugin_index)
121+
const start = events.find(e => e.kind === 'HookResolveIdCallStart' && e.plugin_index === event.plugin_index)
117122
if (!start || start.kind !== 'HookResolveIdCallStart') {
118123
console.error(`[rolldown] resolveId call start not found for ${event.event_id}`)
119124
continue
@@ -122,6 +127,7 @@ export const rolldownGetModuleInfo = defineRpcFunction({
122127
info.resolve_ids.push({
123128
id: event.event_id,
124129
plugin_name: event.plugin_name,
130+
plugin_index: event.plugin_index,
125131
resolved_id: event.resolved_id,
126132
timestamp_start: +start.timestamp,
127133
timestamp_end: +event.timestamp,

packages/devtools/src/node/rpc/functions/rolldown-get-module-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const rolldownGetModuleList = defineRpcFunction({
77
type: 'query',
88
setup: async ({ cwd }) => {
99
return {
10-
handler: async ({ build }: { build: string }) => {
11-
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', build, 'log.json'))
10+
handler: async ({ session }: { session: string }) => {
11+
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', session, 'log.json'))
1212
await reader.read()
1313
const modules = new Set<string>()
1414
for (const event of reader.manager.events) {

packages/devtools/src/node/rpc/functions/rolldown-get-module-raw-events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const rolldownGetModuleRawEvents = defineRpcFunction({
1010
handler: async ({ build, module }: { build: string, module: string }) => {
1111
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', build, 'log.json'))
1212
await reader.read()
13-
const events = reader.manager.events.filter(event => event.module_id === module)
13+
const events = reader.manager.events.filter(event => 'module_id' in event && event.module_id === module)
1414
return {
1515
events,
1616
}

packages/devtools/src/node/rpc/functions/rolldown-get-raw-events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const rolldownGetRawEvents = defineRpcFunction({
77
type: 'query',
88
setup: ({ cwd }) => {
99
return {
10-
handler: async ({ build }: { build: string }) => {
11-
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', build, 'log.json'))
10+
handler: async ({ session }: { session: string }) => {
11+
const reader = RolldownEventsReader.get(join(cwd, '.rolldown', session, 'log.json'))
1212
await reader.read()
1313
return reader.manager.events
1414
},

packages/devtools/src/node/rpc/functions/rolldown-list-builds.ts renamed to packages/devtools/src/node/rpc/functions/rolldown-list-sessions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ export interface BuildInfo {
77
createdAt: number
88
}
99

10-
export const rolldownListBuilds = defineRpcFunction({
11-
name: 'vite:rolldown:list-builds',
10+
export const rolldownListSessions = defineRpcFunction({
11+
name: 'vite:rolldown:list-sessions',
1212
type: 'query',
1313
setup: ({ cwd }) => {
1414
return {
1515
handler: async (): Promise<BuildInfo[]> => {
16-
const builds = await fs.readdir(join(cwd, '.rolldown'), {
16+
const sessions = await fs.readdir(join(cwd, '.rolldown'), {
1717
withFileTypes: true,
1818
})
19-
return await Promise.all(builds
19+
return await Promise.all(sessions
2020
.filter(d => d.isDirectory())
2121
.map(async (d): Promise<BuildInfo> => {
2222
// TODO: read from meta.json

packages/devtools/src/node/rpc/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { rolldownGetModuleInfo } from './functions/rolldown-get-module-info'
66
import { rolldownGetModuleList } from './functions/rolldown-get-module-list'
77
import { rolldownGetModuleRawEvents } from './functions/rolldown-get-module-raw-events'
88
import { rolldownGetRawEvents } from './functions/rolldown-get-raw-events'
9-
import { rolldownListBuilds } from './functions/rolldown-list-builds'
9+
import { rolldownListSessions } from './functions/rolldown-list-sessions'
1010

1111
export const rpcFunctions = [
1212
openInEditor,
1313
openInFinder,
1414
getPayload,
15-
rolldownListBuilds,
15+
rolldownListSessions,
1616
rolldownGetRawEvents,
1717
rolldownGetModuleList,
1818
rolldownGetModuleInfo,

packages/devtools/src/uno.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default defineConfig({
1717
'color-base': 'color-neutral-800 dark:color-neutral-300',
1818
'bg-base': 'bg-white dark:bg-#111',
1919
'bg-secondary': 'bg-#eee dark:bg-#222',
20-
'border-base': 'border-#8883',
20+
'border-base': 'border-#8884',
2121

2222
'bg-tooltip': 'bg-white:75 dark:bg-#111:75 backdrop-blur-8',
2323
'bg-code': 'bg-gray5:5',

0 commit comments

Comments
 (0)