File tree Expand file tree Collapse file tree 1 file changed +15
-20
lines changed
packages/vue-component/plugin Expand file tree Collapse file tree 1 file changed +15
-20
lines changed Original file line number Diff line number Diff 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
297287class 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
You can’t perform that action at this time.
0 commit comments