Skip to content

Commit

Permalink
refactor(hmr): simplify fetchUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 28, 2022
1 parent 1fc0a66 commit 18f0ea9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,12 @@ async function fetchUpdate({ path, acceptedPath, timestamp }: Update) {
const isSelfUpdate = path === acceptedPath

// determine the qualified callbacks before we re-import the modules
let qualifiedCallbacks: HotCallback[] = []
let moduleToUpdate: string | undefined
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) =>
deps.includes(acceptedPath)
)

const tmp = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath))
moduleToUpdate = isSelfUpdate || tmp.length > 0 ? acceptedPath : undefined
qualifiedCallbacks = tmp
const moduleToUpdate =
isSelfUpdate || qualifiedCallbacks.length > 0 ? acceptedPath : undefined

if (moduleToUpdate !== undefined) {
const dep = moduleToUpdate
Expand Down

0 comments on commit 18f0ea9

Please sign in to comment.