Skip to content

Commit 87f8d03

Browse files
author
Guillaume Chau
committed
fix(hmr): some hot reloads were skipped
1 parent 4c4e5cc commit 87f8d03

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

packages/vue-component/plugin/vue-compiler.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,6 @@ class Cache {
282282
}
283283
delete global._vue_cache[key]
284284
}
285-
286-
// static cleanCache (keptInputFiles) {
287-
// // TODO
288-
289-
// const keptKeys = []
290-
291-
// for (let key in global._vue_cache) {
292-
293-
// }
294-
// }
295285
}
296286

297287
class ComponentWatcher {
@@ -331,16 +321,21 @@ class ComponentWatcher {
331321
}
332322

333323
_watchPath (filePath) {
334-
this.filePath = filePath
335-
// Fast file change detection
336-
this._closeWatcher()
337-
this.watcher = fs.watch(filePath, {
338-
persistent: false,
339-
})
340-
this.watcher.on('change', _.debounce(event => { // Refresh once
341-
this.refresh()
342-
}, 100))
343-
this.watcher.on('error', (error) => console.error(error))
324+
if (!this.watcher || filePath !== this.filePath) {
325+
this.filePath = filePath
326+
// Fast file change detection
327+
this._closeWatcher()
328+
this.watcher = fs.watch(filePath, {
329+
persistent: false,
330+
})
331+
this.watcher.on('change', _.debounce(event => { // Refresh once
332+
this.refresh()
333+
}, 100, {
334+
leading: false,
335+
trailing: true,
336+
}))
337+
this.watcher.on('error', (error) => console.error(error))
338+
}
344339
}
345340
}
346341

0 commit comments

Comments
 (0)