tap-stop-to-terminate-workers.js 1.0 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.tapStopToTerminateWorkers = void 0;
  4. const infrastructure_logger_1 = require("../infrastructure-logger");
  5. function tapStopToTerminateWorkers(compiler, getIssuesWorker, getDependenciesWorker, state) {
  6. const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
  7. const terminateWorkers = () => {
  8. debug('Compiler is going to close - terminating workers...');
  9. getIssuesWorker.terminate();
  10. getDependenciesWorker.terminate();
  11. };
  12. compiler.hooks.watchClose.tap('ForkTsCheckerWebpackPlugin', () => {
  13. terminateWorkers();
  14. });
  15. compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', () => {
  16. if (!state.watching) {
  17. terminateWorkers();
  18. }
  19. });
  20. compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', () => {
  21. if (!state.watching) {
  22. terminateWorkers();
  23. }
  24. });
  25. }
  26. exports.tapStopToTerminateWorkers = tapStopToTerminateWorkers;