From 9041f5389acbc4339ee21e8df6b670e00a9d702a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ole=C5=9B?= Date: Mon, 8 Jun 2020 21:21:12 +0200 Subject: [PATCH] perf: fix directory watchers to not invoke them unnecessary --- src/hooks/tapAfterCompileToGetIssues.ts | 3 ++- src/hooks/tapDoneToAsyncGetIssues.ts | 5 +++-- .../reporter/ControlledTypeScriptSystem.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hooks/tapAfterCompileToGetIssues.ts b/src/hooks/tapAfterCompileToGetIssues.ts index 2284f814..7311d82e 100644 --- a/src/hooks/tapAfterCompileToGetIssues.ts +++ b/src/hooks/tapAfterCompileToGetIssues.ts @@ -1,4 +1,5 @@ import webpack from 'webpack'; +import path from 'path'; import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration'; import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState'; import { getForkTsCheckerWebpackPluginHooks } from './pluginHooks'; @@ -35,7 +36,7 @@ function tapAfterCompileToGetIssues( if (configuration.issue.scope === 'webpack') { // exclude issues that are related to files outside webpack compilation issues = issues.filter( - (issue) => !issue.file || compilation.fileDependencies.has(issue.file) + (issue) => !issue.file || compilation.fileDependencies.has(path.normalize(issue.file)) ); } diff --git a/src/hooks/tapDoneToAsyncGetIssues.ts b/src/hooks/tapDoneToAsyncGetIssues.ts index 1e26db5b..7267b212 100644 --- a/src/hooks/tapDoneToAsyncGetIssues.ts +++ b/src/hooks/tapDoneToAsyncGetIssues.ts @@ -1,4 +1,6 @@ import webpack from 'webpack'; +import chalk from 'chalk'; +import path from 'path'; import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration'; import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState'; import { getForkTsCheckerWebpackPluginHooks } from './pluginHooks'; @@ -7,7 +9,6 @@ import { Issue } from '../issue'; import { IssueWebpackError } from '../issue/IssueWebpackError'; import isPending from '../utils/async/isPending'; import wait from '../utils/async/wait'; -import chalk from 'chalk'; function tapDoneToAsyncGetIssues( compiler: webpack.Compiler, @@ -53,7 +54,7 @@ function tapDoneToAsyncGetIssues( if (configuration.issue.scope === 'webpack') { // exclude issues that are related to files outside webpack compilation issues = issues.filter( - (issue) => !issue.file || stats.compilation.fileDependencies.has(issue.file) + (issue) => !issue.file || stats.compilation.fileDependencies.has(path.normalize(issue.file)) ); } diff --git a/src/typescript-reporter/reporter/ControlledTypeScriptSystem.ts b/src/typescript-reporter/reporter/ControlledTypeScriptSystem.ts index 20822ee7..42d90502 100644 --- a/src/typescript-reporter/reporter/ControlledTypeScriptSystem.ts +++ b/src/typescript-reporter/reporter/ControlledTypeScriptSystem.ts @@ -215,7 +215,7 @@ function createControlledTypeScriptSystem( invokeFileChanged(path: string) { const normalizedPath = realFileSystem.normalizePath(path); - if (deletedFiles.get(normalizedPath) || !fileWatchersMap.has(path)) { + if (deletedFiles.get(normalizedPath) || !fileWatchersMap.has(normalizedPath)) { invokeFileWatchers(path, ts.FileWatcherEventKind.Created); invokeDirectoryWatchers(normalizedPath);