Skip to content

Commit

Permalink
fix: fix fileModuleIds from multiple entries
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 8, 2024
1 parent 90ac390 commit fc158a2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/vite/src/node/server/environments/rolldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,26 +279,29 @@ class RolldownEnvironment extends DevEnvironment {
...this.inputOptions,
output: this.outputOptions,
})
this.result = await this.instance.build()
this.fileModuleIds = new Set(
this.result.output[0].moduleIds.map((id) => cleanUrl(id)),
)
await this.buildInner()

this.buildTimestamp = Date.now()
console.timeEnd(`[rolldown:${this.name}:build]`)
}

async buildInner() {
this.result = await this.instance.build()
this.fileModuleIds = new Set(
this.result.output
.flatMap((c) => (c.type === 'chunk' ? c.moduleIds : []))
.map((id) => cleanUrl(id)),
)
}

async buildHmr(
file: string,
): Promise<rolldown.RolldownOutputChunk | undefined> {
logger.info(`hmr '${file}'`, { timestamp: true })
console.time(`[rolldown:${this.name}:rebuild]`)
const result = await this.instance.build()
this.fileModuleIds = new Set(
this.result.output[0].moduleIds.map((id) => cleanUrl(id)),
)
await this.buildInner()
console.timeEnd(`[rolldown:${this.name}:rebuild]`)
const chunk = result.output.find(
const chunk = this.result.output.find(
(v) => v.type === 'chunk' && v.name === 'hmr-update',
)
if (chunk) {
Expand Down

0 comments on commit fc158a2

Please sign in to comment.