Skip to content

Commit

Permalink
Track timestamps to filter changed files. (#500)
Browse files Browse the repository at this point in the history
* Track timestamps to filter changed files.
* Regenerate test data
  • Loading branch information
WearyMonkey authored and johnnyreilly committed Mar 16, 2017
1 parent 05ca5e5 commit 44a2cdb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 173 deletions.
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export interface WebpackNodeWatchFileSystem {

export interface WebpackWatching {
compiler: WebpackCompiler; // a guess
startTime: number;
}

export interface Resolve {
Expand Down
13 changes: 10 additions & 3 deletions src/watch-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ import constants = require('./constants');
function makeWatchRun(
instance: interfaces.TSInstance
) {
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 = {};
}

Object.keys(watcher.getTimes())
.filter(filePath => !!filePath.match(constants.tsTsxJsJsxRegex))
startTime = startTime || watching.startTime;
const times = watcher.getTimes();
Object.keys(times)
.filter(filePath =>
times[filePath] > (lastTimes[filePath] || startTime)
&& !!filePath.match(constants.tsTsxJsJsxRegex)
)
.forEach(filePath => {
lastTimes[filePath] = times[filePath];
filePath = path.normalize(filePath);
const file = instance.files[filePath];
if (file) {
Expand Down

This file was deleted.

This file was deleted.

81 changes: 0 additions & 81 deletions test/comparison-tests/issue441/expectedOutput-2.2/patch0/bundle.js

This file was deleted.

This file was deleted.

0 comments on commit 44a2cdb

Please sign in to comment.