fork-ts-checker-webpack-plugin 0.4.7 → 0.4.11

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.
package/lib/index.js CHANGED
@@ -7,12 +7,11 @@ var fs = require("fs");
7
7
  var os = require("os");
8
8
  var isString = require("lodash.isstring");
9
9
  var isFunction = require("lodash.isfunction");
10
- var CancellationToken = require("./CancellationToken");
11
- var NormalizedMessage = require("./NormalizedMessage");
12
- var createDefaultFormatter = require("./formatter/defaultFormatter");
13
- var createCodeframeFormatter = require("./formatter/codeframeFormatter");
14
- var AsyncSeriesHook = require("tapable").AsyncSeriesHook;
15
- var SyncHook = require("tapable").SyncHook;
10
+ var CancellationToken_1 = require("./CancellationToken");
11
+ var NormalizedMessage_1 = require("./NormalizedMessage");
12
+ var defaultFormatter_1 = require("./formatter/defaultFormatter");
13
+ var codeframeFormatter_1 = require("./formatter/codeframeFormatter");
14
+ var tapable_1 = require("tapable");
16
15
  var checkerPluginName = 'fork-ts-checker-webpack-plugin';
17
16
  var customHooks = {
18
17
  forkTsCheckerServiceBeforeStart: 'fork-ts-checker-service-before-start',
@@ -37,9 +36,14 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
37
36
  options = options || {};
38
37
  this.options = Object.assign({}, options);
39
38
  this.tsconfig = options.tsconfig || './tsconfig.json';
40
- this.tslint = options.tslint ?
41
- options.tslint === true ? './tslint.json' : options.tslint : undefined;
42
- this.watch = isString(options.watch) ? [options.watch] : options.watch || [];
39
+ this.tslint = options.tslint
40
+ ? options.tslint === true
41
+ ? './tslint.json'
42
+ : options.tslint
43
+ : undefined;
44
+ this.watch = isString(options.watch)
45
+ ? [options.watch]
46
+ : options.watch || [];
43
47
  this.ignoreDiagnostics = options.ignoreDiagnostics || [];
44
48
  this.ignoreLints = options.ignoreLints || [];
45
49
  this.logger = options.logger || console;
@@ -47,12 +51,14 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
47
51
  this.async = options.async !== false; // default true
48
52
  this.checkSyntacticErrors = options.checkSyntacticErrors === true; // default false
49
53
  this.workersNumber = options.workers || ForkTsCheckerWebpackPlugin.ONE_CPU;
50
- this.memoryLimit = options.memoryLimit || ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT;
54
+ this.memoryLimit =
55
+ options.memoryLimit || ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT;
51
56
  this.useColors = options.colors !== false; // default true
52
57
  this.colors = new chalk_1.default.constructor({ enabled: this.useColors });
53
- this.formatter = (options.formatter && isFunction(options.formatter))
54
- ? options.formatter
55
- : ForkTsCheckerWebpackPlugin.createFormatter(options.formatter || 'default', options.formatterOptions || {});
58
+ this.formatter =
59
+ options.formatter && isFunction(options.formatter)
60
+ ? options.formatter
61
+ : ForkTsCheckerWebpackPlugin.createFormatter(options.formatter || 'default', options.formatterOptions || {});
56
62
  this.tsconfigPath = undefined;
57
63
  this.tslintPath = undefined;
58
64
  this.watchPaths = [];
@@ -68,15 +74,17 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
68
74
  this.emitCallback = this.createNoopEmitCallback();
69
75
  this.doneCallback = this.createDoneCallback();
70
76
  this.typescriptVersion = require('typescript').version;
71
- this.tslintVersion = this.tslint ? require('tslint').Linter.VERSION : undefined;
77
+ this.tslintVersion = this.tslint
78
+ ? require('tslint').Linter.VERSION
79
+ : undefined;
72
80
  this.vue = options.vue === true; // default false
73
81
  }
