fork-ts-checker-webpack-plugin 0.2.9 → 0.2.10

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.2.10
2
+ * Fix #80 "Cannot read property 'getLineAndCharacterOfPosition' of undefined"
3
+ * Fix #76 "TypeError: Cannot read property '0' of undefined"
4
+
1
5
  ## v0.2.9
2
6
  * Make errors formatting closer to `ts-loader` style
3
7
  * Handle tslint exclude option
@@ -12,15 +12,23 @@ var NormalizedMessage = /** @class */ (function () {
12
12
  // message types
13
13
  NormalizedMessage.createFromDiagnostic = function (diagnostic) {
14
14
  var ts = require('typescript');
15
- var position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
15
+ var file;
16
+ var line;
17
+ var character;
18
+ if (diagnostic.file) {
19
+ file = diagnostic.file.fileName;
20
+ var position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
21
+ line = position.line + 1;
22
+ character = position.character + 1;
23
+ }
16
24
  return new NormalizedMessage({
17
25
  type: NormalizedMessage.TYPE_DIAGNOSTIC,
18
26
  code: diagnostic.code,
19
27
  severity: ts.DiagnosticCategory[diagnostic.category].toLowerCase(),
20
28
  content: ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
21
- file: diagnostic.file.fileName,
22
- line: position.line + 1,
23
- character: position.character + 1
29
+ file: file,
30
+ line: line,
31
+ character: character
24
32
  });
25
33
  };
26
34
  NormalizedMessage.createFromLint = function (lint) {
package/lib/index.js CHANGED
@@ -286,11 +286,10 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
286
286
  }
287
287
  };
288
288
  ForkTsCheckerWebpackPlugin.prototype.createEmitCallback = function (compilation, callback) {
289
- var _this = this;
290
- var emitCallback = function () {
291
- var elapsed = Math.round(_this.elapsed[0] * 1E9 + _this.elapsed[1]);
292
- _this.compiler.applyPlugins('fork-ts-checker-emit', _this.diagnostics, _this.lints, elapsed);
293
- _this.diagnostics.concat(_this.lints).forEach(function (message) {
289
+ return function emitCallback() {
290
+ var elapsed = Math.round(this.elapsed[0] * 1E9 + this.elapsed[1]);
291
+ this.compiler.applyPlugins('fork-ts-checker-emit', this.diagnostics, this.lints, elapsed);
292
+ this.diagnostics.concat(this.lints).forEach(function (message) {
294
293
  // webpack message format
295
294
  var formatted = {
296
295
  rawMessage: (message.getSeverity().toUpperCase() + ' ' + message.getFormattedCode() + ': ' +
@@ -311,38 +310,36 @@ var ForkTsCheckerWebpackPlugin = /** @class */ (function () {
311
310
  });
312
311
  callback();
313
312
  };
314
- return emitCallback;
315
313
  };
316
314
  ForkTsCheckerWebpackPlugin.prototype.createNoopEmitCallback = function () {
317
315
  // tslint:disable-next-line:no-empty
318
316
  return function noopEmitCallback() { };
319
317
  };
320
318
  ForkTsCheckerWebpackPlugin.prototype.createDoneCallback = function () {
321
- var _this = this;
322
- var doneCallback = function () {
323
- var elapsed = Math.round(_this.elapsed[0] * 1E9 + _this.elapsed[1]);
324
- if (_this.compiler) {
325
- _this.compiler.applyPlugins('fork-ts-checker-done', _this.diagnostics, _this.lints, elapsed);
319
+ return function doneCallback() {
320
+ var _this = this;
321
+ var elapsed = Math.round(this.elapsed[0] * 1E9 + this.elapsed[1]);
322
+ if (this.compiler) {
323
+ this.compiler.applyPlugins('fork-ts-checker-done', this.diagnostics, this.lints, elapsed);
326
324
  }
327
- if (!_this.silent && _this.logger) {
328
- if (_this.diagnostics.length || _this.lints.length) {
329
- (_this.lints || []).concat(_this.diagnostics).forEach(function (message) {
325
+ if (!this.silent && this.logger) {
326
+ if (this.diagnostics.length || this.lints.length) {
327
+ (this.lints || []).concat(this.diagnostics).forEach(function (message) {
330
328
  var formattedMessage = _this.formatter(message, _this.useColors);
331
329
  message.isWarningSeverity() ? _this.logger.warn(formattedMessage) : _this.logger.error(formattedMessage);
332
330
  });
333
331
  }
334
- if (!_this.diagnostics.length) {
335
- _this.logger.info(_this.colors.green('No type errors found'));
332
+ if (!this.diagnostics.length) {
333
+ this.logger.info(this.colors.green('No type errors found'));
336
334
  }
337
- if (_this.tslint && !_this.lints.length) {
338
- _this.logger.info(_this.colors.green('No lint errors found'));
335
+ if (this.tslint && !this.lints.length) {
336
+ this.logger.info(this.colors.green('No lint errors found'));
339
337
  }
340
- _this.logger.info('Version: typescript ' + _this.colors.bold(_this.typescriptVersion) +
341
- (_this.tslint ? ', tslint ' + _this.colors.bold(_this.tslintVersion) : ''));
342
- _this.logger.info('Time: ' + _this.colors.bold(Math.round(elapsed / 1E6).toString()) + 'ms');
338
+ this.logger.info('Version: typescript ' + this.colors.bold(this.typescriptVersion) +
339
+ (this.tslint ? ', tslint ' + this.colors.bold(this.tslintVersion) : ''));
340
+ this.logger.info('Time: ' + this.colors.bold(Math.round(elapsed / 1E6).toString()) + 'ms');
343
341
  }
344
342
  };
345
- return doneCallback;
346
343
  };
347
344
  ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT = 2048;
348
345
  ForkTsCheckerWebpackPlugin.ONE_CPU = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "main": "lib/index.js",
6
6
  "files": [