Skip to content

Commit

Permalink
Use compiler.fileTimestamps cause watcher may be null (#587)
Browse files Browse the repository at this point in the history
* Use compiler.fileTimestamps cause watcher may be null
* Update CHANGELOG.md
  • Loading branch information
zinserjan authored and johnnyreilly committed Jul 19, 2017
1 parent c0e8477 commit ac17f1f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.3.1 - NOT RELEASED YET

- [Fix undefined watcher in watch-run causes error](https://github.com/TypeStrong/ts-loader/pull/587) (#585) - thanks @zinserjan and @sokra!

## v2.3.0

- [add appendTsxSuffixTo option to support using tsx with Vue](https://github.com/TypeStrong/ts-loader/pull/581) - lots of discussion went into this PR. Thanks to @vhqtvn (author) and @HerringtonDarkholme, @johnnyreilly, @jbrantly, @octref, @rhyek and others for helping us land on our final implementation.
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export interface WebpackCompiler {
isChild(): boolean;
context: string; // a guess
watchFileSystem: WebpackNodeWatchFileSystem;
fileTimestamps: {[key: string]: number};
}

export interface WebpackModule {
Expand Down
4 changes: 1 addition & 3 deletions src/watch-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ function makeWatchRun(
const lastTimes = {};
let startTime : number = null;
return (watching: interfaces.WebpackWatching, cb: () => void) => {
const watcher = watching.compiler.watchFileSystem.watcher ||
watching.compiler.watchFileSystem.wfs.watcher;
if (null === instance.modifiedFiles) {
instance.modifiedFiles = {};
}
startTime = startTime || watching.startTime;
const times = watcher.getTimes();
const times = watching.compiler.fileTimestamps;
Object.keys(times)
.filter(filePath =>
times[filePath] > (lastTimes[filePath] || startTime)
Expand Down

0 comments on commit ac17f1f

Please sign in to comment.