1
+ import * as path from 'path' ;
2
+
1
3
import { cosmiconfigSync } from 'cosmiconfig' ;
2
4
import merge from 'deepmerge' ;
3
5
import type { JSONSchema7 } from 'json-schema' ;
@@ -15,10 +17,12 @@ import { dependenciesPool, issuesPool } from './hooks/pluginPools';
15
17
import { tapAfterCompileToAddDependencies } from './hooks/tapAfterCompileToAddDependencies' ;
16
18
import { tapAfterEnvironmentToPatchWatching } from './hooks/tapAfterEnvironmentToPatchWatching' ;
17
19
import { tapErrorToLogMessage } from './hooks/tapErrorToLogMessage' ;
18
- import { tapStartToConnectAndRunReporter } from './hooks/tapStartToConnectAndRunReporter' ;
19
- import { tapStopToDisconnectReporter } from './hooks/tapStopToDisconnectReporter' ;
20
- import { createTypeScriptReporterRpcClient } from './typescript-reporter/reporter/TypeScriptReporterRpcClient' ;
21
- import { assertTypeScriptSupport } from './typescript-reporter/TypeScriptSupport' ;
20
+ import { tapStartToRunWorkers } from './hooks/tapStartToRunWorkers' ;
21
+ import { tapStopToTerminateWorkers } from './hooks/tapStopToTerminateWorkers' ;
22
+ import { assertTypeScriptSupport } from './typescript/TypeScriptSupport' ;
23
+ import type { GetDependenciesWorker } from './typescript/worker/get-dependencies-worker' ;
24
+ import type { GetIssuesWorker } from './typescript/worker/get-issues-worker' ;
25
+ import { createRpcWorker } from './utils/rpc' ;
22
26
23
27
class ForkTsCheckerWebpackPlugin {
24
28
/**
@@ -61,19 +65,20 @@ class ForkTsCheckerWebpackPlugin {
61
65
const state = createForkTsCheckerWebpackPluginState ( ) ;
62
66
63
67
assertTypeScriptSupport ( configuration . typescript ) ;
64
- const issuesReporter = createTypeScriptReporterRpcClient ( configuration . typescript ) ;
65
- const dependenciesReporter = createTypeScriptReporterRpcClient ( configuration . typescript ) ;
68
+ const getIssuesWorker = createRpcWorker < GetIssuesWorker > (
69
+ path . resolve ( __dirname , './typescript/worker/get-issues-worker.js' ) ,
70
+ configuration . typescript ,
71
+ configuration . typescript . memoryLimit
72
+ ) ;
73
+ const getDependenciesWorker = createRpcWorker < GetDependenciesWorker > (
74
+ path . resolve ( __dirname , './typescript/worker/get-dependencies-worker.js' ) ,
75
+ configuration . typescript
76
+ ) ;
66
77
67
78
tapAfterEnvironmentToPatchWatching ( compiler , state ) ;
68
- tapStartToConnectAndRunReporter (
69
- compiler ,
70
- issuesReporter ,
71
- dependenciesReporter ,
72
- configuration ,
73
- state
74
- ) ;
79
+ tapStartToRunWorkers ( compiler , getIssuesWorker , getDependenciesWorker , configuration , state ) ;
75
80
tapAfterCompileToAddDependencies ( compiler , configuration , state ) ;
76
- tapStopToDisconnectReporter ( compiler , issuesReporter , dependenciesReporter , state ) ;
81
+ tapStopToTerminateWorkers ( compiler , getIssuesWorker , getDependenciesWorker , state ) ;
77
82
tapErrorToLogMessage ( compiler , configuration ) ;
78
83
}
79
84
}
0 commit comments