Skip to content

Commit

Permalink
fix: always update last HMR ms on a module
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 11, 2023
1 parent 7e38890 commit 9967645
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ export class Vitest {

private _rerunTimer: any
private async scheduleRerun(triggerId: string) {
const mod = this.server.moduleGraph.getModuleById(triggerId)
if (mod)
mod.lastHMRTimestamp = Date.now()
const currentCount = this.restartsCount
clearTimeout(this._rerunTimer)
await this.runningPromise
Expand Down Expand Up @@ -447,8 +444,15 @@ export class Vitest {

private unregisterWatcher = noop
private registerWatcher() {
const updateLastChanged = (id: string) => {
const mod = this.server.moduleGraph.getModuleById(id)
if (mod)
mod.lastHMRTimestamp = Date.now()
}

const onChange = (id: string) => {
id = slash(id)
updateLastChanged(id)
const needsRerun = this.handleFileChanged(id)
if (needsRerun)
this.scheduleRerun(id)
Expand All @@ -467,6 +471,7 @@ export class Vitest {
}
const onAdd = async (id: string) => {
id = slash(id)
updateLastChanged(id)
if (await this.isTargetFile(id)) {
this.changedTests.add(id)
await this.cache.stats.updateStats(id)
Expand Down

0 comments on commit 9967645

Please sign in to comment.