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/CHANGELOG.md +16 -0
- package/lib/CancellationToken.js +4 -2
- package/lib/FilesRegister.js +2 -1
- package/lib/FilesWatcher.js +4 -2
- package/lib/IncrementalChecker.js +41 -24
- package/lib/NormalizedMessage.js +7 -8
- package/lib/VueProgram.js +28 -16
- package/lib/WorkResult.js +2 -1
- package/lib/WorkSet.js +2 -1
- package/lib/cluster.js +7 -7
- package/lib/formatter/codeframeFormatter.js +21 -6
- package/lib/formatter/defaultFormatter.js +12 -3
- package/lib/index.js +127 -69
- package/lib/service.js +4 -4
- package/lib/types/CancellationToken.d.ts +2 -2
- package/lib/types/FilesRegister.d.ts +3 -3
- package/lib/types/FilesWatcher.d.ts +2 -3
- package/lib/types/IncrementalChecker.d.ts +12 -12
- package/lib/types/Message.d.ts +2 -2
- package/lib/types/NormalizedMessage.d.ts +6 -6
- package/lib/types/VueProgram.d.ts +5 -5
- package/lib/types/WorkResult.d.ts +2 -3
- package/lib/types/WorkSet.d.ts +2 -3
- package/lib/types/formatter/codeframeFormatter.d.ts +2 -3
- package/lib/types/formatter/defaultFormatter.d.ts +2 -3
- package/lib/types/index.d.ts +8 -6
- package/package.json +33 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## v0.4.11
|
|
2
|
+
|
|
3
|
+
* [Fix os.cpus is not a function](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/172) (#172)
|
|
4
|
+
|
|
5
|
+
## v0.4.10
|
|
6
|
+
|
|
7
|
+
* [Allow fork-ts-checker-webpack-plugin to be imported in .ts files using ESM import syntax](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/163) (#163)
|
|
8
|
+
|
|
9
|
+
## v0.4.9
|
|
10
|
+
|
|
11
|
+
* [Set "compilationDone" before resolving "forkTsCheckerServiceBeforeStart"](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/146) (#146)
|
|
12
|
+
|
|
13
|
+
## v0.4.8
|
|
14
|
+
|
|
15
|
+
* [Fix(types collision): update webpack](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/151) (#142)
|
|
16
|
+
|
|
1
17
|
## v0.4.7
|
|
2
18
|
|
|
3
19
|
* [Fix(types collision): update chalk and chokidar](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/147) (#142)
|
package/lib/CancellationToken.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var crypto = require("crypto");
|
|
3
4
|
var fs = require("fs");
|
|
4
5
|
var os = require("os");
|
|
@@ -7,7 +8,8 @@ var ts = require("typescript");
|
|
|
7
8
|
var CancellationToken = /** @class */ (function () {
|
|
8
9
|
function CancellationToken(cancellationFileName, isCancelled) {
|
|
9
10
|
this.isCancelled = !!isCancelled;
|
|
10
|
-
this.cancellationFileName =
|
|
11
|
+
this.cancellationFileName =
|
|
12
|
+
cancellationFileName || crypto.randomBytes(64).toString('hex');
|
|
11
13
|
this.lastCancellationCheckTime = 0;
|
|
12
14
|
}
|
|
13
15
|
CancellationToken.createFromJSON = function (json) {
|
|
@@ -52,4 +54,4 @@ var CancellationToken = /** @class */ (function () {
|
|
|
52
54
|
};
|
|
53
55
|
return CancellationToken;
|
|
54
56
|
}());
|
|
55
|
-
|
|
57
|
+
exports.CancellationToken = CancellationToken;
|
package/lib/FilesRegister.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var FilesRegister = /** @class */ (function () {
|
|
3
4
|
function FilesRegister(dataFactory) {
|
|
4
5
|
this.files = {};
|
|
@@ -52,4 +53,4 @@ var FilesRegister = /** @class */ (function () {
|
|
|
52
53
|
};
|
|
53
54
|
return FilesRegister;
|
|
54
55
|
}());
|
|
55
|
-
|
|
56
|
+
exports.FilesRegister = FilesRegister;
|
package/lib/FilesWatcher.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var chokidar = require("chokidar");
|
|
3
4
|
var path = require("path");
|
|
4
5
|
var startsWith = require("lodash.startswith");
|
|
@@ -18,7 +19,8 @@ var FilesWatcher = /** @class */ (function () {
|
|
|
18
19
|
throw new Error('Cannot watch again - already watching.');
|
|
19
20
|
}
|
|
20
21
|
this.watchers = this.watchPaths.map(function (watchPath) {
|
|
21
|
-
return chokidar
|
|
22
|
+
return chokidar
|
|
23
|
+
.watch(watchPath, { persistent: true, alwaysStat: true })
|
|
22
24
|
.on('change', function (filePath, stats) {
|
|
23
25
|
if (_this.isFileSupported(filePath)) {
|
|
24
26
|
(_this.listeners['change'] || []).forEach(function (changeListener) {
|
|
@@ -56,4 +58,4 @@ var FilesWatcher = /** @class */ (function () {
|
|
|
56
58
|
};
|
|
57
59
|
return FilesWatcher;
|
|
58
60
|
}());
|
|
59
|
-
|
|
61
|
+
exports.FilesWatcher = FilesWatcher;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var fs = require("fs");
|
|
3
4
|
var endsWith = require("lodash.endswith");
|
|
4
5
|
var path = require("path");
|
|
5
6
|
var ts = require("typescript");
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
var FilesRegister_1 = require("./FilesRegister");
|
|
8
|
+
var FilesWatcher_1 = require("./FilesWatcher");
|
|
9
|
+
var WorkSet_1 = require("./WorkSet");
|
|
10
|
+
var NormalizedMessage_1 = require("./NormalizedMessage");
|
|
10
11
|
var minimatch = require("minimatch");
|
|
11
|
-
var
|
|
12
|
+
var VueProgram_1 = require("./VueProgram");
|
|
12
13
|
var IncrementalChecker = /** @class */ (function () {
|
|
13
14
|
function IncrementalChecker(programConfigFile, linterConfigFile, watchPaths, workNumber, workDivision, checkSyntacticErrors, vue) {
|
|
14
15
|
this.programConfigFile = programConfigFile;
|
|
@@ -22,7 +23,7 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
22
23
|
// to check of its existence later on.
|
|
23
24
|
this.linterExclusions = [];
|
|
24
25
|
// it's shared between compilations
|
|
25
|
-
this.files = new FilesRegister(function () { return ({
|
|
26
|
+
this.files = new FilesRegister_1.FilesRegister(function () { return ({
|
|
26
27
|
// data shape
|
|
27
28
|
source: undefined,
|
|
28
29
|
linted: false,
|
|
@@ -32,7 +33,9 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
32
33
|
IncrementalChecker.loadProgramConfig = function (configFile) {
|
|
33
34
|
return ts.parseJsonConfigFileContent(
|
|
34
35
|
// Regardless of the setting in the tsconfig.json we want isolatedModules to be false
|
|
35
|
-
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, {
|
|
36
|
+
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, {
|
|
37
|
+
isolatedModules: false
|
|
38
|
+
}), ts.sys, path.dirname(configFile));
|
|
36
39
|
};
|
|
37
40
|
IncrementalChecker.loadLinterConfig = function (configFile) {
|
|
38
41
|
var tslint = require('tslint');
|
|
@@ -69,13 +72,16 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
69
72
|
return new tslint.Linter({ fix: false }, program);
|
|
70
73
|
};
|
|
71
74
|
IncrementalChecker.isFileExcluded = function (filePath, linterExclusions) {
|
|
72
|
-
return endsWith(filePath, '.d.ts') ||
|
|
75
|
+
return (endsWith(filePath, '.d.ts') ||
|
|
76
|
+
linterExclusions.some(function (matcher) { return matcher.match(filePath); }));
|
|
73
77
|
};
|
|
74
78
|
IncrementalChecker.prototype.nextIteration = function () {
|
|
75
79
|
var _this = this;
|
|
76
80
|
if (!this.watcher) {
|
|
77
|
-
var watchExtensions = this.vue
|
|
78
|
-
|
|
81
|
+
var watchExtensions = this.vue
|
|
82
|
+
? ['.ts', '.tsx', '.vue']
|
|
83
|
+
: ['.ts', '.tsx'];
|
|
84
|
+
this.watcher = new FilesWatcher_1.FilesWatcher(this.watchPaths, watchExtensions);
|
|
79
85
|
// connect watcher with register
|
|
80
86
|
this.watcher.on('change', function (filePath, stats) {
|
|
81
87
|
_this.files.setMtime(filePath, stats.mtime.valueOf());
|
|
@@ -87,7 +93,8 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
87
93
|
}
|
|
88
94
|
if (!this.linterConfig && this.linterConfigFile) {
|
|
89
95
|
this.linterConfig = IncrementalChecker.loadLinterConfig(this.linterConfigFile);
|
|
90
|
-
if (this.linterConfig.linterOptions &&
|
|
96
|
+
if (this.linterConfig.linterOptions &&
|
|
97
|
+
this.linterConfig.linterOptions.exclude) {
|
|
91
98
|
// Pre-build minimatch patterns to avoid additional overhead later on.
|
|
92
99
|
// Note: Resolving the path is required to properly match against the full file paths,
|
|
93
100
|
// and also deals with potential cross-platform problems regarding path separators.
|
|
@@ -100,11 +107,15 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
100
107
|
}
|
|
101
108
|
};
|
|
102
109
|
IncrementalChecker.prototype.loadVueProgram = function () {
|
|
103
|
-
this.programConfig =
|
|
104
|
-
|
|
110
|
+
this.programConfig =
|
|
111
|
+
this.programConfig ||
|
|
112
|
+
VueProgram_1.VueProgram.loadProgramConfig(this.programConfigFile);
|
|
113
|
+
return VueProgram_1.VueProgram.createProgram(this.programConfig, path.dirname(this.programConfigFile), this.files, this.watcher, this.program);
|
|
105
114
|
};
|
|
106
115
|
IncrementalChecker.prototype.loadDefaultProgram = function () {
|
|
107
|
-
this.programConfig =
|
|
116
|
+
this.programConfig =
|
|
117
|
+
this.programConfig ||
|
|
118
|
+
IncrementalChecker.loadProgramConfig(this.programConfigFile);
|
|
108
119
|
return IncrementalChecker.createProgram(this.programConfig, this.files, this.watcher, this.program);
|
|
109
120
|
};
|
|
110
121
|
IncrementalChecker.prototype.hasLinter = function () {
|
|
@@ -116,13 +127,14 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
116
127
|
// select files to check (it's semantic check - we have to include all files :/)
|
|
117
128
|
var filesToCheck = this.program.getSourceFiles();
|
|
118
129
|
// calculate subset of work to do
|
|
119
|
-
var workSet = new WorkSet(filesToCheck, this.workNumber, this.workDivision);
|
|
130
|
+
var workSet = new WorkSet_1.WorkSet(filesToCheck, this.workNumber, this.workDivision);
|
|
120
131
|
// check given work set
|
|
121
132
|
workSet.forEach(function (sourceFile) {
|
|
122
133
|
if (cancellationToken) {
|
|
123
134
|
cancellationToken.throwIfCancellationRequested();
|
|
124
135
|
}
|
|
125
|
-
var diagnosticsToRegister = _this
|
|
136
|
+
var diagnosticsToRegister = _this
|
|
137
|
+
.checkSyntacticErrors
|
|
126
138
|
? []
|
|
127
139
|
.concat(_this.program.getSemanticDiagnostics(sourceFile, cancellationToken))
|
|
128
140
|
.concat(_this.program.getSyntacticDiagnostics(sourceFile, cancellationToken))
|
|
@@ -130,7 +142,7 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
130
142
|
diagnostics.push.apply(diagnostics, diagnosticsToRegister);
|
|
131
143
|
});
|
|
132
144
|
// normalize and deduplicate diagnostics
|
|
133
|
-
return NormalizedMessage.deduplicate(diagnostics.map(NormalizedMessage.createFromDiagnostic));
|
|
145
|
+
return NormalizedMessage_1.NormalizedMessage.deduplicate(diagnostics.map(NormalizedMessage_1.NormalizedMessage.createFromDiagnostic));
|
|
134
146
|
};
|
|
135
147
|
IncrementalChecker.prototype.getLints = function (cancellationToken) {
|
|
136
148
|
var _this = this;
|
|
@@ -138,11 +150,14 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
138
150
|
throw new Error('Cannot get lints - checker has no linter.');
|
|
139
151
|
}
|
|
140
152
|
// select files to lint
|
|
141
|
-
var filesToLint = this.files
|
|
142
|
-
|
|
153
|
+
var filesToLint = this.files
|
|
154
|
+
.keys()
|
|
155
|
+
.filter(function (filePath) {
|
|
156
|
+
return !_this.files.getData(filePath).linted &&
|
|
157
|
+
!IncrementalChecker.isFileExcluded(filePath, _this.linterExclusions);
|
|
143
158
|
});
|
|
144
159
|
// calculate subset of work to do
|
|
145
|
-
var workSet = new WorkSet(filesToLint, this.workNumber, this.workDivision);
|
|
160
|
+
var workSet = new WorkSet_1.WorkSet(filesToLint, this.workNumber, this.workDivision);
|
|
146
161
|
// lint given work set
|
|
147
162
|
workSet.forEach(function (fileName) {
|
|
148
163
|
cancellationToken.throwIfCancellationRequested();
|
|
@@ -154,7 +169,7 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
154
169
|
// check the error type due to file system lag
|
|
155
170
|
!(e instanceof Error) &&
|
|
156
171
|
!(e.constructor.name === 'FatalError') &&
|
|
157
|
-
!(e.message && e.message.trim().startsWith(
|
|
172
|
+
!(e.message && e.message.trim().startsWith('Invalid source file'))) {
|
|
158
173
|
// it's not because file doesn't exist - throw error
|
|
159
174
|
throw e;
|
|
160
175
|
}
|
|
@@ -175,12 +190,14 @@ var IncrementalChecker = /** @class */ (function () {
|
|
|
175
190
|
});
|
|
176
191
|
});
|
|
177
192
|
// get all lints
|
|
178
|
-
var lints = this.files
|
|
193
|
+
var lints = this.files
|
|
194
|
+
.keys()
|
|
195
|
+
.reduce(function (innerLints, filePath) {
|
|
179
196
|
return innerLints.concat(_this.files.getData(filePath).lints);
|
|
180
197
|
}, []);
|
|
181
198
|
// normalize and deduplicate lints
|
|
182
|
-
return NormalizedMessage.deduplicate(lints.map(NormalizedMessage.createFromLint));
|
|
199
|
+
return NormalizedMessage_1.NormalizedMessage.deduplicate(lints.map(NormalizedMessage_1.NormalizedMessage.createFromLint));
|
|
183
200
|
};
|
|
184
201
|
return IncrementalChecker;
|
|
185
202
|
}());
|
|
186
|
-
|
|
203
|
+
exports.IncrementalChecker = IncrementalChecker;
|
package/lib/NormalizedMessage.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var typescript_1 = require("typescript");
|
|
2
4
|
var NormalizedMessage = /** @class */ (function () {
|
|
3
5
|
function NormalizedMessage(data) {
|
|
4
6
|
this.type = data.type;
|
|
@@ -11,7 +13,6 @@ var NormalizedMessage = /** @class */ (function () {
|
|
|
11
13
|
}
|
|
12
14
|
// message types
|
|
13
15
|
NormalizedMessage.createFromDiagnostic = function (diagnostic) {
|
|
14
|
-
var ts = require('typescript');
|
|
15
16
|
var file;
|
|
16
17
|
var line;
|
|
17
18
|
var character;
|
|
@@ -24,8 +25,8 @@ var NormalizedMessage = /** @class */ (function () {
|
|
|
24
25
|
return new NormalizedMessage({
|
|
25
26
|
type: NormalizedMessage.TYPE_DIAGNOSTIC,
|
|
26
27
|
code: diagnostic.code,
|
|
27
|
-
severity:
|
|
28
|
-
content:
|
|
28
|
+
severity: typescript_1.DiagnosticCategory[diagnostic.category].toLowerCase(),
|
|
29
|
+
content: typescript_1.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
|
|
29
30
|
file: file,
|
|
30
31
|
line: line,
|
|
31
32
|
character: character
|
|
@@ -67,10 +68,8 @@ var NormalizedMessage = /** @class */ (function () {
|
|
|
67
68
|
return this.compare(messageA, messageB) === 0;
|
|
68
69
|
};
|
|
69
70
|
NormalizedMessage.deduplicate = function (messages) {
|
|
70
|
-
return messages
|
|
71
|
-
|
|
72
|
-
.filter(function (message, index) {
|
|
73
|
-
return index === 0 || !NormalizedMessage.equals(message, messages[index - 1]);
|
|
71
|
+
return messages.sort(NormalizedMessage.compare).filter(function (message, index) {
|
|
72
|
+
return (index === 0 || !NormalizedMessage.equals(message, messages[index - 1]));
|
|
74
73
|
});
|
|
75
74
|
};
|
|
76
75
|
NormalizedMessage.compareTypes = function (typeA, typeB) {
|
|
@@ -160,4 +159,4 @@ var NormalizedMessage = /** @class */ (function () {
|
|
|
160
159
|
NormalizedMessage.SEVERITY_WARNING = 'warning';
|
|
161
160
|
return NormalizedMessage;
|
|
162
161
|
}());
|
|
163
|
-
|
|
162
|
+
exports.NormalizedMessage = NormalizedMessage;
|
package/lib/VueProgram.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var fs = require("fs");
|
|
3
4
|
var path = require("path");
|
|
4
5
|
var ts = require("typescript");
|
|
@@ -17,7 +18,9 @@ var VueProgram = /** @class */ (function () {
|
|
|
17
18
|
};
|
|
18
19
|
var parsed = ts.parseJsonConfigFileContent(
|
|
19
20
|
// Regardless of the setting in the tsconfig.json we want isolatedModules to be false
|
|
20
|
-
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, {
|
|
21
|
+
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, {
|
|
22
|
+
isolatedModules: false
|
|
23
|
+
}), parseConfigHost, path.dirname(configFile));
|
|
21
24
|
parsed.options.allowNonTsExtensions = true;
|
|
22
25
|
return parsed;
|
|
23
26
|
};
|
|
@@ -34,7 +37,8 @@ var VueProgram = /** @class */ (function () {
|
|
|
34
37
|
if (options.paths) {
|
|
35
38
|
Object.keys(options.paths).forEach(function (key) {
|
|
36
39
|
var pathSymbol = key[0];
|
|
37
|
-
if (discardedSymbols.indexOf(pathSymbol) < 0 &&
|
|
40
|
+
if (discardedSymbols.indexOf(pathSymbol) < 0 &&
|
|
41
|
+
wildcards.indexOf(pathSymbol) < 0) {
|
|
38
42
|
wildcards.push(pathSymbol);
|
|
39
43
|
}
|
|
40
44
|
});
|
|
@@ -50,8 +54,12 @@ var VueProgram = /** @class */ (function () {
|
|
|
50
54
|
}
|
|
51
55
|
});
|
|
52
56
|
if (correctWildcard) {
|
|
53
|
-
var pattern = options.paths
|
|
54
|
-
|
|
57
|
+
var pattern = options.paths
|
|
58
|
+
? options.paths[correctWildcard + "/*"]
|
|
59
|
+
: undefined;
|
|
60
|
+
var substitution = pattern
|
|
61
|
+
? options.paths[correctWildcard + "/*"][0].replace('*', '')
|
|
62
|
+
: 'src';
|
|
55
63
|
moduleName = path.resolve(baseUrl, substitution, moduleName.substr(2));
|
|
56
64
|
}
|
|
57
65
|
else if (isRelative) {
|
|
@@ -101,7 +109,8 @@ var VueProgram = /** @class */ (function () {
|
|
|
101
109
|
var resolvedModule = ts.resolveModuleName(moduleName, containingFile, programConfig.options, {
|
|
102
110
|
fileExists: function (fileName) {
|
|
103
111
|
if (fileName.endsWith('.vue.ts')) {
|
|
104
|
-
return host.fileExists(fileName.slice(0, -3)) ||
|
|
112
|
+
return (host.fileExists(fileName.slice(0, -3)) ||
|
|
113
|
+
host.fileExists(fileName));
|
|
105
114
|
}
|
|
106
115
|
else {
|
|
107
116
|
return host.fileExists(fileName);
|
|
@@ -118,7 +127,8 @@ var VueProgram = /** @class */ (function () {
|
|
|
118
127
|
}
|
|
119
128
|
}).resolvedModule;
|
|
120
129
|
if (resolvedModule) {
|
|
121
|
-
if (resolvedModule.resolvedFileName.endsWith('.vue.ts') &&
|
|
130
|
+
if (resolvedModule.resolvedFileName.endsWith('.vue.ts') &&
|
|
131
|
+
!host.fileExists(resolvedModule.resolvedFileName)) {
|
|
122
132
|
resolvedModule.resolvedFileName = resolvedModule.resolvedFileName.slice(0, -3);
|
|
123
133
|
}
|
|
124
134
|
resolvedModules.push(resolvedModule);
|
|
@@ -135,7 +145,9 @@ var VueProgram = /** @class */ (function () {
|
|
|
135
145
|
else {
|
|
136
146
|
resolvedModules.push({
|
|
137
147
|
// If the file does exist, return an empty string (because we assume user has provided a ".d.ts" file for it).
|
|
138
|
-
resolvedFileName: host.fileExists(absolutePath)
|
|
148
|
+
resolvedFileName: host.fileExists(absolutePath)
|
|
149
|
+
? ''
|
|
150
|
+
: absolutePath,
|
|
139
151
|
extension: '.ts'
|
|
140
152
|
});
|
|
141
153
|
}
|
|
@@ -147,13 +159,13 @@ var VueProgram = /** @class */ (function () {
|
|
|
147
159
|
);
|
|
148
160
|
};
|
|
149
161
|
VueProgram.getScriptKindByLang = function (lang) {
|
|
150
|
-
if (lang ===
|
|
162
|
+
if (lang === 'ts') {
|
|
151
163
|
return ts.ScriptKind.TS;
|
|
152
164
|
}
|
|
153
|
-
else if (lang ===
|
|
165
|
+
else if (lang === 'tsx') {
|
|
154
166
|
return ts.ScriptKind.TSX;
|
|
155
167
|
}
|
|
156
|
-
else if (lang ===
|
|
168
|
+
else if (lang === 'jsx') {
|
|
157
169
|
return ts.ScriptKind.JSX;
|
|
158
170
|
}
|
|
159
171
|
else {
|
|
@@ -194,11 +206,11 @@ var VueProgram = /** @class */ (function () {
|
|
|
194
206
|
// For now, ignore the error when the src file is not found
|
|
195
207
|
// since it will produce incorrect code location.
|
|
196
208
|
// It's not a large problem since it's handled on webpack side.
|
|
197
|
-
content: '/* tslint:disable */\n'
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
209
|
+
content: '/* tslint:disable */\n' +
|
|
210
|
+
'// @ts-ignore\n' +
|
|
211
|
+
("export { default } from '" + src + "';\n") +
|
|
212
|
+
'// @ts-ignore\n' +
|
|
213
|
+
("export * from '" + src + "';\n")
|
|
202
214
|
};
|
|
203
215
|
}
|
|
204
216
|
// Pad blank lines to retain diagnostics location
|
|
@@ -213,4 +225,4 @@ var VueProgram = /** @class */ (function () {
|
|
|
213
225
|
};
|
|
214
226
|
return VueProgram;
|
|
215
227
|
}());
|
|
216
|
-
|
|
228
|
+
exports.VueProgram = VueProgram;
|
package/lib/WorkResult.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var WorkResult = /** @class */ (function () {
|
|
3
4
|
function WorkResult(workDomain) {
|
|
4
5
|
this.workResult = {};
|
|
@@ -37,4 +38,4 @@ var WorkResult = /** @class */ (function () {
|
|
|
37
38
|
};
|
|
38
39
|
return WorkResult;
|
|
39
40
|
}());
|
|
40
|
-
|
|
41
|
+
exports.WorkResult = WorkResult;
|
package/lib/WorkSet.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var WorkSet = /** @class */ (function () {
|
|
3
4
|
function WorkSet(workDomain, workNumber, workDivision) {
|
|
4
5
|
this.workDomain = workDomain;
|
|
@@ -19,4 +20,4 @@ var WorkSet = /** @class */ (function () {
|
|
|
19
20
|
};
|
|
20
21
|
return WorkSet;
|
|
21
22
|
}());
|
|
22
|
-
|
|
23
|
+
exports.WorkSet = WorkSet;
|
package/lib/cluster.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var childProcess = require("child_process");
|
|
4
4
|
var path = require("path");
|
|
5
5
|
var process = require("process");
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var WorkResult_1 = require("./WorkResult");
|
|
7
|
+
var NormalizedMessage_1 = require("./NormalizedMessage");
|
|
8
8
|
// fork workers...
|
|
9
9
|
var division = parseInt(process.env.WORK_DIVISION, 10);
|
|
10
10
|
var workers = [];
|
|
@@ -16,7 +16,7 @@ for (var num = 0; num < division; num++) {
|
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
18
18
|
var pids = workers.map(function (worker) { return worker.pid; });
|
|
19
|
-
var result = new WorkResult(pids);
|
|
19
|
+
var result = new WorkResult_1.WorkResult(pids);
|
|
20
20
|
process.on('message', function (message) {
|
|
21
21
|
// broadcast message to all workers
|
|
22
22
|
workers.forEach(function (worker) {
|
|
@@ -36,8 +36,8 @@ workers.forEach(function (worker) {
|
|
|
36
36
|
worker.on('message', function (message) {
|
|
37
37
|
// set result from worker
|
|
38
38
|
result.set(worker.pid, {
|
|
39
|
-
diagnostics: message.diagnostics.map(NormalizedMessage.createFromJSON),
|
|
40
|
-
lints: message.lints.map(NormalizedMessage.createFromJSON)
|
|
39
|
+
diagnostics: message.diagnostics.map(NormalizedMessage_1.NormalizedMessage.createFromJSON),
|
|
40
|
+
lints: message.lints.map(NormalizedMessage_1.NormalizedMessage.createFromJSON)
|
|
41
41
|
});
|
|
42
42
|
// if we have result from all workers, send merged
|
|
43
43
|
if (result.hasAll()) {
|
|
@@ -45,8 +45,8 @@ workers.forEach(function (worker) {
|
|
|
45
45
|
diagnostics: innerMerged.diagnostics.concat(innerResult.diagnostics),
|
|
46
46
|
lints: innerMerged.lints.concat(innerResult.lints)
|
|
47
47
|
}); }, { diagnostics: [], lints: [] });
|
|
48
|
-
merged.diagnostics = NormalizedMessage.deduplicate(merged.diagnostics);
|
|
49
|
-
merged.lints = NormalizedMessage.deduplicate(merged.lints);
|
|
48
|
+
merged.diagnostics = NormalizedMessage_1.NormalizedMessage.deduplicate(merged.diagnostics);
|
|
49
|
+
merged.lints = NormalizedMessage_1.NormalizedMessage.deduplicate(merged.lints);
|
|
50
50
|
try {
|
|
51
51
|
process.send(merged);
|
|
52
52
|
}
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var os = require("os");
|
|
3
4
|
var codeFrame = require("babel-code-frame");
|
|
4
5
|
var chalk_1 = require("chalk");
|
|
5
6
|
var fs = require("fs");
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Create new code frame formatter.
|
|
9
|
+
*
|
|
10
|
+
* @param options Options for babel-code-frame - see https://www.npmjs.com/package/babel-code-frame
|
|
11
|
+
* @returns {codeframeFormatter}
|
|
12
|
+
*/
|
|
13
|
+
function createCodeframeFormatter(options) {
|
|
7
14
|
return function codeframeFormatter(message, useColors) {
|
|
8
15
|
var colors = new chalk_1.default.constructor({ enabled: useColors });
|
|
9
|
-
var messageColor = message.isWarningSeverity()
|
|
16
|
+
var messageColor = message.isWarningSeverity()
|
|
17
|
+
? colors.bold.yellow
|
|
18
|
+
: colors.bold.red;
|
|
10
19
|
var positionColor = colors.dim;
|
|
11
|
-
var source = message.getFile() &&
|
|
20
|
+
var source = message.getFile() &&
|
|
21
|
+
fs.existsSync(message.getFile()) &&
|
|
22
|
+
fs.readFileSync(message.getFile(), 'utf-8');
|
|
12
23
|
var frame = '';
|
|
13
24
|
if (source) {
|
|
14
25
|
frame = codeFrame(source, message.line, message.character, Object.assign({}, options || {}, { highlightCode: useColors }))
|
|
@@ -16,8 +27,12 @@ module.exports = function createCodeframeFormatter(options) {
|
|
|
16
27
|
.map(function (str) { return ' ' + str; })
|
|
17
28
|
.join(os.EOL);
|
|
18
29
|
}
|
|
19
|
-
return (messageColor(message.getSeverity().toUpperCase() + ' in ' + message.getFile()) +
|
|
20
|
-
|
|
30
|
+
return (messageColor(message.getSeverity().toUpperCase() + ' in ' + message.getFile()) +
|
|
31
|
+
os.EOL +
|
|
32
|
+
positionColor(message.getLine() + ':' + message.getCharacter()) +
|
|
33
|
+
' ' +
|
|
34
|
+
message.getContent() +
|
|
21
35
|
(frame ? os.EOL + frame : ''));
|
|
22
36
|
};
|
|
23
|
-
}
|
|
37
|
+
}
|
|
38
|
+
exports.createCodeframeFormatter = createCodeframeFormatter;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
var chalk_1 = require("chalk");
|
|
3
4
|
var os = require("os");
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Creates new default formatter.
|
|
7
|
+
*
|
|
8
|
+
* @returns {defaultFormatter}
|
|
9
|
+
*/
|
|
10
|
+
function createDefaultFormatter() {
|
|
5
11
|
return function defaultFormatter(message, useColors) {
|
|
6
12
|
var colors = new chalk_1.default.constructor({ enabled: useColors });
|
|
7
|
-
var messageColor = message.isWarningSeverity()
|
|
13
|
+
var messageColor = message.isWarningSeverity()
|
|
14
|
+
? colors.bold.yellow
|
|
15
|
+
: colors.bold.red;
|
|
8
16
|
var fileAndNumberColor = colors.bold.cyan;
|
|
9
17
|
var codeColor = colors.grey;
|
|
10
18
|
return [
|
|
@@ -14,4 +22,5 @@ module.exports = function createDefaultFormatter() {
|
|
|
14
22
|
codeColor(message.getFormattedCode() + ': ') + message.getContent()
|
|
15
23
|
].join(os.EOL);
|
|
16
24
|
};
|
|
17
|
-
}
|
|
25
|
+
}
|
|
26
|
+
exports.createDefaultFormatter = createDefaultFormatter;
|