New file watching implementation

Reviewed By: davidaurelio

Differential Revision: D4161662

fbshipit-source-id: 9a2a399304c83b411a8b0b74ea015c18b599fbaf
This commit is contained in:
Christoph Pojer
2016-11-16 01:13:40 -08:00
committed by Facebook Github Bot
parent c22b00e58f
commit e8a623a2ab
20 changed files with 192 additions and 742 deletions
+7 -13
View File
@@ -16,8 +16,6 @@ const Module = require('./Module');
const Package = require('./Package');
const Polyfill = require('./Polyfill');
const path = require('path');
import type Cache from './Cache';
import type {
DepGraphHelpers,
@@ -69,8 +67,6 @@ class ModuleCache {
this._assetDependencies = assetDependencies;
this._moduleOptions = moduleOptions;
this._packageModuleMap = new WeakMap();
fastfs.on('change', this._processFileChange.bind(this));
}
getModule(filePath: string) {
@@ -149,16 +145,14 @@ class ModuleCache {
});
}
_processFileChange(type, filePath, root) {
const absPath = path.join(root, filePath);
if (this._moduleCache[absPath]) {
this._moduleCache[absPath].invalidate();
delete this._moduleCache[absPath];
processFileChange(type: string, filePath: string) {
if (this._moduleCache[filePath]) {
this._moduleCache[filePath].invalidate();
delete this._moduleCache[filePath];
}
if (this._packageCache[absPath]) {
this._packageCache[absPath].invalidate();
delete this._packageCache[absPath];
if (this._packageCache[filePath]) {
this._packageCache[filePath].invalidate();
delete this._packageCache[filePath];
}
}
}