Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/vite/src/node/server/bundledDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ export class BundledDev {
this._devEngine = await dev(rolldownOptions, outputOptions, {
onHmrUpdates: (result) => {
if (result instanceof Error) {
this.environment.logger.error(
colors.red(`✘ Build error: ${result.message}`),
{
error: result,
},
)
// TODO: send to the specific client
for (const client of this.clients.getAll()) {
client.send({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { setTimeout } from 'node:timers/promises'
import { expect, test, onTestFinished } from 'vitest'
import { addFile, browserLogs, editFile, isBuild, page, readFile } from '~utils'
import {
addFile,
browserLogs,
editFile,
isBuild,
page,
readFile,
serverLogs,
} from '~utils'

const assetUrl = /asset-[\w-]+\.png/

Expand Down Expand Up @@ -80,10 +88,14 @@ if (isBuild) {
// BUNDLED -> GENERATING_HMR_PATCH -> BUNDLED
test('handle generate hmr patch error', async () => {
await expect.poll(() => page.textContent('.hmr')).toBe('hello')
const lastServerLogIndex = serverLogs.length
editFile('hmr.js', (code) =>
code.replace("const foo = 'hello'", "const foo = 'hello"),
)
await expect.poll(() => page.isVisible('vite-error-overlay')).toBe(true)
await expect
.poll(() => serverLogs.slice(lastServerLogIndex).join('\n'))
.toContain('Build error')

editFile('hmr.js', (code) =>
code.replace("const foo = 'hello", "const foo = 'hello'"),
Expand Down
Loading