Skip to content

Commit 95bddf7

Browse files
committed
wip: update for new rolldown
1 parent b32bd4e commit 95bddf7

File tree

1 file changed

+38
-42
lines changed

1 file changed

+38
-42
lines changed

packages/vite/src/node/server/environments/fullBundleEnvironment.ts

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class FullBundleDevEnvironment extends DevEnvironment {
104104
patched: this.state.patched,
105105
}
106106

107-
let hmrOutput: HmrOutput
107+
let hmrOutput: HmrOutput | undefined
108108
try {
109109
// NOTE: only single outputOptions is supported here
110110
hmrOutput = await this.state.bundle.generateHmrPatch([file])
@@ -121,6 +121,11 @@ export class FullBundleDevEnvironment extends DevEnvironment {
121121
return
122122
}
123123

124+
if (!hmrOutput) {
125+
debug?.(`ignored file change for ${file}`)
126+
return
127+
}
128+
124129
this.handleHmrOutput(file, hmrOutput, this.state)
125130
return
126131
}
@@ -356,50 +361,41 @@ export class FullBundleDevEnvironment extends DevEnvironment {
356361
return
357362
}
358363

359-
// TODO: handle `No corresponding module found for changed file path`
360-
if (
361-
hmrOutput.code &&
362-
hmrOutput.code !== '__rolldown_runtime__.applyUpdates([]);'
363-
) {
364-
debug?.(`handle hmr output for ${file}`, {
365-
...hmrOutput,
366-
code: typeof hmrOutput.code === 'string' ? '[code]' : hmrOutput.code,
367-
})
368-
369-
this.memoryFiles.set(hmrOutput.filename, hmrOutput.code)
370-
if (hmrOutput.sourcemapFilename && hmrOutput.sourcemap) {
371-
this.memoryFiles.set(hmrOutput.sourcemapFilename, hmrOutput.sourcemap)
372-
}
373-
const updates: Update[] = hmrOutput.hmrBoundaries.map((boundary: any) => {
374-
return {
375-
type: 'js-update',
376-
url: hmrOutput.filename,
377-
path: boundary.boundary,
378-
acceptedPath: boundary.acceptedVia,
379-
firstInvalidatedBy: hmrOutput.firstInvalidatedBy,
380-
timestamp: 0,
381-
}
382-
})
383-
this.hot.send({
384-
type: 'update',
385-
updates,
386-
})
387-
this.logger.info(
388-
colors.green(`hmr update `) +
389-
colors.dim([...new Set(updates.map((u) => u.path))].join(', ')),
390-
{ clear: !hmrOutput.firstInvalidatedBy, timestamp: true },
391-
)
364+
debug?.(`handle hmr output for ${file}`, {
365+
...hmrOutput,
366+
code: typeof hmrOutput.code === 'string' ? '[code]' : hmrOutput.code,
367+
})
392368

393-
this.state = {
394-
type: 'bundled',
395-
options,
396-
bundle,
397-
patched: true,
398-
}
399-
return
369+
this.memoryFiles.set(hmrOutput.filename, hmrOutput.code)
370+
if (hmrOutput.sourcemapFilename && hmrOutput.sourcemap) {
371+
this.memoryFiles.set(hmrOutput.sourcemapFilename, hmrOutput.sourcemap)
400372
}
373+
const updates: Update[] = hmrOutput.hmrBoundaries.map((boundary: any) => {
374+
return {
375+
type: 'js-update',
376+
url: hmrOutput.filename,
377+
path: boundary.boundary,
378+
acceptedPath: boundary.acceptedVia,
379+
firstInvalidatedBy: hmrOutput.firstInvalidatedBy,
380+
timestamp: 0,
381+
}
382+
})
383+
this.hot.send({
384+
type: 'update',
385+
updates,
386+
})
387+
this.logger.info(
388+
colors.green(`hmr update `) +
389+
colors.dim([...new Set(updates.map((u) => u.path))].join(', ')),
390+
{ clear: !hmrOutput.firstInvalidatedBy, timestamp: true },
391+
)
401392

402-
debug?.(`ignored file change for ${file}`)
393+
this.state = {
394+
type: 'bundled',
395+
options,
396+
bundle,
397+
patched: true,
398+
}
403399
}
404400
}
405401

0 commit comments

Comments
 (0)