Skip to content

Commit

Permalink
fix(hmr): always invalidate all affected modules
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 8, 2021
1 parent 5aeadb7 commit e048114
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,22 @@ function updateModules(
) {
const updates: Update[] = []
const invalidatedModules = new Set<ModuleNode>()
let needFulleReload = false

This comment has been minimized.

Copy link
@btea

btea Jun 8, 2021

Collaborator

Full后面是不是多写了个e?


for (const mod of modules) {
invalidate(mod, timestamp, invalidatedModules)
if (needFulleReload) {
continue
}

const boundaries = new Set<{
boundary: ModuleNode
acceptedVia: ModuleNode
}>()
invalidate(mod, timestamp, invalidatedModules)
const hasDeadEnd = propagateUpdate(mod, timestamp, boundaries)
if (hasDeadEnd) {
config.logger.info(chalk.green(`page reload `) + chalk.dim(file), {
clear: true,
timestamp: true
})
ws.send({
type: 'full-reload'
})
return
needFulleReload = true
continue
}

updates.push(
Expand All @@ -155,17 +154,26 @@ function updateModules(
)
}

config.logger.info(
updates
.map(({ path }) => chalk.green(`hmr update `) + chalk.dim(path))
.join('\n'),
{ clear: true, timestamp: true }
)

ws.send({
type: 'update',
updates
})
if (needFulleReload) {
config.logger.info(chalk.green(`page reload `) + chalk.dim(file), {
clear: true,
timestamp: true
})
ws.send({
type: 'full-reload'
})
} else {
config.logger.info(
updates
.map(({ path }) => chalk.green(`hmr update `) + chalk.dim(path))
.join('\n'),
{ clear: true, timestamp: true }
)
ws.send({
type: 'update',
updates
})
}
}

export async function handleFileAddUnlink(
Expand Down

1 comment on commit e048114

@yyx990803
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref #3711

Please sign in to comment.