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 ignoredFiles = files.filter(ignored); | ||||||
| 		const ignoredDirs = dirs.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); | 			if(err) return callback(err); | ||||||
| 
 | 
 | ||||||
| 			ignoredFiles.forEach(path => { | 			ignoredFiles.forEach(path => { | ||||||
|  | @ -49,5 +49,24 @@ class IgnoringWatchFileSystem { | ||||||
| 
 | 
 | ||||||
| 			callback(err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps); | 			callback(err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps); | ||||||
| 		}, callbackUndelayed); | 		}, 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.fileTimestamps = fileTimestamps; | ||||||
| 			this.compiler.contextTimestamps = contextTimestamps; | 			this.compiler.contextTimestamps = contextTimestamps; | ||||||
| 			this.invalidate(); | 			this._invalidate(); | ||||||
| 		}, (fileName, changeTime) => { | 		}, (fileName, changeTime) => { | ||||||
| 			this.compiler.hooks.invalid.call(fileName, changeTime); | 			this.compiler.hooks.invalid.call(fileName, changeTime); | ||||||
| 		}); | 		}); | ||||||
|  | @ -121,6 +121,14 @@ class Watching { | ||||||
| 		if(callback) { | 		if(callback) { | ||||||
| 			this.callbacks.push(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) { | 		if(this.watcher) { | ||||||
| 			this.pausedWatcher = this.watcher; | 			this.pausedWatcher = this.watcher; | ||||||
| 			this.watcher.pause(); | 			this.watcher.pause(); | ||||||
|  |  | ||||||
|  | @ -64,6 +64,18 @@ class NodeWatchFileSystem { | ||||||
| 				if(this.watcher) { | 				if(this.watcher) { | ||||||
| 					this.watcher.pause(); | 					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