74
82
  ForkTsCheckerWebpackPlugin.createFormatter = function (type, options) {
75
83
  switch (type) {
76
84
  case 'default':
77
- return createDefaultFormatter();
85
+ return defaultFormatter_1.createDefaultFormatter();
78
86
  case 'codeframe':
79
- return createCodeframeFormatter(options);
87
+ return codeframeFormatter_1.createCodeframeFormatter(options);
80
88
  default:
81
89
  throw new Error('Unknown "' + type + '" formatter. Available are: default, codeframe.');
82
90
  }
@@ -84,7 +92,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
84
92
  ForkTsCheckerWebpackPlugin.prototype.apply = function (compiler) {
85
93
  this.compiler = compiler;
86
94
  this.tsconfigPath = this.computeContextPath(this.tsconfig);
87
- this.tslintPath = this.tslint ? this.computeContextPath(this.tslint) : null;
95
+ this.tslintPath = this.tslint
96
+ ? this.computeContextPath(this.tslint)
97
+ : null;
88
98
  this.watchPaths = this.watch.map(this.computeContextPath.bind(this));
89
99
  // validate config
90
100
  var tsconfigOk = fs.existsSync(this.tsconfigPath);
@@ -92,7 +102,7 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
92
102
  // validate logger
93
103
  if (this.logger) {
94
104
  if (!this.logger.error || !this.logger.warn || !this.logger.info) {
95
- throw new Error('Invalid logger object - doesn\'t provide `error`, `warn` or `info` method.');
105
+ throw new Error("Invalid logger object - doesn't provide `error`, `warn` or `info` method.");
96
106
  }
97
107
  }
98
108
  if (tsconfigOk && tslintOk) {
@@ -107,7 +117,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
107
117
  }
108
118
  else {
109
119
  if (!tsconfigOk) {
110
- throw new Error('Cannot find "' + this.tsconfigPath + '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
120
+ throw new Error('Cannot find "' +
121
+ this.tsconfigPath +
122
+ '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
111
123
  'Possible errors: \n' +
112
124
  ' - wrong `context` directory in webpack configuration' +
113
125
  ' (if `tsconfig` is not set or is a relative path in fork plugin configuration)\n' +
@@ -115,7 +127,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
115
127
  ' (should be a relative or absolute path)');
116
128
  }
117
129
  if (!tslintOk) {
118
- throw new Error('Cannot find "' + this.tslintPath + '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
130
+ throw new Error('Cannot find "' +
131
+ this.tslintPath +
132
+ '" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. \n' +
119
133
  'Possible errors: \n' +
120
134
  ' - wrong `context` directory in webpack configuration' +
121
135
  ' (if `tslint` is not set or is a relative path in fork plugin configuration)\n' +
@@ -127,7 +141,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
127
141
  }
128
142
  };
129
143
  ForkTsCheckerWebpackPlugin.prototype.computeContextPath = function (filePath) {
130
- return path.isAbsolute(filePath) ? filePath : path.resolve(this.compiler.options.context, filePath);
144
+ return path.isAbsolute(filePath)
145
+ ? filePath
146
+ : path.resolve(this.compiler.options.context, filePath);
131
147
  };
132
148
  ForkTsCheckerWebpackPlugin.prototype.pluginStart = function () {
133
149
  var _this = this;
@@ -175,26 +191,47 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
175
191
  });
176
192
  };
177
193
  ForkTsCheckerWebpackPlugin.prototype.registerCustomHooks = function () {
178
- if (this.compiler.hooks.forkTsCheckerServiceBeforeStart
179
- || this.compiler.hooks.forkTsCheckerCancel
180
- || this.compiler.hooks.forkTsCheckerServiceStartError
181
- || this.compiler.hooks.forkTsCheckerWaiting
182
- || this.compiler.hooks.forkTsCheckerServiceStart
183
- || this.compiler.hooks.forkTsCheckerReceive
184
- || this.compiler.hooks.forkTsCheckerServiceOutOfMemory
185
- || this.compiler.hooks.forkTsCheckerDone
186
- || this.compiler.hooks.forkTsCheckerEmit) {
194
+ if (this.compiler.hooks.forkTsCheckerServiceBeforeStart ||
195
+ this.compiler.hooks.forkTsCheckerCancel ||
196
+ this.compiler.hooks.forkTsCheckerServiceStartError ||
197
+ this.compiler.hooks.forkTsCheckerWaiting ||
198
+ this.compiler.hooks.forkTsCheckerServiceStart ||
199
+ this.compiler.hooks.forkTsCheckerReceive ||
200
+ this.compiler.hooks.forkTsCheckerServiceOutOfMemory ||
201
+ this.compiler.hooks.forkTsCheckerDone ||
202
+ this.compiler.hooks.forkTsCheckerEmit) {
187
203
  throw new Error('fork-ts-checker-webpack-plugin hooks are already in use');
188
204
  }
189
- this.compiler.hooks.forkTsCheckerServiceBeforeStart = new AsyncSeriesHook([]);
190
- this.compiler.hooks.forkTsCheckerCancel = new SyncHook(['cancellationToken']);
191
- this.compiler.hooks.forkTsCheckerServiceStartError = new SyncHook(['error']);
192
- this.compiler.hooks.forkTsCheckerWaiting = new SyncHook(['hasTsLint']);
193
- this.compiler.hooks.forkTsCheckerServiceStart = new SyncHook(['tsconfigPath', 'tslintPath', 'watchPaths', 'workersNumber', 'memoryLimit']);
194
- this.compiler.hooks.forkTsCheckerReceive = new SyncHook(['diagnostics', 'lints']);
195
- this.compiler.hooks.forkTsCheckerServiceOutOfMemory = new SyncHook([]);
196
- this.compiler.hooks.forkTsCheckerEmit = new SyncHook(['diagnostics', 'lints', 'elapsed']);
197
- this.compiler.hooks.forkTsCheckerDone = new SyncHook(['diagnostics', 'lints', 'elapsed']);
205
+ this.compiler.hooks.forkTsCheckerServiceBeforeStart = new tapable_1.AsyncSeriesHook([]);
206
+ this.compiler.hooks.forkTsCheckerCancel = new tapable_1.SyncHook([
207
+ 'cancellationToken'
208
+ ]);
209
+ this.compiler.hooks.forkTsCheckerServiceStartError = new tapable_1.SyncHook([
210
+ 'error'
211
+ ]);
212
+ this.compiler.hooks.forkTsCheckerWaiting = new tapable_1.SyncHook(['hasTsLint']);
213
+ this.compiler.hooks.forkTsCheckerServiceStart = new tapable_1.SyncHook([
214
+ 'tsconfigPath',
215
+ 'tslintPath',
216
+ 'watchPaths',
217
+ 'workersNumber',
218
+ 'memoryLimit'
219
+ ]);
220
+ this.compiler.hooks.forkTsCheckerReceive = new tapable_1.SyncHook([
221
+ 'diagnostics',
222
+ 'lints'
223
+ ]);
224
+ this.compiler.hooks.forkTsCheckerServiceOutOfMemory = new tapable_1.SyncHook([]);
225
+ this.compiler.hooks.forkTsCheckerEmit = new tapable_1.SyncHook([
226
+ 'diagnostics',
227
+ 'lints',
228
+ 'elapsed'
229
+ ]);
230
+ this.compiler.hooks.forkTsCheckerDone = new tapable_1.SyncHook([
231
+ 'diagnostics',
232
+ 'lints',
233
+ 'elapsed'
234
+ ]);
198
235
  // for backwards compatibility
199
236
  this.compiler._pluginCompat.tap(checkerPluginName, function (options) {
200
237
  switch (options.name) {
@@ -219,6 +256,7 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
219
256
  if ('hooks' in this.compiler) {
220
257
  // webpack 4
221
258
  this.compiler.hooks.compile.tap(checkerPluginName, function () {
259
+ _this.compilationDone = false;
222
260
  _this.compiler.hooks.forkTsCheckerServiceBeforeStart.callAsync(function () {
223
261
  if (_this.cancellationToken) {
224
262
  // request cancellation if there is not finished job
@@ -226,10 +264,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
226
264
  _this.compiler.hooks.forkTsCheckerCancel.call(_this.cancellationToken);
227
265
  }
228
266
  _this.checkDone = false;
229
- _this.compilationDone = false;
230
267
  _this.started = process.hrtime();
231
268
  // create new token for current job
232
- _this.cancellationToken = new CancellationToken(undefined, undefined);
269
+ _this.cancellationToken = new CancellationToken_1.CancellationToken(undefined, undefined);
233
270
  if (!_this.service || !_this.service.connected) {
234
271
  _this.spawnService();
235
272
  }
@@ -238,7 +275,8 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
238
275
  }
239
276
  catch (error) {
240
277
  if (!_this.silent && _this.logger) {
241
- _this.logger.error(_this.colors.red('Cannot start checker service: ' + (error ? error.toString() : 'Unknown error')));
278
+ _this.logger.error(_this.colors.red('Cannot start checker service: ' +
279
+ (error ? error.toString() : 'Unknown error')));
242
280
  }
243
281
  _this.compiler.hooks.forkTsCheckerServiceStartError.call(error);
244
282
  }
@@ -248,6 +286,7 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
248
286
  else {
249
287
  // webpack 2 / 3
250
288
  this.compiler.plugin('compile', function () {
289
+ _this.compilationDone = false;
251
290
  _this.compiler.applyPluginsAsync('fork-ts-checker-service-before-start', function () {
252
291
  if (_this.cancellationToken) {
253
292
  // request cancellation if there is not finished job
@@ -255,10 +294,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
255
294
  _this.compiler.applyPlugins('fork-ts-checker-cancel', _this.cancellationToken);
256
295
  }
257
296
  _this.checkDone = false;
258
- _this.compilationDone = false;
259
297
  _this.started = process.hrtime();
260
298
  // create new token for current job
261
- _this.cancellationToken = new CancellationToken(undefined, undefined);
299
+ _this.cancellationToken = new CancellationToken_1.CancellationToken(undefined, undefined);
262
300
  if (!_this.service || !_this.service.connected) {
263
301
  _this.spawnService();
264
302
  }
@@ -267,7 +305,8 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
267
305
  }
268
306
  catch (error) {
269
307
  if (!_this.silent && _this.logger) {
270
- _this.logger.error(_this.colors.red('Cannot start checker service: ' + (error ? error.toString() : 'Unknown error')));
308
+ _this.logger.error(_this.colors.red('Cannot start checker service: ' +
309
+ (error ? error.toString() : 'Unknown error')));
271
310
  }
272
311
  _this.compiler.applyPlugins('fork-ts-checker-service-start-error', error);
273
312
  }
@@ -347,7 +386,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
347
386
  ForkTsCheckerWebpackPlugin.prototype.spawnService = function () {
348
387
  var _this = this;
349
388
  this.service = childProcess.fork(path.resolve(__dirname, this.workersNumber > 1 ? './cluster.js' : './service.js'), [], {
350
- execArgv: this.workersNumber > 1 ? [] : ['--max-old-space-size=' + this.memoryLimit],
389
+ execArgv: this.workersNumber > 1
390
+ ? []
391
+ : ['--max-old-space-size=' + this.memoryLimit],
351
392
  env: Object.assign({}, process.env, {
352
393
  TSCONFIG: this.tsconfigPath,
353
394
  TSLINT: this.tslintPath || '',
@@ -368,19 +409,28 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
368
409
  this.compiler.applyPlugins('fork-ts-checker-service-start', this.tsconfigPath, this.tslintPath, this.watchPaths, this.workersNumber, this.memoryLimit);
369
410
  }
370
411
  if (!this.silent && this.logger) {
371
- this.logger.info('Starting type checking' + (this.tslint ? ' and linting' : '') + ' service...');
372
- this.logger.info('Using ' + this.colors.bold(this.workersNumber === 1 ? '1 worker' : this.workersNumber + ' workers') +
373
- ' with ' + this.colors.bold(this.memoryLimit + 'MB') + ' memory limit');
412
+ this.logger.info('Starting type checking' +
413
+ (this.tslint ? ' and linting' : '') +
414
+ ' service...');
415
+ this.logger.info('Using ' +
416
+ this.colors.bold(this.workersNumber === 1
417
+ ? '1 worker'
418
+ : this.workersNumber + ' workers') +
419
+ ' with ' +
420
+ this.colors.bold(this.memoryLimit + 'MB') +
421
+ ' memory limit');
374
422
  if (this.watchPaths.length && this.isWatching) {
375
423
  this.logger.info('Watching:' +
376
424
  (this.watchPaths.length > 1 ? '\n' : ' ') +
377
- this.watchPaths
378
- .map(function (wpath) { return _this.colors.grey(wpath); })
379
- .join('\n'));
425
+ this.watchPaths.map(function (wpath) { return _this.colors.grey(wpath); }).join('\n'));
380
426
  }
381
427
  }
382
- this.service.on('message', function (message) { return _this.handleServiceMessage(message); });
383
- this.service.on('exit', function (code, signal) { return _this.handleServiceExit(code, signal); });
428
+ this.service.on('message', function (message) {
429
+ return _this.handleServiceMessage(message);
430
+ });
431
+ this.service.on('exit', function (code, signal) {
432
+ return _this.handleServiceExit(code, signal);
433
+ });
384
434
  };
385
435
  ForkTsCheckerWebpackPlugin.prototype.killService = function () {
386
436
  if (this.service) {
@@ -407,17 +457,15 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
407
457
  }
408
458
  this.checkDone = true;
409
459
  this.elapsed = process.hrtime(this.started);
410
- this.diagnostics = message.diagnostics.map(NormalizedMessage.createFromJSON);
411
- this.lints = message.lints.map(NormalizedMessage.createFromJSON);
460
+ this.diagnostics = message.diagnostics.map(NormalizedMessage_1.NormalizedMessage.createFromJSON);
461
+ this.lints = message.lints.map(NormalizedMessage_1.NormalizedMessage.createFromJSON);
412
462
  if (this.ignoreDiagnostics.length) {
413
463
  this.diagnostics = this.diagnostics.filter(function (diagnostic) {
414
464
  return _this.ignoreDiagnostics.indexOf(parseInt(diagnostic.getCode(), 10)) === -1;
415
465
  });
416
466
  }
417
467
  if (this.ignoreLints.length) {
418
- this.lints = this.lints.filter(function (lint) {
419
- return _this.ignoreLints.indexOf(lint.getCode()) === -1;
420
- });
468
+ this.lints = this.lints.filter(function (lint) { return _this.ignoreLints.indexOf(lint.getCode()) === -1; });
421
469
  }
422
470
  if ('hooks' in this.compiler) {
423
471
  // webpack 4
@@ -428,7 +476,7 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
428
476
  this.compiler.applyPlugins('fork-ts-checker-receive', this.diagnostics, this.lints);
429
477
  }
430
478
  if (this.compilationDone) {
431
- (this.isWatching && this.async) ? this.doneCallback() : this.emitCallback();
479
+ this.isWatching && this.async ? this.doneCallback() : this.emitCallback();
432
480
  }
433
481
  };
434
482
  ForkTsCheckerWebpackPlugin.prototype.handleServiceExit = function (_code, signal) {
@@ -453,7 +501,7 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
453
501
  ForkTsCheckerWebpackPlugin.prototype.createEmitCallback = function (compilation, callback) {
454
502
  return function emitCallback() {
455
503
  var _this = this;
456
- var elapsed = Math.round(this.elapsed[0] * 1E9 + this.elapsed[1]);
504
+ var elapsed = Math.round(this.elapsed[0] * 1e9 + this.elapsed[1]);
457
505
  if ('hooks' in this.compiler) {
458
506
  // webpack 4
459
507
  this.compiler.hooks.forkTsCheckerEmit.call(this.diagnostics, this.lints, elapsed);
@@ -465,8 +513,11 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
465
513
  this.diagnostics.concat(this.lints).forEach(function (message) {
466
514
  // webpack message format
467
515
  var formatted = {
468
- rawMessage: (message.getSeverity().toUpperCase() + ' ' + message.getFormattedCode() + ': ' +
469
- message.getContent()),
516
+ rawMessage: message.getSeverity().toUpperCase() +
517
+ ' ' +
518
+ message.getFormattedCode() +
519
+ ': ' +
520
+ message.getContent(),
470
521
  message: _this.formatter(message, _this.useColors),
471
522
  location: {
472
523
  line: message.getLine(),
@@ -491,7 +542,7 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
491
542
  ForkTsCheckerWebpackPlugin.prototype.createDoneCallback = function () {
492
543
  return function doneCallback() {
493
544
  var _this = this;
494
- var elapsed = Math.round(this.elapsed[0] * 1E9 + this.elapsed[1]);
545
+ var elapsed = Math.round(this.elapsed[0] * 1e9 + this.elapsed[1]);
495
546
  if (this.compiler) {
496
547
  if ('hooks' in this.compiler) {
497
548
  // webpack 4
@@ -506,7 +557,9 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
506
557
  if (this.diagnostics.length || this.lints.length) {
507
558
  (this.lints || []).concat(this.diagnostics).forEach(function (message) {
508
559
  var formattedMessage = _this.formatter(message, _this.useColors);
509
- message.isWarningSeverity() ? _this.logger.warn(formattedMessage) : _this.logger.error(formattedMessage);
560
+ message.isWarningSeverity()
561
+ ? _this.logger.warn(formattedMessage)
562
+ : _this.logger.error(formattedMessage);
510
563
  });
511
564
  }
512
565
  if (!this.diagnostics.length) {
@@ -515,15 +568,20 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
515
568
  if (this.tslint && !this.lints.length) {
516
569
  this.logger.info(this.colors.green('No lint errors found'));
517
570
  }
518
- this.logger.info('Version: typescript ' + this.colors.bold(this.typescriptVersion) +
519
- (this.tslint ? ', tslint ' + this.colors.bold(this.tslintVersion) : ''));
520
- this.logger.info('Time: ' + this.colors.bold(Math.round(elapsed / 1E6).toString()) + 'ms');
571
+ this.logger.info('Version: typescript ' +
572
+ this.colors.bold(this.typescriptVersion) +
573
+ (this.tslint
574
+ ? ', tslint ' + this.colors.bold(this.tslintVersion)
575
+ : ''));
576
+ this.logger.info('Time: ' +
577
+ this.colors.bold(Math.round(elapsed / 1e6).toString()) +
578
+ 'ms');
521
579
  }
522
580
  };
523
581
  };
524
582
  ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT = 2048;
525
583
  ForkTsCheckerWebpackPlugin.ONE_CPU = 1;
526
- ForkTsCheckerWebpackPlugin.ALL_CPUS = os.cpus().length;
584
+ ForkTsCheckerWebpackPlugin.ALL_CPUS = os.cpus && os.cpus() ? os.cpus().length : 1;
527
585
  ForkTsCheckerWebpackPlugin.ONE_CPU_FREE = Math.max(1, ForkTsCheckerWebpackPlugin.ALL_CPUS - 1);
528
586
  ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE = Math.max(1, ForkTsCheckerWebpackPlugin.ALL_CPUS - 2);
529
587
  return ForkTsCheckerWebpackPlugin;
package/lib/service.js CHANGED
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var process = require("process");
4
4
  var ts = require("typescript");
5
- var IncrementalChecker = require("./IncrementalChecker");
6
- var CancellationToken = require("./CancellationToken");
7
- var checker = new IncrementalChecker(process.env.TSCONFIG, process.env.TSLINT === '' ? false : process.env.TSLINT, process.env.WATCH === '' ? [] : process.env.WATCH.split('|'), parseInt(process.env.WORK_NUMBER, 10), parseInt(process.env.WORK_DIVISION, 10), process.env.CHECK_SYNTACTIC_ERRORS === 'true', process.env.VUE === 'true');
5
+ var IncrementalChecker_1 = require("./IncrementalChecker");
6
+ var CancellationToken_1 = require("./CancellationToken");
7
+ var checker = new IncrementalChecker_1.IncrementalChecker(process.env.TSCONFIG, process.env.TSLINT === '' ? false : process.env.TSLINT, process.env.WATCH === '' ? [] : process.env.WATCH.split('|'), parseInt(process.env.WORK_NUMBER, 10), parseInt(process.env.WORK_DIVISION, 10), process.env.CHECK_SYNTACTIC_ERRORS === 'true', process.env.VUE === 'true');
8
8
  function run(cancellationToken) {
9
9
  var diagnostics = [];
10
10
  var lints = [];
@@ -35,7 +35,7 @@ function run(cancellationToken) {
35
35
  }
36
36
  }
37
37
  process.on('message', function (message) {
38
- run(CancellationToken.createFromJSON(message));
38
+ run(CancellationToken_1.CancellationToken.createFromJSON(message));
39
39
  });
40
40
  process.on('SIGINT', function () {
41
41
  process.exit();
@@ -2,7 +2,7 @@ interface CancellationTokenData {
2
2
  isCancelled: boolean;
3
3
  cancellationFileName: string;
4
4
  }
5
- declare class CancellationToken {
5
+ export declare class CancellationToken {
6
6
  isCancelled: boolean;
7
7
  cancellationFileName: string;
8
8
  lastCancellationCheckTime: number;
@@ -18,4 +18,4 @@ declare class CancellationToken {
18
18
  requestCancellation(): void;
19
19
  cleanupCancellation(): void;
20
20
  }
21
- export = CancellationToken;
21
+ export {};
@@ -1,10 +1,10 @@
1
- import ts = require('typescript');
1
+ import * as ts from 'typescript';
2
2
  interface DataShape {
3
3
  source: ts.SourceFile;
4
4
  linted: boolean;
5
5
  lints: any[];
6
6
  }
7
- declare class FilesRegister {
7
+ export declare class FilesRegister {
8
8
  files: {
9
9
  [filePath: string]: {
10
10
  mtime: number;
@@ -27,4 +27,4 @@ declare class FilesRegister {
27
27
  getMtime(filePath: string): number;
28
28
  setMtime(filePath: string, mtime: number): void;
29
29
  }
30
- export = FilesRegister;
30
+ export {};
@@ -1,5 +1,5 @@
1
- import chokidar = require('chokidar');
2
- declare class FilesWatcher {
1
+ import * as chokidar from 'chokidar';
2
+ export declare class FilesWatcher {
3
3
  watchPaths: string[];
4
4
  watchExtensions: string[];
5
5
  watchers: chokidar.FSWatcher[];
@@ -14,4 +14,3 @@ declare class FilesWatcher {
14
14
  on(event: string, listener: Function): void;
15
15
  off(event: string, listener: Function): void;
16
16
  }
17
- export = FilesWatcher;
@@ -1,17 +1,17 @@
1
- import ts = require('typescript');
2
- import tslintTypes = require('tslint');
3
- import FilesRegister = require('./FilesRegister');
4
- import FilesWatcher = require('./FilesWatcher');
5
- import NormalizedMessage = require('./NormalizedMessage');
6
- import CancellationToken = require('./CancellationToken');
7
- import minimatch = require('minimatch');
8
- interface ConfigurationFile extends tslintTypes.Configuration.IConfigurationFile {
1
+ import * as ts from 'typescript';
2
+ import { Configuration, Linter } from 'tslint';
3
+ import { FilesRegister } from './FilesRegister';
4
+ import { FilesWatcher } from './FilesWatcher';
5
+ import { NormalizedMessage } from './NormalizedMessage';
6
+ import { CancellationToken } from './CancellationToken';
7
+ import * as minimatch from 'minimatch';
8
+ interface ConfigurationFile extends Configuration.IConfigurationFile {
9
9
  linterOptions?: {
10
10
  typeCheck?: boolean;
11
11
  exclude?: string[];
12
12
  };
13
13
  }
14
- declare class IncrementalChecker {
14
+ export declare class IncrementalChecker {
15
15
  programConfigFile: string;
16
16
  linterConfigFile: string | false;
17
17
  watchPaths: string[];
@@ -19,7 +19,7 @@ declare class IncrementalChecker {
19
19
  workDivision: number;
20
20
  checkSyntacticErrors: boolean;
21
21
  files: FilesRegister;
22
- linter: tslintTypes.Linter;
22
+ linter: Linter;
23
23
  linterConfig: ConfigurationFile;
24
24
  linterExclusions: minimatch.IMinimatch[];
25
25
  program: ts.Program;
@@ -30,7 +30,7 @@ declare class IncrementalChecker {
30
30
  static loadProgramConfig(configFile: string): ts.ParsedCommandLine;
31
31
  static loadLinterConfig(configFile: string): ConfigurationFile;
32
32
  static createProgram(programConfig: ts.ParsedCommandLine, files: FilesRegister, watcher: FilesWatcher, oldProgram: ts.Program): ts.Program;
33
- static createLinter(program: ts.Program): tslintTypes.Linter;
33
+ static createLinter(program: ts.Program): any;
34
34
  static isFileExcluded(filePath: string, linterExclusions: minimatch.IMinimatch[]): boolean;
35
35
  nextIteration(): void;
36
36
  loadVueProgram(): ts.Program;
@@ -39,4 +39,4 @@ declare class IncrementalChecker {
39
39
  getDiagnostics(cancellationToken: CancellationToken): NormalizedMessage[];
40
40
  getLints(cancellationToken: CancellationToken): NormalizedMessage[];
41
41
  }
42
- export = IncrementalChecker;
42
+ export {};
@@ -1,5 +1,5 @@
1
- import NormalizedMessage = require('./NormalizedMessage');
2
- export default interface Message {
1
+ import { NormalizedMessage } from './NormalizedMessage';
2
+ export interface Message {
3
3
  diagnostics: NormalizedMessage[];
4
4
  lints: NormalizedMessage[];
5
5
  }
@@ -1,5 +1,5 @@
1
- import tsTypes = require('typescript');
2
- import tslintTypes = require('tslint');
1
+ import { Diagnostic } from 'typescript';
2
+ import { RuleFailure } from 'tslint';
3
3
  declare type ErrorType = 'diagnostic' | 'lint';
4
4
  declare type Severity = 'error' | 'warning';
5
5
  interface NormalizedMessageJson {
@@ -11,7 +11,7 @@ interface NormalizedMessageJson {
11
11
  line: number;
12
12
  character: number;
13
13
  }
14
- declare class NormalizedMessage {
14
+ export declare class NormalizedMessage {
15
15
  static TYPE_DIAGNOSTIC: ErrorType;
16
16
  static TYPE_LINT: ErrorType;
17
17
  static SEVERITY_ERROR: Severity;
@@ -24,8 +24,8 @@ declare class NormalizedMessage {
24
24
  line: number;
25
25
  character: number;
26
26
  constructor(data: NormalizedMessageJson);
27
- static createFromDiagnostic(diagnostic: tsTypes.Diagnostic): NormalizedMessage;
28
- static createFromLint(lint: tslintTypes.RuleFailure): NormalizedMessage;
27
+ static createFromDiagnostic(diagnostic: Diagnostic): NormalizedMessage;
28
+ static createFromLint(lint: RuleFailure): NormalizedMessage;
29
29
  static createFromJSON(json: NormalizedMessageJson): NormalizedMessage;
30
30
  static compare(messageA: NormalizedMessage, messageB: NormalizedMessage): number;
31
31
  static equals(messageA: NormalizedMessage, messageB: NormalizedMessage): boolean;
@@ -48,4 +48,4 @@ declare class NormalizedMessage {
48
48
  getLine(): number;
49
49
  getCharacter(): number;
50
50
  }
51
- export = NormalizedMessage;
51
+ export {};
@@ -1,11 +1,11 @@
1
- import ts = require('typescript');
2
- import FilesRegister = require('./FilesRegister');
3
- import FilesWatcher = require('./FilesWatcher');
1
+ import * as ts from 'typescript';
2
+ import { FilesRegister } from './FilesRegister';
3
+ import { FilesWatcher } from './FilesWatcher';
4
4
  interface ResolvedScript {
5
5
  scriptKind: ts.ScriptKind;
6
6
  content: string;
7
7
  }
8
- declare class VueProgram {
8
+ export declare class VueProgram {
9
9
  static loadProgramConfig(configFile: string): ts.ParsedCommandLine;
10
10
  /**
11
11
  * Search for default wildcard or wildcard from options, we only search for that in tsconfig CompilerOptions.paths.
@@ -19,4 +19,4 @@ declare class VueProgram {
19
19
  private static getScriptKindByLang;
20
20
  static resolveScriptBlock(content: string): ResolvedScript;
21
21
  }
22
- export = VueProgram;
22
+ export {};
@@ -1,5 +1,5 @@
1
- import Message from './Message';
2
- declare class WorkResult {
1
+ import { Message } from './Message';
2
+ export declare class WorkResult {
3
3
  workResult: {};
4
4
  workDomain: any[];
5
5
  constructor(workDomain: any[]);
@@ -11,4 +11,3 @@ declare class WorkResult {
11
11
  clear(): void;
12
12
  reduce(reducer: (m1: Message, m2: Message) => Message, initial: Message): any;
13
13
  }
14
- export = WorkResult;
@@ -1,5 +1,5 @@
1
- import ts = require('typescript');
2
- declare class WorkSet {
1
+ import * as ts from 'typescript';
2
+ export declare class WorkSet {
3
3
  workDomain: ReadonlyArray<ts.SourceFile> | string[];
4
4
  workNumber: number;
5
5
  workDivision: number;
@@ -9,4 +9,3 @@ declare class WorkSet {
9
9
  constructor(workDomain: ReadonlyArray<ts.SourceFile> | string[], workNumber: number, workDivision: number);
10
10
  forEach(callback: (workDomainItem: any, index: number) => void): void;
11
11
  }
12
- export = WorkSet;
@@ -1,9 +1,8 @@
1
- import NormalizedMessage = require('../NormalizedMessage');
2
- declare const _default: (options: any) => (message: NormalizedMessage, useColors: boolean) => string;
1
+ import { NormalizedMessage } from '../NormalizedMessage';
3
2
  /**
4
3
  * Create new code frame formatter.
5
4
  *
6
5
  * @param options Options for babel-code-frame - see https://www.npmjs.com/package/babel-code-frame
7
6
  * @returns {codeframeFormatter}
8
7
  */
9
- export = _default;
8
+ export declare function createCodeframeFormatter(options: any): (message: NormalizedMessage, useColors: boolean) => string;
@@ -1,8 +1,7 @@
1
- import NormalizedMessage = require('../NormalizedMessage');
2
- declare const _default: () => (message: NormalizedMessage, useColors: boolean) => string;
1
+ import { NormalizedMessage } from '../NormalizedMessage';
3
2
  /**
4
3
  * Creates new default formatter.
5
4
  *
6
5
  * @returns {defaultFormatter}
7
6
  */
8
- export = _default;
7
+ export declare function createDefaultFormatter(): (message: NormalizedMessage, useColors: boolean) => string;