fork-ts-checker-webpack-plugin 4.0.0-beta.4 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +19 -68
  3. package/lib/ApiIncrementalChecker.d.ts +2 -15
  4. package/lib/ApiIncrementalChecker.js +79 -109
  5. package/lib/ApiIncrementalChecker.js.map +1 -1
  6. package/lib/CancellationToken.js +36 -25
  7. package/lib/CancellationToken.js.map +1 -1
  8. package/lib/CompilerHost.d.ts +7 -7
  9. package/lib/CompilerHost.js +225 -155
  10. package/lib/CompilerHost.js.map +1 -1
  11. package/lib/FilesRegister.d.ts +2 -4
  12. package/lib/FilesRegister.js +24 -23
  13. package/lib/FilesRegister.js.map +1 -1
  14. package/lib/FsHelper.js +9 -1
  15. package/lib/FsHelper.js.map +1 -1
  16. package/lib/IncrementalChecker.d.ts +2 -15
  17. package/lib/IncrementalChecker.js +146 -172
  18. package/lib/IncrementalChecker.js.map +1 -1
  19. package/lib/IncrementalCheckerInterface.d.ts +0 -4
  20. package/lib/IncrementalCheckerInterface.js.map +1 -1
  21. package/lib/LinkedList.js +38 -36
  22. package/lib/LinkedList.js.map +1 -1
  23. package/lib/Message.js.map +1 -1
  24. package/lib/RpcTypes.js.map +1 -1
  25. package/lib/VueProgram.d.ts +1 -1
  26. package/lib/VueProgram.js +92 -71
  27. package/lib/VueProgram.js.map +1 -1
  28. package/lib/createEslinter.d.ts +2 -2
  29. package/lib/createEslinter.js +13 -6
  30. package/lib/createEslinter.js.map +1 -1
  31. package/lib/formatter/CodeframeFormatter.js +41 -17
  32. package/lib/formatter/CodeframeFormatter.js.map +1 -1
  33. package/lib/formatter/DefaultFormatter.js +18 -8
  34. package/lib/formatter/DefaultFormatter.js.map +1 -1
  35. package/lib/formatter/Formatter.js.map +1 -1
  36. package/lib/formatter/FormatterFactory.js +2 -2
  37. package/lib/formatter/FormatterFactory.js.map +1 -1
  38. package/lib/formatter/InternalFormatter.js +17 -7
  39. package/lib/formatter/InternalFormatter.js.map +1 -1
  40. package/lib/formatter/RawFormatter.js +3 -3
  41. package/lib/formatter/RawFormatter.js.map +1 -1
  42. package/lib/formatter/index.js.map +1 -1
  43. package/lib/hooks.js +5 -5
  44. package/lib/hooks.js.map +1 -1
  45. package/lib/index.d.ts +2 -10
  46. package/lib/index.js +219 -229
  47. package/lib/index.js.map +1 -1
  48. package/lib/issue/Issue.js +6 -4
  49. package/lib/issue/Issue.js.map +1 -1
  50. package/lib/issue/IssueOrigin.d.ts +0 -1
  51. package/lib/issue/IssueOrigin.js +8 -9
  52. package/lib/issue/IssueOrigin.js.map +1 -1
  53. package/lib/issue/IssueSeverity.js +4 -2
  54. package/lib/issue/IssueSeverity.js.map +1 -1
  55. package/lib/issue/eslint/EsLintIssueFactory.d.ts +2 -2
  56. package/lib/issue/eslint/EsLintIssueFactory.js +17 -12
  57. package/lib/issue/eslint/EsLintIssueFactory.js.map +1 -1
  58. package/lib/issue/eslint/FileAwareEsLintMessage.d.ts +2 -2
  59. package/lib/issue/eslint/FileAwareEsLintMessage.js.map +1 -1
  60. package/lib/issue/eslint/index.js.map +1 -1
  61. package/lib/issue/index.d.ts +0 -1
  62. package/lib/issue/index.js +0 -1
  63. package/lib/issue/index.js.map +1 -1
  64. package/lib/issue/internal/InternalIssueFactory.d.ts +6 -1
  65. package/lib/issue/internal/InternalIssueFactory.js +5 -3
  66. package/lib/issue/internal/InternalIssueFactory.js.map +1 -1
  67. package/lib/issue/internal/index.js.map +1 -1
  68. package/lib/issue/typescript/TypeScriptIssueFactory.js +14 -14
  69. package/lib/issue/typescript/TypeScriptIssueFactory.js.map +1 -1
  70. package/lib/issue/typescript/index.js.map +1 -1
  71. package/lib/patchTypescript.js +27 -20
  72. package/lib/patchTypescript.js.map +1 -1
  73. package/lib/resolution.js +3 -11
  74. package/lib/resolution.js.map +1 -1
  75. package/lib/service.js +107 -63
  76. package/lib/service.js.map +1 -1
  77. package/lib/types/eslint.d.ts +33 -0
  78. package/lib/types/eslint.js +3 -0
  79. package/lib/types/eslint.js.map +1 -0
  80. package/lib/types/vue-options.js.map +1 -1
  81. package/package.json +11 -32
  82. package/lib/issue/tslint/TsLintIssueFactory.d.ts +0 -5
  83. package/lib/issue/tslint/TsLintIssueFactory.js +0 -25
  84. package/lib/issue/tslint/TsLintIssueFactory.js.map +0 -1
  85. package/lib/issue/tslint/index.d.ts +0 -1
  86. package/lib/issue/tslint/index.js +0 -7
  87. package/lib/issue/tslint/index.js.map +0 -1
  88. package/lib/linterConfigHelpers.d.ts +0 -10
  89. package/lib/linterConfigHelpers.js +0 -35
  90. package/lib/linterConfigHelpers.js.map +0 -1
package/lib/index.js CHANGED
@@ -1,33 +1,51 @@
1
1
  "use strict";
2
- const path = require("path");
3
- const process = require("process");
4
- const childProcess = require("child_process");
5
- const semver = require("semver");
6
- const micromatch = require("micromatch");
7
- const chalk_1 = require("chalk");
8
- const worker_rpc_1 = require("worker-rpc");
9
- const CancellationToken_1 = require("./CancellationToken");
10
- const formatter_1 = require("./formatter");
11
- const FsHelper_1 = require("./FsHelper");
12
- const hooks_1 = require("./hooks");
13
- const RpcTypes_1 = require("./RpcTypes");
14
- const issue_1 = require("./issue");
15
- const checkerPluginName = 'fork-ts-checker-webpack-plugin';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importStar = (this && this.__importStar) || function (mod) {
14
+ if (mod && mod.__esModule) return mod;
15
+ var result = {};
16
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
17
+ result["default"] = mod;
18
+ return result;
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ var path = __importStar(require("path"));
24
+ var childProcess = __importStar(require("child_process"));
25
+ var semver = __importStar(require("semver"));
26
+ var micromatch_1 = __importDefault(require("micromatch"));
27
+ var chalk_1 = __importDefault(require("chalk"));
28
+ var worker_rpc_1 = require("worker-rpc");
29
+ var CancellationToken_1 = require("./CancellationToken");
30
+ var formatter_1 = require("./formatter");
31
+ var FsHelper_1 = require("./FsHelper");
32
+ var hooks_1 = require("./hooks");
33
+ var RpcTypes_1 = require("./RpcTypes");
34
+ var issue_1 = require("./issue");
35
+ var checkerPluginName = 'fork-ts-checker-webpack-plugin';
16
36
  /**
17
37
  * ForkTsCheckerWebpackPlugin
18
- * Runs typescript type checker and linter (tslint) on separate process.
38
+ * Runs typescript type checker and linter on separate process.
19
39
  * This speed-ups build a lot.
20
40
  *
21
41
  * Options description in README.md
22
42
  */
23
- class ForkTsCheckerWebpackPlugin {
24
- constructor(options) {
25
- this.tslint = false;
43
+ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
44
+ function ForkTsCheckerWebpackPlugin(options) {
26
45
  this.eslint = false;
27
46
  this.eslintOptions = {};
28
- this.tslintAutoFix = false;
29
47
  this.tsconfigPath = undefined;
30
- this.tslintPath = undefined;
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
49
  this.compiler = undefined;
32
50
  this.started = undefined;
33
51
  this.elapsed = undefined;
@@ -41,7 +59,7 @@ class ForkTsCheckerWebpackPlugin {
41
59
  this.startAt = 0;
42
60
  this.nodeArgs = [];
43
61
  options = options || {};
44
- this.options = Object.assign({}, options);
62
+ this.options = __assign({}, options);
45
63
  this.ignoreDiagnostics = options.ignoreDiagnostics || [];
46
64
  this.ignoreLints = options.ignoreLints || [];
47
65
  this.ignoreLintWarnings = options.ignoreLintWarnings === true;
@@ -59,24 +77,18 @@ class ForkTsCheckerWebpackPlugin {
59
77
  this.rawFormatter = formatter_1.createRawFormatter();
60
78
  this.emitCallback = this.createNoopEmitCallback();
61
79
  this.doneCallback = this.createDoneCallback();
62
- const { typescript, typescriptPath, typescriptVersion, tsconfig, compilerOptions } = this.validateTypeScript(options);
80
+ var _a = this.validateTypeScript(options), typescript = _a.typescript, typescriptPath = _a.typescriptPath, typescriptVersion = _a.typescriptVersion, tsconfig = _a.tsconfig, compilerOptions = _a.compilerOptions;
63
81
  this.typescript = typescript;
64
82
  this.typescriptPath = typescriptPath;
65
83
  this.typescriptVersion = typescriptVersion;
66
84
  this.tsconfig = tsconfig;
67
85
  this.compilerOptions = compilerOptions;
68
86
  if (options.eslint === true) {
69
- const { eslintVersion, eslintOptions } = this.validateEslint(options);
87
+ var _b = this.validateEslint(options), eslintVersion = _b.eslintVersion, eslintOptions = _b.eslintOptions;
70
88
  this.eslint = true;
71
89
  this.eslintVersion = eslintVersion;
72
90
  this.eslintOptions = eslintOptions;
73
91
  }
74
- else {
75
- const { tslint, tslintVersion, tslintAutoFix } = this.validateTslint(options);
76
- this.tslint = tslint;
77
- this.tslintVersion = tslintVersion;
78
- this.tslintAutoFix = tslintAutoFix;
79
- }
80
92
  this.vue = ForkTsCheckerWebpackPlugin.prepareVueOptions(options.vue);
81
93
  this.useTypescriptIncrementalApi =
82
94
  options.useTypescriptIncrementalApi === undefined
@@ -84,20 +96,26 @@ class ForkTsCheckerWebpackPlugin {
84
96
  : options.useTypescriptIncrementalApi;
85
97
  this.measureTime = options.measureCompilationTime === true;
86
98
  if (this.measureTime) {
99
+ if (semver.lt(process.version, '8.5.0')) {
100
+ throw new Error("To use 'measureCompilationTime' option, please update to Node.js >= v8.5.0 " +
101
+ ("(current version is " + process.version + ")"));
102
+ }
87
103
  // Node 8+ only
104
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
88
105
  this.performance = require('perf_hooks').performance;
89
106
  }
90
107
  }
91
- static getCompilerHooks(compiler) {
108
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
+ ForkTsCheckerWebpackPlugin.getCompilerHooks = function (compiler) {
92
110
  return hooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
93
- }
94
- validateTypeScript(options) {
95
- const typescriptPath = options.typescript || require.resolve('typescript');
96
- const tsconfig = options.tsconfig || './tsconfig.json';
97
- const compilerOptions = typeof options.compilerOptions === 'object'
111
+ };
112
+ ForkTsCheckerWebpackPlugin.prototype.validateTypeScript = function (options) {
113
+ var typescriptPath = options.typescript || require.resolve('typescript');
114
+ var tsconfig = options.tsconfig || './tsconfig.json';
115
+ var compilerOptions = typeof options.compilerOptions === 'object'
98
116
  ? options.compilerOptions
99
117
  : {};
100
- let typescript, typescriptVersion;
118
+ var typescript, typescriptVersion;
101
119
  try {
102
120
  typescript = require(typescriptPath);
103
121
  typescriptVersion = typescript.version;
@@ -106,51 +124,33 @@ class ForkTsCheckerWebpackPlugin {
106
124
  throw new Error('When you use this plugin you must install `typescript`.');
107
125
  }
108
126
  if (semver.lt(typescriptVersion, '2.1.0')) {
109
- throw new Error(`Cannot use current typescript version of ${typescriptVersion}, the minimum required version is 2.1.0`);
127
+ throw new Error("Cannot use current typescript version of " + typescriptVersion + ", the minimum required version is 2.1.0");
110
128
  }
111
129
  return {
112
- typescriptPath,
113
- typescript,
114
- typescriptVersion,
115
- tsconfig,
116
- compilerOptions
130
+ typescriptPath: typescriptPath,
131
+ typescript: typescript,
132
+ typescriptVersion: typescriptVersion,
133
+ tsconfig: tsconfig,
134
+ compilerOptions: compilerOptions
117
135
  };
118
- }
119
- validateTslint(options) {
120
- const tslint = options.tslint
121
- ? options.tslint === true
122
- ? true
123
- : options.tslint
124
- : undefined;
125
- let tslintAutoFix, tslintVersion;
126
- try {
127
- tslintAutoFix = options.tslintAutoFix || false;
128
- tslintVersion = tslint
129
- ? // tslint:disable-next-line:no-implicit-dependencies
130
- require('tslint').Linter.VERSION
131
- : undefined;
132
- }
133
- catch (_ignored) {
134
- throw new Error('When you use `tslint` option, make sure to install `tslint`.');
135
- }
136
- if (tslintVersion && semver.lt(tslintVersion, '4.0.0')) {
137
- throw new Error(`Cannot use current tslint version of ${tslintVersion}, the minimum required version is 4.0.0`);
136
+ };
137
+ ForkTsCheckerWebpackPlugin.prototype.validateEslint = function (options) {
138
+ var eslintVersion;
139
+ var eslintOptions = typeof options.eslintOptions === 'object' ? options.eslintOptions : {};
140
+ if (semver.lt(process.version, '8.10.0')) {
141
+ throw new Error("To use 'eslint' option, please update to Node.js >= v8.10.0 " +
142
+ ("(current version is " + process.version + ")"));
138
143
  }
139
- return { tslint, tslintAutoFix, tslintVersion };
140
- }
141
- validateEslint(options) {
142
- let eslintVersion;
143
- const eslintOptions = typeof options.eslintOptions === 'object' ? options.eslintOptions : {};
144
144
  try {
145
145
  eslintVersion = require('eslint').Linter.version;
146
146
  }
147
- catch (_ignored) {
148
- throw new Error('When you use `eslint` option, make sure to install `eslint`.');
147
+ catch (error) {
148
+ throw new Error("When you use 'eslint' option, make sure to install 'eslint'.");
149
149
  }
150
- return { eslintVersion, eslintOptions };
151
- }
152
- static prepareVueOptions(vueOptions) {
153
- const defaultVueOptions = {
150
+ return { eslintVersion: eslintVersion, eslintOptions: eslintOptions };
151
+ };
152
+ ForkTsCheckerWebpackPlugin.prepareVueOptions = function (vueOptions) {
153
+ var defaultVueOptions = {
154
154
  compiler: 'vue-template-compiler',
155
155
  enabled: false
156
156
  };
@@ -163,162 +163,148 @@ class ForkTsCheckerWebpackPlugin {
163
163
  else {
164
164
  return defaultVueOptions;
165
165
  }
166
- }
167
- apply(compiler) {
166
+ };
167
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
+ ForkTsCheckerWebpackPlugin.prototype.apply = function (compiler) {
168
169
  this.compiler = compiler;
169
170
  this.tsconfigPath = this.computeContextPath(this.tsconfig);
170
- this.tslintPath =
171
- typeof this.tslint === 'string'
172
- ? this.computeContextPath(this.tslint)
173
- : undefined;
174
171
  // validate config
175
- const tsconfigOk = FsHelper_1.fileExistsSync(this.tsconfigPath);
176
- const tslintOk = !this.tslintPath || FsHelper_1.fileExistsSync(this.tslintPath);
172
+ var tsconfigOk = FsHelper_1.fileExistsSync(this.tsconfigPath);
177
173
  // validate logger
178
174
  if (this.logger) {
179
175
  if (!this.logger.error || !this.logger.warn || !this.logger.info) {
180
176
  throw new Error("Invalid logger object - doesn't provide `error`, `warn` or `info` method.");
181
177
  }
182
178
  }
183
- if (tsconfigOk && tslintOk) {
184
- this.pluginStart();
185
- this.pluginStop();
186
- this.pluginCompile();
187
- this.pluginEmit();
188
- this.pluginDone();
189
- }
190
- else {
191
- if (!tsconfigOk) {
192
- throw new Error('Cannot find "' +
193
- this.tsconfigPath +
194
- '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
195
- 'Possible errors: \n' +
196
- ' - wrong `context` directory in webpack configuration' +
197
- ' (if `tsconfig` is not set or is a relative path in fork plugin configuration)\n' +
198
- ' - wrong `tsconfig` path in fork plugin configuration' +
199
- ' (should be a relative or absolute path)');
200
- }
201
- if (!tslintOk) {
202
- throw new Error('Cannot find "' +
203
- this.tslintPath +
204
- '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
205
- 'Possible errors: \n' +
206
- ' - wrong `context` directory in webpack configuration' +
207
- ' (if `tslint` is not set or is a relative path in fork plugin configuration)\n' +
208
- ' - wrong `tslint` path in fork plugin configuration' +
209
- ' (should be a relative or absolute path)\n' +
210
- ' - `tslint` path is not set to false in fork plugin configuration' +
211
- ' (if you want to disable tslint support)');
212
- }
213
- }
214
- }
215
- computeContextPath(filePath) {
179
+ if (!tsconfigOk) {
180
+ throw new Error('Cannot find "' +
181
+ this.tsconfigPath +
182
+ '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
183
+ 'Possible errors: \n' +
184
+ ' - wrong `context` directory in webpack configuration' +
185
+ ' (if `tsconfig` is not set or is a relative path in fork plugin configuration)\n' +
186
+ ' - wrong `tsconfig` path in fork plugin configuration' +
187
+ ' (should be a relative or absolute path)');
188
+ }
189
+ this.pluginStart();
190
+ this.pluginStop();
191
+ this.pluginCompile();
192
+ this.pluginEmit();
193
+ this.pluginDone();
194
+ };
195
+ ForkTsCheckerWebpackPlugin.prototype.computeContextPath = function (filePath) {
216
196
  return path.isAbsolute(filePath)
217
197
  ? filePath
218
198
  : path.resolve(this.compiler.options.context, filePath);
219
- }
220
- pluginStart() {
221
- const run = (compilation, callback) => {
222
- this.isWatching = false;
199
+ };
200
+ ForkTsCheckerWebpackPlugin.prototype.pluginStart = function () {
201
+ var _this = this;
202
+ var run = function (compilation, callback) {
203
+ _this.isWatching = false;
223
204
  callback();
224
205
  };
225
- const watchRun = (compiler, callback) => {
226
- this.isWatching = true;
206
+ var watchRun = function (compiler, callback) {
207
+ _this.isWatching = true;
227
208
  callback();
228
209
  };
229
210
  this.compiler.hooks.run.tapAsync(checkerPluginName, run);
230
211
  this.compiler.hooks.watchRun.tapAsync(checkerPluginName, watchRun);
231
- }
232
- pluginStop() {
233
- const watchClose = () => {
234
- this.killService();
212
+ };
213
+ ForkTsCheckerWebpackPlugin.prototype.pluginStop = function () {
214
+ var _this = this;
215
+ var watchClose = function () {
216
+ _this.killService();
235
217
  };
236
- const done = () => {
237
- if (!this.isWatching) {
238
- this.killService();
218
+ var done = function () {
219
+ if (!_this.isWatching) {
220
+ _this.killService();
239
221
  }
240
222
  };
241
223
  this.compiler.hooks.watchClose.tap(checkerPluginName, watchClose);
242
224
  this.compiler.hooks.done.tap(checkerPluginName, done);
243
- process.on('exit', () => {
244
- this.killService();
225
+ process.on('exit', function () {
226
+ _this.killService();
245
227
  });
246
- }
247
- pluginCompile() {
248
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
249
- this.compiler.hooks.compile.tap(checkerPluginName, () => {
250
- this.compilationDone = false;
251
- forkTsCheckerHooks.serviceBeforeStart.callAsync(() => {
252
- if (this.cancellationToken) {
228
+ };
229
+ ForkTsCheckerWebpackPlugin.prototype.pluginCompile = function () {
230
+ var _this = this;
231
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
232
+ this.compiler.hooks.compile.tap(checkerPluginName, function () {
233
+ _this.compilationDone = false;
234
+ forkTsCheckerHooks.serviceBeforeStart.callAsync(function () {
235
+ if (_this.cancellationToken) {
253
236
  // request cancellation if there is not finished job
254
- this.cancellationToken.requestCancellation();
255
- forkTsCheckerHooks.cancel.call(this.cancellationToken);
237
+ _this.cancellationToken.requestCancellation();
238
+ forkTsCheckerHooks.cancel.call(_this.cancellationToken);
256
239
  }
257
- this.checkDone = false;
258
- this.started = process.hrtime();
240
+ _this.checkDone = false;
241
+ _this.started = process.hrtime();
259
242
  // create new token for current job
260
- this.cancellationToken = new CancellationToken_1.CancellationToken(this.typescript);
261
- if (!this.service || !this.service.connected) {
262
- this.spawnService();
243
+ _this.cancellationToken = new CancellationToken_1.CancellationToken(_this.typescript);
244
+ if (!_this.service || !_this.service.connected) {
245
+ _this.spawnService();
263
246
  }
264
247
  try {
265
- if (this.measureTime) {
266
- this.startAt = this.performance.now();
248
+ if (_this.measureTime) {
249
+ _this.startAt = _this.performance.now();
267
250
  }
268
- this.serviceRpc.rpc(RpcTypes_1.RUN, this.cancellationToken.toJSON()).then(result => {
251
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
252
+ _this.serviceRpc.rpc(RpcTypes_1.RUN, _this.cancellationToken.toJSON()).then(function (result) {
269
253
  if (result) {
270
- this.handleServiceMessage(result);
254
+ _this.handleServiceMessage(result);
271
255
  }
272
256
  });
273
257
  }
274
258
  catch (error) {
275
- if (!this.silent && this.logger) {
276
- this.logger.error(chalk_1.default.red('Cannot start checker service: ' +
259
+ if (!_this.silent && _this.logger) {
260
+ _this.logger.error(chalk_1.default.red('Cannot start checker service: ' +
277
261
  (error ? error.toString() : 'Unknown error')));
278
262
  }
279
263
  forkTsCheckerHooks.serviceStartError.call(error);
280
264
  }
281
265
  });
282
266
  });
283
- }
284
- pluginEmit() {
285
- const emit = (compilation, callback) => {
286
- if (this.isWatching && this.async) {
267
+ };
268
+ ForkTsCheckerWebpackPlugin.prototype.pluginEmit = function () {
269
+ var _this = this;
270
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
271
+ var emit = function (compilation, callback) {
272
+ if (_this.isWatching && _this.async) {
287
273
  callback();
288
274
  return;
289
275
  }
290
- this.emitCallback = this.createEmitCallback(compilation, callback);
291
- if (this.checkDone) {
292
- this.emitCallback();
276
+ _this.emitCallback = _this.createEmitCallback(compilation, callback);
277
+ if (_this.checkDone) {
278
+ _this.emitCallback();
293
279
  }
294
- this.compilationDone = true;
280
+ _this.compilationDone = true;
295
281
  };
296
282
  this.compiler.hooks.emit.tapAsync(checkerPluginName, emit);
297
- }
298
- pluginDone() {
299
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
300
- this.compiler.hooks.done.tap(checkerPluginName, (_stats) => {
301
- if (!this.isWatching || !this.async) {
283
+ };
284
+ ForkTsCheckerWebpackPlugin.prototype.pluginDone = function () {
285
+ var _this = this;
286
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
287
+ this.compiler.hooks.done.tap(checkerPluginName, function () {
288
+ if (!_this.isWatching || !_this.async) {
302
289
  return;
303
290
  }
304
- if (this.checkDone) {
305
- this.doneCallback();
291
+ if (_this.checkDone) {
292
+ _this.doneCallback();
306
293
  }
307
294
  else {
308
- if (this.compiler) {
309
- forkTsCheckerHooks.waiting.call(this.tslint !== undefined);
295
+ if (_this.compiler) {
296
+ forkTsCheckerHooks.waiting.call();
310
297
  }
311
- if (!this.silent && this.logger) {
312
- this.logger.info(this.tslint
313
- ? 'Type checking and linting in progress...'
314
- : 'Type checking in progress...');
298
+ if (!_this.silent && _this.logger) {
299
+ _this.logger.info('Type checking in progress...');
315
300
  }
316
301
  }
317
- this.compilationDone = true;
302
+ _this.compilationDone = true;
318
303
  });
319
- }
320
- spawnService() {
321
- const env = Object.assign({}, process.env, { TYPESCRIPT_PATH: this.typescriptPath, TSCONFIG: this.tsconfigPath, COMPILER_OPTIONS: JSON.stringify(this.compilerOptions), TSLINT: this.tslintPath || (this.tslint ? 'true' : ''), CONTEXT: this.compiler.options.context, TSLINTAUTOFIX: String(this.tslintAutoFix), ESLINT: String(this.eslint), ESLINT_OPTIONS: JSON.stringify(this.eslintOptions), MEMORY_LIMIT: String(this.memoryLimit), CHECK_SYNTACTIC_ERRORS: String(this.checkSyntacticErrors), USE_INCREMENTAL_API: String(this.useTypescriptIncrementalApi === true), VUE: JSON.stringify(this.vue) });
304
+ };
305
+ ForkTsCheckerWebpackPlugin.prototype.spawnService = function () {
306
+ var _this = this;
307
+ var env = __assign({}, process.env, { TYPESCRIPT_PATH: this.typescriptPath, TSCONFIG: this.tsconfigPath, COMPILER_OPTIONS: JSON.stringify(this.compilerOptions), CONTEXT: this.compiler.options.context, ESLINT: String(this.eslint), ESLINT_OPTIONS: JSON.stringify(this.eslintOptions), MEMORY_LIMIT: String(this.memoryLimit), CHECK_SYNTACTIC_ERRORS: String(this.checkSyntacticErrors), USE_INCREMENTAL_API: String(this.useTypescriptIncrementalApi === true), VUE: JSON.stringify(this.vue) });
322
308
  if (typeof this.resolveModuleNameModule !== 'undefined') {
323
309
  env.RESOLVE_MODULE_NAME = this.resolveModuleNameModule;
324
310
  }
@@ -332,22 +318,24 @@ class ForkTsCheckerWebpackPlugin {
332
318
  delete env.RESOLVE_TYPE_REFERENCE_DIRECTIVE;
333
319
  }
334
320
  this.service = childProcess.fork(path.resolve(__dirname, './service.js'), [], {
335
- env,
321
+ env: env,
336
322
  execArgv: ['--max-old-space-size=' + this.memoryLimit].concat(this.nodeArgs),
337
323
  stdio: ['inherit', 'inherit', 'inherit', 'ipc']
338
324
  });
339
- this.serviceRpc = new worker_rpc_1.RpcProvider(message => this.service.send(message));
340
- this.service.on('message', message => this.serviceRpc.dispatch(message));
341
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
342
- forkTsCheckerHooks.serviceStart.call(this.tsconfigPath, this.tslintPath, this.memoryLimit);
325
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
326
+ this.serviceRpc = new worker_rpc_1.RpcProvider(function (message) { return _this.service.send(message); });
327
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
328
+ this.service.on('message', function (message) { return _this.serviceRpc.dispatch(message); });
329
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
330
+ forkTsCheckerHooks.serviceStart.call(this.tsconfigPath, this.memoryLimit);
343
331
  if (!this.silent && this.logger) {
344
- this.logger.info('Starting type checking' +
345
- (this.tslint ? ' and linting' : '') +
346
- ' service...');
332
+ this.logger.info('Starting type checking service...');
347
333
  }
348
- this.service.on('exit', (code, signal) => this.handleServiceExit(code, signal));
349
- }
350
- killService() {
334
+ this.service.on('exit', function (code, signal) {
335
+ return _this.handleServiceExit(code, signal);
336
+ });
337
+ };
338
+ ForkTsCheckerWebpackPlugin.prototype.killService = function () {
351
339
  if (!this.service) {
352
340
  return;
353
341
  }
@@ -364,12 +352,13 @@ class ForkTsCheckerWebpackPlugin {
364
352
  this.logger.error(e);
365
353
  }
366
354
  }
367
- }
368
- handleServiceMessage(message) {
355
+ };
356
+ ForkTsCheckerWebpackPlugin.prototype.handleServiceMessage = function (message) {
357
+ var _this = this;
369
358
  if (this.measureTime) {
370
- const delta = this.performance.now() - this.startAt;
371
- const deltaRounded = Math.round(delta * 100) / 100;
372
- this.logger.info(`Compilation took: ${deltaRounded} ms.`);
359
+ var delta = this.performance.now() - this.startAt;
360
+ var deltaRounded = Math.round(delta * 100) / 100;
361
+ this.logger.info("Compilation took: " + deltaRounded + " ms.");
373
362
  }
374
363
  if (this.cancellationToken) {
375
364
  this.cancellationToken.cleanupCancellation();
@@ -381,16 +370,18 @@ class ForkTsCheckerWebpackPlugin {
381
370
  this.diagnostics = message.diagnostics;
382
371
  this.lints = message.lints;
383
372
  if (this.ignoreDiagnostics.length) {
384
- this.diagnostics = this.diagnostics.filter(diagnostic => !this.ignoreDiagnostics.includes(parseInt(diagnostic.code, 10)));
373
+ this.diagnostics = this.diagnostics.filter(function (diagnostic) {
374
+ return !_this.ignoreDiagnostics.includes(parseInt(diagnostic.code, 10));
375
+ });
385
376
  }
386
377
  if (this.ignoreLints.length) {
387
- this.lints = this.lints.filter(lint => !this.ignoreLints.includes(lint.code));
378
+ this.lints = this.lints.filter(function (lint) { return !_this.ignoreLints.includes(lint.code); });
388
379
  }
389
380
  if (this.reportFiles.length) {
390
- const reportFilesPredicate = (issue) => {
381
+ var reportFilesPredicate = function (issue) {
391
382
  if (issue.file) {
392
- const relativeFileName = path.relative(this.compiler.options.context, issue.file);
393
- const matchResult = micromatch([relativeFileName], this.reportFiles);
383
+ var relativeFileName = path.relative(_this.compiler.options.context, issue.file);
384
+ var matchResult = micromatch_1.default([relativeFileName], _this.reportFiles);
394
385
  if (matchResult.length === 0) {
395
386
  return false;
396
387
  }
@@ -400,39 +391,40 @@ class ForkTsCheckerWebpackPlugin {
400
391
  this.diagnostics = this.diagnostics.filter(reportFilesPredicate);
401
392
  this.lints = this.lints.filter(reportFilesPredicate);
402
393
  }
403
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
394
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
404
395
  forkTsCheckerHooks.receive.call(this.diagnostics, this.lints);
405
396
  if (this.compilationDone) {
406
397
  this.isWatching && this.async ? this.doneCallback() : this.emitCallback();
407
398
  }
408
- }
409
- handleServiceExit(_code, signal) {
399
+ };
400
+ ForkTsCheckerWebpackPlugin.prototype.handleServiceExit = function (_code, signal) {
410
401
  if (signal !== 'SIGABRT') {
411
402
  return;
412
403
  }
413
404
  // probably out of memory :/
414
405
  if (this.compiler) {
415
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
406
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
416
407
  forkTsCheckerHooks.serviceOutOfMemory.call();
417
408
  }
418
409
  if (!this.silent && this.logger) {
419
410
  this.logger.error(chalk_1.default.red('Type checking and linting aborted - probably out of memory. ' +
420
411
  'Check `memoryLimit` option in ForkTsCheckerWebpackPlugin configuration.'));
421
412
  }
422
- }
423
- createEmitCallback(compilation, callback) {
413
+ };
414
+ ForkTsCheckerWebpackPlugin.prototype.createEmitCallback = function (compilation, callback) {
424
415
  return function emitCallback() {
416
+ var _this = this;
425
417
  if (!this.elapsed) {
426
418
  throw new Error('Execution order error');
427
419
  }
428
- const elapsed = Math.round(this.elapsed[0] * 1e9 + this.elapsed[1]);
429
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
420
+ var elapsed = Math.round(this.elapsed[0] * 1e9 + this.elapsed[1]);
421
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
430
422
  forkTsCheckerHooks.emit.call(this.diagnostics, this.lints, elapsed);
431
- this.diagnostics.concat(this.lints).forEach(issue => {
423
+ this.diagnostics.concat(this.lints).forEach(function (issue) {
432
424
  // webpack message format
433
- const formatted = {
434
- rawMessage: this.rawFormatter(issue),
435
- message: this.formatter(issue),
425
+ var formatted = {
426
+ rawMessage: _this.rawFormatter(issue),
427
+ message: _this.formatter(issue),
436
428
  location: {
437
429
  line: issue.line,
438
430
  character: issue.character
@@ -440,7 +432,7 @@ class ForkTsCheckerWebpackPlugin {
440
432
  file: issue.file
441
433
  };
442
434
  if (issue.severity === issue_1.IssueSeverity.WARNING) {
443
- if (!this.ignoreLintWarnings) {
435
+ if (!_this.ignoreLintWarnings) {
444
436
  compilation.warnings.push(formatted);
445
437
  }
446
438
  }
@@ -450,12 +442,13 @@ class ForkTsCheckerWebpackPlugin {
450
442
  });
451
443
  callback();
452
444
  };
453
- }
454
- createNoopEmitCallback() {
455
- // tslint:disable-next-line:no-empty
445
+ };
446
+ ForkTsCheckerWebpackPlugin.prototype.createNoopEmitCallback = function () {
447
+ // this function is empty intentionally
448
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
456
449
  return function noopEmitCallback() { };
457
- }
458
- printLoggerMessage(issue, formattedIssue) {
450
+ };
451
+ ForkTsCheckerWebpackPlugin.prototype.printLoggerMessage = function (issue, formattedIssue) {
459
452
  if (issue.severity === issue_1.IssueSeverity.WARNING) {
460
453
  if (this.ignoreLintWarnings) {
461
454
  return;
@@ -465,42 +458,39 @@ class ForkTsCheckerWebpackPlugin {
465
458
  else {
466
459
  this.logger.error(formattedIssue);
467
460
  }
468
- }
469
- createDoneCallback() {
461
+ };
462
+ ForkTsCheckerWebpackPlugin.prototype.createDoneCallback = function () {
470
463
  return function doneCallback() {
464
+ var _this = this;
471
465
  if (!this.elapsed) {
472
466
  throw new Error('Execution order error');
473
467
  }
474
- const elapsed = Math.round(this.elapsed[0] * 1e9 + this.elapsed[1]);
468
+ var elapsed = Math.round(this.elapsed[0] * 1e9 + this.elapsed[1]);
475
469
  if (this.compiler) {
476
- const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
470
+ var forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
477
471
  forkTsCheckerHooks.done.call(this.diagnostics, this.lints, elapsed);
478
472
  }
479
473
  if (!this.silent && this.logger) {
480
474
  if (this.diagnostics.length || this.lints.length) {
481
- (this.lints || []).concat(this.diagnostics).forEach(diagnostic => {
482
- const formattedDiagnostic = this.formatter(diagnostic);
483
- this.printLoggerMessage(diagnostic, formattedDiagnostic);
475
+ (this.lints || []).concat(this.diagnostics).forEach(function (diagnostic) {
476
+ var formattedDiagnostic = _this.formatter(diagnostic);
477
+ _this.printLoggerMessage(diagnostic, formattedDiagnostic);
484
478
  });
485
479
  }
486
480
  if (!this.diagnostics.length) {
487
481
  this.logger.info(chalk_1.default.green('No type errors found'));
488
482
  }
489
- if (this.tslint && !this.lints.length) {
490
- this.logger.info(chalk_1.default.green('No lint errors found'));
491
- }
492
483
  this.logger.info('Version: typescript ' +
493
484
  chalk_1.default.bold(this.typescriptVersion) +
494
485
  (this.eslint
495
486
  ? ', eslint ' + chalk_1.default.bold(this.eslintVersion)
496
- : this.tslint
497
- ? ', tslint ' + chalk_1.default.bold(this.tslintVersion)
498
- : ''));
487
+ : ''));
499
488
  this.logger.info('Time: ' + chalk_1.default.bold(Math.round(elapsed / 1e6).toString()) + 'ms');
500
489
  }
501
490
  };
502
- }
503
- }
504
- ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT = 2048;
491
+ };
492
+ ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT = 2048;
493
+ return ForkTsCheckerWebpackPlugin;
494
+ }());
505
495
  module.exports = ForkTsCheckerWebpackPlugin;
506
496
  //# sourceMappingURL=index.js.map