Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
fix: Handle undefined watcher error (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
kompot authored and mattcompiles committed Jan 12, 2020
1 parent 8ee1811 commit c3b44e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/treat/webpack-plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ module.exports = class TreatWebpackPlugin {
}

compiler.hooks.watchRun.tap(TWP, watchCompiler => {
this.treatCompiler.expireCache(
Object.keys(watchCompiler.watchFileSystem.watcher.mtimes),
);
// watchCompiler.watchFileSystem.watcher is undefined in some node environments.
// Allow fallback to watchCompiler.watchFileSystem.wfs
// https://github.com/s-panferov/awesome-typescript-loader/commit/c7da9ac82d105cdaf9b124ccc4c130648e59168a
const watcher =
watchCompiler.watchFileSystem.watcher ||
watchCompiler.watchFileSystem.wfs.watcher;
this.treatCompiler.expireCache(Object.keys(watcher.mtimes));
});

compiler.hooks.thisCompilation.tap(TWP, compilation => {
Expand Down

0 comments on commit c3b44e9

Please sign in to comment.