mirror of https://github.com/webpack/webpack.git
				
				
				
			add getContext/FileTimestamps to watcher
get timestamps on invalidate fixes #5970
This commit is contained in:
		
							parent
							
								
									e9f1ad208b
								
							
						
					
					
						commit
						74a8c45ea1
					
				|  | @ -36,7 +36,7 @@ class IgnoringWatchFileSystem { | |||
| 		const ignoredFiles = files.filter(ignored); | ||||
| 		const ignoredDirs = dirs.filter(ignored); | ||||
| 
 | ||||
| 		this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, options, (err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps) => { | ||||
| 		const watcher = this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, options, (err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps) => { | ||||
| 			if(err) return callback(err); | ||||
| 
 | ||||
| 			ignoredFiles.forEach(path => { | ||||
|  | @ -49,5 +49,24 @@ class IgnoringWatchFileSystem { | |||
| 
 | ||||
| 			callback(err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps); | ||||
| 		}, callbackUndelayed); | ||||
| 
 | ||||
| 		return { | ||||
| 			close: () => watcher.close(), | ||||
| 			pause: () => watcher.pause(), | ||||
| 			getContextTimestamps: () => { | ||||
| 				const dirTimestamps = watcher.getContextTimestamps(); | ||||
| 				ignoredDirs.forEach(path => { | ||||
| 					dirTimestamps[path] = 1; | ||||
| 				}); | ||||
| 				return dirTimestamps; | ||||
| 			}, | ||||
| 			getFileTimestamps: () => { | ||||
| 				const fileTimestamps = watcher.getFileTimestamps(); | ||||
| 				ignoredFiles.forEach(path => { | ||||
| 					fileTimestamps[path] = 1; | ||||
| 				}); | ||||
| 				return fileTimestamps; | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -111,7 +111,7 @@ class Watching { | |||
| 
 | ||||
| 			this.compiler.fileTimestamps = fileTimestamps; | ||||
| 			this.compiler.contextTimestamps = contextTimestamps; | ||||
| 			this.invalidate(); | ||||
| 			this._invalidate(); | ||||
| 		}, (fileName, changeTime) => { | ||||
| 			this.compiler.hooks.invalid.call(fileName, changeTime); | ||||
| 		}); | ||||
|  | @ -121,6 +121,14 @@ class Watching { | |||
| 		if(callback) { | ||||
| 			this.callbacks.push(callback); | ||||
| 		} | ||||
| 		if(this.watcher) { | ||||
| 			this.compiler.fileTimestamps = this.watcher.getFileTimestamps(); | ||||
| 			this.compiler.contextTimestamps = this.watcher.getContextTimestamps(); | ||||
| 		} | ||||
| 		return this._invalidate(); | ||||
| 	} | ||||
| 
 | ||||
| 	_invalidate() { | ||||
| 		if(this.watcher) { | ||||
| 			this.pausedWatcher = this.watcher; | ||||
| 			this.watcher.pause(); | ||||
|  |  | |||
|  | @ -64,6 +64,18 @@ class NodeWatchFileSystem { | |||
| 				if(this.watcher) { | ||||
| 					this.watcher.pause(); | ||||
| 				} | ||||
| 			}, | ||||
| 			getFileTimestamps: () => { | ||||
| 				if(this.watcher) | ||||
| 					return this.watcher.getTimes(); | ||||
| 				else | ||||
| 					return {}; | ||||
| 			}, | ||||
| 			getContextTimestamps: () => { | ||||
| 				if(this.watcher) | ||||
| 					return this.watcher.getTimes(); | ||||
| 				else | ||||
| 					return {}; | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue