ts-checker-rspack-plugin 1.0.1 → 1.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.
- package/lib/formatter/code-frame-formatter.js +4 -1
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +3 -12
- package/lib/hooks/tap-after-compile-to-get-issues.js +4 -13
- package/lib/hooks/tap-done-to-async-get-issues.js +6 -15
- package/lib/hooks/tap-start-to-run-workers.js +11 -20
- package/lib/rpc/expose-rpc.js +5 -14
- package/lib/rpc/rpc-worker.js +6 -3
- package/lib/rpc/wrap-rpc.js +3 -12
- package/lib/typescript/type-script-worker-config.js +19 -1
- package/lib/typescript/worker/get-issues-worker.js +7 -17
- package/lib/typescript/worker/lib/config.js +33 -6
- package/lib/typescript/worker/lib/dependencies.js +1 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +5 -2
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +5 -2
- package/lib/typescript/worker/lib/host/compiler-host.js +8 -1
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +14 -2
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +10 -4
- package/lib/typescript/worker/lib/performance.js +3 -6
- package/lib/typescript/worker/lib/system.js +17 -23
- package/lib/typescript/worker/lib/tracing.js +2 -4
- package/lib/utils/async/abort-error.js +1 -1
- package/lib/utils/async/pool.js +12 -23
- package/lib/watch/inclusive-node-watch-file-system.js +20 -21
- package/package.json +6 -1
|
@@ -14,7 +14,10 @@ function createCodeFrameFormatter(options) {
|
|
|
14
14
|
const source = issue.file && node_fs_1.default.existsSync(issue.file) && node_fs_1.default.readFileSync(issue.file, 'utf-8');
|
|
15
15
|
let frame = '';
|
|
16
16
|
if (source && issue.location) {
|
|
17
|
-
frame = (0, code_frame_1.codeFrameColumns)(source, issue.location,
|
|
17
|
+
frame = (0, code_frame_1.codeFrameColumns)(source, issue.location, {
|
|
18
|
+
highlightCode: true,
|
|
19
|
+
...(options || {}),
|
|
20
|
+
})
|
|
18
21
|
.split('\n')
|
|
19
22
|
.map((line) => ' ' + line)
|
|
20
23
|
.join(os_1.default.EOL);
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.tapAfterCompileToAddDependencies = void 0;
|
|
13
4
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
14
5
|
function tapAfterCompileToAddDependencies(compiler, config, state) {
|
|
15
6
|
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
16
|
-
compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', (compilation) =>
|
|
7
|
+
compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation) => {
|
|
17
8
|
if (compilation.compiler !== compiler) {
|
|
18
9
|
// run only for the compiler that the plugin was registered for
|
|
19
10
|
return;
|
|
20
11
|
}
|
|
21
|
-
const dependencies =
|
|
12
|
+
const dependencies = await state.dependenciesPromise;
|
|
22
13
|
debug(`Got dependencies from the getDependenciesWorker.`, dependencies);
|
|
23
14
|
if (dependencies) {
|
|
24
15
|
state.lastDependencies = dependencies;
|
|
@@ -26,6 +17,6 @@ function tapAfterCompileToAddDependencies(compiler, config, state) {
|
|
|
26
17
|
compilation.fileDependencies.add(file);
|
|
27
18
|
});
|
|
28
19
|
}
|
|
29
|
-
})
|
|
20
|
+
});
|
|
30
21
|
}
|
|
31
22
|
exports.tapAfterCompileToAddDependencies = tapAfterCompileToAddDependencies;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.tapAfterCompileToGetIssues = void 0;
|
|
13
4
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
@@ -16,20 +7,20 @@ const plugin_hooks_1 = require("../plugin-hooks");
|
|
|
16
7
|
function tapAfterCompileToGetIssues(compiler, config, state) {
|
|
17
8
|
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
18
9
|
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
19
|
-
compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', (compilation) =>
|
|
10
|
+
compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation) => {
|
|
20
11
|
if (compilation.compiler !== compiler) {
|
|
21
12
|
// run only for the compiler that the plugin was registered for
|
|
22
13
|
return;
|
|
23
14
|
}
|
|
24
15
|
let issues = [];
|
|
25
16
|
try {
|
|
26
|
-
issues =
|
|
17
|
+
issues = await state.issuesPromise;
|
|
27
18
|
}
|
|
28
19
|
catch (error) {
|
|
29
20
|
hooks.error.call(error, compilation);
|
|
30
21
|
return;
|
|
31
22
|
}
|
|
32
|
-
debug('Got issues from getIssuesWorker.', issues
|
|
23
|
+
debug('Got issues from getIssuesWorker.', issues?.length);
|
|
33
24
|
if (!issues) {
|
|
34
25
|
// some error has been thrown or it was canceled
|
|
35
26
|
return;
|
|
@@ -47,6 +38,6 @@ function tapAfterCompileToGetIssues(compiler, config, state) {
|
|
|
47
38
|
compilation.errors.push(error);
|
|
48
39
|
}
|
|
49
40
|
});
|
|
50
|
-
})
|
|
41
|
+
});
|
|
51
42
|
}
|
|
52
43
|
exports.tapAfterCompileToGetIssues = tapAfterCompileToGetIssues;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -25,7 +16,7 @@ const wait_1 = require("../utils/async/wait");
|
|
|
25
16
|
function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
26
17
|
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
27
18
|
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
28
|
-
compiler.hooks.done.tap('TsCheckerRspackPlugin', (stats) =>
|
|
19
|
+
compiler.hooks.done.tap('TsCheckerRspackPlugin', async (stats) => {
|
|
29
20
|
if (stats.compilation.compiler !== compiler) {
|
|
30
21
|
// run only for the compiler that the plugin was registered for
|
|
31
22
|
return;
|
|
@@ -33,15 +24,15 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
33
24
|
const issuesPromise = state.issuesPromise;
|
|
34
25
|
let issues;
|
|
35
26
|
try {
|
|
36
|
-
if (
|
|
27
|
+
if (await (0, is_pending_1.isPending)(issuesPromise)) {
|
|
37
28
|
hooks.waiting.call(stats.compilation);
|
|
38
29
|
config.logger.log(picocolors_1.default.cyan('Type-checking in progress...'));
|
|
39
30
|
}
|
|
40
31
|
else {
|
|
41
32
|
// wait 10ms to log issues after webpack stats
|
|
42
|
-
|
|
33
|
+
await (0, wait_1.wait)(10);
|
|
43
34
|
}
|
|
44
|
-
issues =
|
|
35
|
+
issues = await issuesPromise;
|
|
45
36
|
}
|
|
46
37
|
catch (error) {
|
|
47
38
|
hooks.error.call(error, stats.compilation);
|
|
@@ -52,7 +43,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
52
43
|
) {
|
|
53
44
|
return;
|
|
54
45
|
}
|
|
55
|
-
debug(`Got ${
|
|
46
|
+
debug(`Got ${issues?.length || 0} issues from getIssuesWorker.`);
|
|
56
47
|
// filter list of issues by provided issue predicate
|
|
57
48
|
issues = issues.filter(config.issue.predicate);
|
|
58
49
|
// modify list of issues in the plugin hooks
|
|
@@ -82,6 +73,6 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
82
73
|
debug('Sending issues to the webpack-dev-server.');
|
|
83
74
|
state.webpackDevServerDoneTap.fn(stats);
|
|
84
75
|
}
|
|
85
|
-
})
|
|
76
|
+
});
|
|
86
77
|
}
|
|
87
78
|
exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.tapStartToRunWorkers = void 0;
|
|
13
4
|
const files_change_1 = require("../files-change");
|
|
@@ -28,7 +19,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
28
19
|
(0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
|
|
29
20
|
}
|
|
30
21
|
});
|
|
31
|
-
compiler.hooks.watchRun.tap('TsCheckerRspackPlugin', () =>
|
|
22
|
+
compiler.hooks.watchRun.tap('TsCheckerRspackPlugin', async () => {
|
|
32
23
|
if (!state.initialized) {
|
|
33
24
|
state.initialized = true;
|
|
34
25
|
state.watching = true;
|
|
@@ -42,8 +33,8 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
42
33
|
(0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
|
-
})
|
|
46
|
-
compiler.hooks.compilation.tap('TsCheckerRspackPlugin', (compilation) =>
|
|
36
|
+
});
|
|
37
|
+
compiler.hooks.compilation.tap('TsCheckerRspackPlugin', async (compilation) => {
|
|
47
38
|
if (compilation.compiler !== compiler) {
|
|
48
39
|
// run only for the compiler that the plugin was registered for
|
|
49
40
|
return;
|
|
@@ -70,7 +61,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
70
61
|
else {
|
|
71
62
|
log('Calling reporter service for single check.');
|
|
72
63
|
}
|
|
73
|
-
filesChange =
|
|
64
|
+
filesChange = await hooks.start.promise(filesChange, compilation);
|
|
74
65
|
let aggregatedFilesChange = filesChange;
|
|
75
66
|
if (state.aggregatedFilesChange) {
|
|
76
67
|
aggregatedFilesChange = (0, files_change_1.aggregateFilesChanges)([aggregatedFilesChange, filesChange]);
|
|
@@ -91,10 +82,10 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
91
82
|
return undefined;
|
|
92
83
|
}
|
|
93
84
|
debug(`Submitting the getIssuesWorker to the pool, iteration ${iteration}.`);
|
|
94
|
-
return plugin_pools_1.issuesPool.submit(() =>
|
|
85
|
+
return plugin_pools_1.issuesPool.submit(async () => {
|
|
95
86
|
try {
|
|
96
87
|
debug(`Running the getIssuesWorker, iteration ${iteration}.`);
|
|
97
|
-
const issues =
|
|
88
|
+
const issues = await getIssuesWorker(aggregatedFilesChange, state.watching);
|
|
98
89
|
if (state.aggregatedFilesChange === aggregatedFilesChange) {
|
|
99
90
|
state.aggregatedFilesChange = undefined;
|
|
100
91
|
}
|
|
@@ -110,13 +101,13 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
110
101
|
finally {
|
|
111
102
|
debug(`The getIssuesWorker finished its job, iteration ${iteration}.`);
|
|
112
103
|
}
|
|
113
|
-
}
|
|
104
|
+
}, abortController.signal);
|
|
114
105
|
});
|
|
115
106
|
debug(`Submitting the getDependenciesWorker to the pool, iteration ${iteration}.`);
|
|
116
|
-
state.dependenciesPromise = plugin_pools_1.dependenciesPool.submit(() =>
|
|
107
|
+
state.dependenciesPromise = plugin_pools_1.dependenciesPool.submit(async () => {
|
|
117
108
|
try {
|
|
118
109
|
debug(`Running the getDependenciesWorker, iteration ${iteration}.`);
|
|
119
|
-
return
|
|
110
|
+
return await getDependenciesWorker(filesChange);
|
|
120
111
|
}
|
|
121
112
|
catch (error) {
|
|
122
113
|
hooks.error.call(error, compilation);
|
|
@@ -125,7 +116,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
125
116
|
finally {
|
|
126
117
|
debug(`The getDependenciesWorker finished its job, iteration ${iteration}.`);
|
|
127
118
|
}
|
|
128
|
-
})
|
|
129
|
-
})
|
|
119
|
+
}); // don't pass abortController.signal because getDependencies() is blocking
|
|
120
|
+
});
|
|
130
121
|
}
|
|
131
122
|
exports.tapStartToRunWorkers = tapStartToRunWorkers;
|
package/lib/rpc/expose-rpc.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -34,7 +25,7 @@ function exposeRpc(fn) {
|
|
|
34
25
|
});
|
|
35
26
|
}
|
|
36
27
|
});
|
|
37
|
-
const handleMessage = (message) =>
|
|
28
|
+
const handleMessage = async (message) => {
|
|
38
29
|
if (message.type === 'call') {
|
|
39
30
|
if (!process_1.default.send) {
|
|
40
31
|
// process disconnected - skip
|
|
@@ -43,21 +34,21 @@ function exposeRpc(fn) {
|
|
|
43
34
|
let value;
|
|
44
35
|
let error;
|
|
45
36
|
try {
|
|
46
|
-
value =
|
|
37
|
+
value = await fn(...message.args);
|
|
47
38
|
}
|
|
48
39
|
catch (fnError) {
|
|
49
40
|
error = fnError;
|
|
50
41
|
}
|
|
51
42
|
try {
|
|
52
43
|
if (error) {
|
|
53
|
-
|
|
44
|
+
await sendMessage({
|
|
54
45
|
type: 'reject',
|
|
55
46
|
id: message.id,
|
|
56
47
|
error,
|
|
57
48
|
});
|
|
58
49
|
}
|
|
59
50
|
else {
|
|
60
|
-
|
|
51
|
+
await sendMessage({
|
|
61
52
|
type: 'resolve',
|
|
62
53
|
id: message.id,
|
|
63
54
|
value,
|
|
@@ -72,7 +63,7 @@ function exposeRpc(fn) {
|
|
|
72
63
|
console.error(sendError);
|
|
73
64
|
}
|
|
74
65
|
}
|
|
75
|
-
}
|
|
66
|
+
};
|
|
76
67
|
process_1.default.on('message', handleMessage);
|
|
77
68
|
}
|
|
78
69
|
exports.exposeRpc = exposeRpc;
|
package/lib/rpc/rpc-worker.js
CHANGED
|
@@ -30,7 +30,10 @@ const wrap_rpc_1 = require("./wrap-rpc");
|
|
|
30
30
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
31
31
|
function createRpcWorker(modulePath, data, memoryLimit) {
|
|
32
32
|
const options = {
|
|
33
|
-
env:
|
|
33
|
+
env: {
|
|
34
|
+
...process.env,
|
|
35
|
+
[WORKER_DATA_ENV_KEY]: JSON.stringify(data || {}),
|
|
36
|
+
},
|
|
34
37
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
35
38
|
serialization: 'advanced',
|
|
36
39
|
};
|
|
@@ -46,7 +49,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
|
|
|
46
49
|
childProcess = undefined;
|
|
47
50
|
remoteMethod = undefined;
|
|
48
51
|
}
|
|
49
|
-
if (!
|
|
52
|
+
if (!childProcess?.connected) {
|
|
50
53
|
childProcess = child_process.fork(modulePath, options);
|
|
51
54
|
remoteMethod = (0, wrap_rpc_1.wrapRpc)(childProcess);
|
|
52
55
|
}
|
|
@@ -59,7 +62,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
|
|
|
59
62
|
}
|
|
60
63
|
},
|
|
61
64
|
get connected() {
|
|
62
|
-
return Boolean(childProcess
|
|
65
|
+
return Boolean(childProcess?.connected);
|
|
63
66
|
},
|
|
64
67
|
get process() {
|
|
65
68
|
return childProcess;
|
package/lib/rpc/wrap-rpc.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.wrapRpc = void 0;
|
|
13
4
|
const controlled_promise_1 = require("../utils/async/controlled-promise");
|
|
14
5
|
const rpc_error_1 = require("./rpc-error");
|
|
15
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
7
|
function wrapRpc(childProcess) {
|
|
17
|
-
return ((...args) =>
|
|
8
|
+
return (async (...args) => {
|
|
18
9
|
if (!childProcess.send) {
|
|
19
10
|
throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
|
|
20
11
|
}
|
|
@@ -26,7 +17,7 @@ function wrapRpc(childProcess) {
|
|
|
26
17
|
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)();
|
|
27
18
|
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)();
|
|
28
19
|
const handleMessage = (message) => {
|
|
29
|
-
if (
|
|
20
|
+
if (message?.id === id) {
|
|
30
21
|
if (message.type === 'resolve') {
|
|
31
22
|
// assume the contract is respected
|
|
32
23
|
resolveResult(message.value);
|
|
@@ -68,7 +59,7 @@ function wrapRpc(childProcess) {
|
|
|
68
59
|
}
|
|
69
60
|
});
|
|
70
61
|
return sendPromise.then(() => resultPromise);
|
|
71
|
-
})
|
|
62
|
+
});
|
|
72
63
|
}
|
|
73
64
|
exports.wrapRpc = wrapRpc;
|
|
74
65
|
function uuid() {
|
|
@@ -13,6 +13,24 @@ function createTypeScriptWorkerConfig(compiler, options) {
|
|
|
13
13
|
: path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
|
|
14
14
|
const optionsAsObject = typeof options === 'object' ? options : {};
|
|
15
15
|
const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
|
|
16
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
enabled: Boolean(options) || options === undefined,
|
|
18
|
+
memoryLimit: 8192,
|
|
19
|
+
build: false,
|
|
20
|
+
mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',
|
|
21
|
+
profile: false,
|
|
22
|
+
...optionsAsObject,
|
|
23
|
+
configFile: configFile,
|
|
24
|
+
configOverwrite: optionsAsObject.configOverwrite || {},
|
|
25
|
+
context: optionsAsObject.context || path_1.default.dirname(configFile),
|
|
26
|
+
diagnosticOptions: {
|
|
27
|
+
syntactic: false,
|
|
28
|
+
semantic: true,
|
|
29
|
+
declaration: false,
|
|
30
|
+
global: false,
|
|
31
|
+
...(optionsAsObject.diagnosticOptions || {}),
|
|
32
|
+
},
|
|
33
|
+
typescriptPath: typescriptPath,
|
|
34
|
+
};
|
|
17
35
|
}
|
|
18
36
|
exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const rpc_1 = require("../../rpc");
|
|
13
4
|
const artifacts_1 = require("./lib/artifacts");
|
|
@@ -22,8 +13,7 @@ const system_1 = require("./lib/system");
|
|
|
22
13
|
const tracing_1 = require("./lib/tracing");
|
|
23
14
|
const tsbuildinfo_1 = require("./lib/tsbuildinfo");
|
|
24
15
|
const worker_config_1 = require("./lib/worker-config");
|
|
25
|
-
const getIssuesWorker = (change, watching) =>
|
|
26
|
-
var _a, _b;
|
|
16
|
+
const getIssuesWorker = async (change, watching) => {
|
|
27
17
|
system_1.system.invalidateCache();
|
|
28
18
|
if ((0, config_1.didConfigFileChanged)(change)) {
|
|
29
19
|
(0, config_1.invalidateConfig)();
|
|
@@ -62,19 +52,19 @@ const getIssuesWorker = (change, watching) => __awaiter(void 0, void 0, void 0,
|
|
|
62
52
|
(0, program_1.useProgram)();
|
|
63
53
|
}
|
|
64
54
|
// simulate file system events
|
|
65
|
-
|
|
66
|
-
system_1.system
|
|
55
|
+
change.changedFiles?.forEach((changedFile) => {
|
|
56
|
+
system_1.system?.invokeFileChanged(changedFile);
|
|
67
57
|
});
|
|
68
|
-
|
|
69
|
-
system_1.system
|
|
58
|
+
change.deletedFiles?.forEach((deletedFile) => {
|
|
59
|
+
system_1.system?.invokeFileDeleted(deletedFile);
|
|
70
60
|
});
|
|
71
61
|
// wait for all queued events to be processed
|
|
72
|
-
|
|
62
|
+
await system_1.system.waitForQueued();
|
|
73
63
|
// retrieve all collected diagnostics as normalized issues
|
|
74
64
|
const issues = (0, diagnostics_1.getIssues)();
|
|
75
65
|
(0, tracing_1.dumpTracingLegendIfNeeded)();
|
|
76
66
|
(0, performance_1.printPerformanceMeasuresIfNeeded)();
|
|
77
67
|
(0, performance_1.disablePerformanceIfNeeded)();
|
|
78
68
|
return issues;
|
|
79
|
-
}
|
|
69
|
+
};
|
|
80
70
|
(0, rpc_1.exposeRpc)(getIssuesWorker);
|
|
@@ -33,9 +33,12 @@ const worker_config_1 = require("./worker-config");
|
|
|
33
33
|
let parsedConfig;
|
|
34
34
|
let parseConfigDiagnostics = [];
|
|
35
35
|
// initialize ParseConfigFileHost
|
|
36
|
-
const parseConfigFileHost =
|
|
36
|
+
const parseConfigFileHost = {
|
|
37
|
+
...system_1.system,
|
|
38
|
+
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
37
39
|
parseConfigDiagnostics.push(diagnostic);
|
|
38
|
-
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
39
42
|
function getUserProvidedConfigOverwrite() {
|
|
40
43
|
return worker_config_1.config.configOverwrite || {};
|
|
41
44
|
}
|
|
@@ -48,12 +51,22 @@ function getImplicitConfigOverwrite() {
|
|
|
48
51
|
switch (worker_config_1.config.mode) {
|
|
49
52
|
case 'write-dts':
|
|
50
53
|
return {
|
|
51
|
-
compilerOptions:
|
|
54
|
+
compilerOptions: {
|
|
55
|
+
...baseCompilerOptionsOverwrite,
|
|
56
|
+
declaration: true,
|
|
57
|
+
emitDeclarationOnly: true,
|
|
58
|
+
noEmit: false,
|
|
59
|
+
},
|
|
52
60
|
};
|
|
53
61
|
case 'write-tsbuildinfo':
|
|
54
62
|
case 'write-references':
|
|
55
63
|
return {
|
|
56
|
-
compilerOptions:
|
|
64
|
+
compilerOptions: {
|
|
65
|
+
...baseCompilerOptionsOverwrite,
|
|
66
|
+
declaration: true,
|
|
67
|
+
emitDeclarationOnly: false,
|
|
68
|
+
noEmit: false,
|
|
69
|
+
},
|
|
57
70
|
};
|
|
58
71
|
}
|
|
59
72
|
return {
|
|
@@ -63,7 +76,14 @@ function getImplicitConfigOverwrite() {
|
|
|
63
76
|
function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
|
|
64
77
|
let config = baseConfig;
|
|
65
78
|
for (const overwriteConfig of overwriteConfigs) {
|
|
66
|
-
config =
|
|
79
|
+
config = {
|
|
80
|
+
...(config || {}),
|
|
81
|
+
...(overwriteConfig || {}),
|
|
82
|
+
compilerOptions: {
|
|
83
|
+
...(config?.compilerOptions || {}),
|
|
84
|
+
...(overwriteConfig?.compilerOptions || {}),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
67
87
|
}
|
|
68
88
|
return config;
|
|
69
89
|
}
|
|
@@ -72,7 +92,14 @@ function parseConfig(configFileName, configFileContext) {
|
|
|
72
92
|
const { config: baseConfig, error: readConfigError } = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
|
|
73
93
|
const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
|
|
74
94
|
const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
|
|
75
|
-
return
|
|
95
|
+
return {
|
|
96
|
+
...parsedConfigFile,
|
|
97
|
+
options: {
|
|
98
|
+
...parsedConfigFile.options,
|
|
99
|
+
configFilePath: configFilePath,
|
|
100
|
+
},
|
|
101
|
+
errors: readConfigError ? [readConfigError] : parsedConfigFile.errors,
|
|
102
|
+
};
|
|
76
103
|
}
|
|
77
104
|
exports.parseConfig = parseConfig;
|
|
78
105
|
function getParseConfigIssues() {
|
|
@@ -42,14 +42,13 @@ function invalidateDependencies() {
|
|
|
42
42
|
}
|
|
43
43
|
exports.invalidateDependencies = invalidateDependencies;
|
|
44
44
|
function getDependenciesWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
|
|
45
|
-
var _a;
|
|
46
45
|
const files = new Set(parsedConfig.fileNames);
|
|
47
46
|
const configFilePath = parsedConfig.options.configFilePath;
|
|
48
47
|
if (typeof configFilePath === 'string') {
|
|
49
48
|
files.add(configFilePath);
|
|
50
49
|
}
|
|
51
50
|
const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
|
|
52
|
-
const excluded = new Set((
|
|
51
|
+
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath) => path.resolve(configFileContext, filePath)));
|
|
53
52
|
for (const projectReference of parsedConfig.projectReferences || []) {
|
|
54
53
|
const childConfigFilePath = typescript_1.typescript.resolveProjectReferencePath(projectReference);
|
|
55
54
|
const childConfigContext = path.dirname(childConfigFilePath);
|
|
@@ -7,7 +7,9 @@ const real_file_system_1 = require("./real-file-system");
|
|
|
7
7
|
/**
|
|
8
8
|
* It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
|
|
9
9
|
*/
|
|
10
|
-
exports.memFileSystem =
|
|
10
|
+
exports.memFileSystem = {
|
|
11
|
+
...real_file_system_1.realFileSystem,
|
|
12
|
+
exists(path) {
|
|
11
13
|
return exists(real_file_system_1.realFileSystem.realPath(path));
|
|
12
14
|
},
|
|
13
15
|
readFile(path, encoding) {
|
|
@@ -33,7 +35,8 @@ exports.memFileSystem = Object.assign(Object.assign({}, real_file_system_1.realF
|
|
|
33
35
|
},
|
|
34
36
|
clearCache() {
|
|
35
37
|
real_file_system_1.realFileSystem.clearCache();
|
|
36
|
-
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
37
40
|
function exists(path) {
|
|
38
41
|
return memfs_1.fs.existsSync(real_file_system_1.realFileSystem.normalizePath(path));
|
|
39
42
|
}
|
|
@@ -6,7 +6,9 @@ const real_file_system_1 = require("./real-file-system");
|
|
|
6
6
|
/**
|
|
7
7
|
* It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
|
|
8
8
|
*/
|
|
9
|
-
exports.passiveFileSystem =
|
|
9
|
+
exports.passiveFileSystem = {
|
|
10
|
+
...mem_file_system_1.memFileSystem,
|
|
11
|
+
exists(path) {
|
|
10
12
|
return exists(real_file_system_1.realFileSystem.realPath(path));
|
|
11
13
|
},
|
|
12
14
|
readFile(path, encoding) {
|
|
@@ -23,7 +25,8 @@ exports.passiveFileSystem = Object.assign(Object.assign({}, mem_file_system_1.me
|
|
|
23
25
|
},
|
|
24
26
|
clearCache() {
|
|
25
27
|
real_file_system_1.realFileSystem.clearCache();
|
|
26
|
-
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
27
30
|
function exists(path) {
|
|
28
31
|
return real_file_system_1.realFileSystem.exists(path) || mem_file_system_1.memFileSystem.exists(path);
|
|
29
32
|
}
|
|
@@ -5,6 +5,13 @@ const system_1 = require("../system");
|
|
|
5
5
|
const typescript_1 = require("../typescript");
|
|
6
6
|
function createCompilerHost(parsedConfig) {
|
|
7
7
|
const baseCompilerHost = typescript_1.typescript.createCompilerHost(parsedConfig.options);
|
|
8
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...baseCompilerHost,
|
|
10
|
+
fileExists: system_1.system.fileExists,
|
|
11
|
+
readFile: system_1.system.readFile,
|
|
12
|
+
directoryExists: system_1.system.directoryExists,
|
|
13
|
+
getDirectories: system_1.system.getDirectories,
|
|
14
|
+
realpath: system_1.system.realpath,
|
|
15
|
+
};
|
|
9
16
|
}
|
|
10
17
|
exports.createCompilerHost = createCompilerHost;
|
|
@@ -5,7 +5,9 @@ const system_1 = require("../system");
|
|
|
5
5
|
const typescript_1 = require("../typescript");
|
|
6
6
|
function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate) {
|
|
7
7
|
const baseWatchCompilerHost = typescript_1.typescript.createWatchCompilerHost(parsedConfig.fileNames, parsedConfig.options, system_1.system, createProgram, reportDiagnostic, reportWatchStatus, parsedConfig.projectReferences);
|
|
8
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...baseWatchCompilerHost,
|
|
10
|
+
createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
|
|
9
11
|
return baseWatchCompilerHost.createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
10
12
|
},
|
|
11
13
|
afterProgramCreate(program) {
|
|
@@ -15,6 +17,16 @@ function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic,
|
|
|
15
17
|
},
|
|
16
18
|
onWatchStatusChange() {
|
|
17
19
|
// do nothing
|
|
18
|
-
},
|
|
20
|
+
},
|
|
21
|
+
watchFile: system_1.system.watchFile,
|
|
22
|
+
watchDirectory: system_1.system.watchDirectory,
|
|
23
|
+
setTimeout: system_1.system.setTimeout,
|
|
24
|
+
clearTimeout: system_1.system.clearTimeout,
|
|
25
|
+
fileExists: system_1.system.fileExists,
|
|
26
|
+
readFile: system_1.system.readFile,
|
|
27
|
+
directoryExists: system_1.system.directoryExists,
|
|
28
|
+
getDirectories: system_1.system.getDirectories,
|
|
29
|
+
realpath: system_1.system.realpath,
|
|
30
|
+
};
|
|
19
31
|
}
|
|
20
32
|
exports.createWatchCompilerHost = createWatchCompilerHost;
|
|
@@ -6,7 +6,9 @@ const typescript_1 = require("../typescript");
|
|
|
6
6
|
const watch_compiler_host_1 = require("./watch-compiler-host");
|
|
7
7
|
function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics) {
|
|
8
8
|
const controlledWatchCompilerHost = (0, watch_compiler_host_1.createWatchCompilerHost)(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate);
|
|
9
|
-
return
|
|
9
|
+
return {
|
|
10
|
+
...controlledWatchCompilerHost,
|
|
11
|
+
reportDiagnostic(diagnostic) {
|
|
10
12
|
if (reportDiagnostic) {
|
|
11
13
|
reportDiagnostic(diagnostic);
|
|
12
14
|
}
|
|
@@ -37,11 +39,15 @@ function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagn
|
|
|
37
39
|
system_1.system.deleteFile(fileName);
|
|
38
40
|
},
|
|
39
41
|
getParsedCommandLine(fileName) {
|
|
40
|
-
return typescript_1.typescript.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true },
|
|
42
|
+
return typescript_1.typescript.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, {
|
|
43
|
+
...system_1.system,
|
|
44
|
+
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
41
45
|
if (reportDiagnostic) {
|
|
42
46
|
reportDiagnostic(diagnostic);
|
|
43
47
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
46
52
|
}
|
|
47
53
|
exports.createWatchSolutionBuilderHost = createWatchSolutionBuilderHost;
|
|
@@ -6,24 +6,21 @@ const worker_config_1 = require("./worker-config");
|
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
7
|
const performance = typescript_1.typescript.performance;
|
|
8
8
|
function enablePerformanceIfNeeded() {
|
|
9
|
-
var _a;
|
|
10
9
|
if (worker_config_1.config.profile) {
|
|
11
|
-
|
|
10
|
+
performance?.enable?.();
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
exports.enablePerformanceIfNeeded = enablePerformanceIfNeeded;
|
|
15
14
|
function disablePerformanceIfNeeded() {
|
|
16
|
-
var _a;
|
|
17
15
|
if (worker_config_1.config.profile) {
|
|
18
|
-
|
|
16
|
+
performance?.disable?.();
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
exports.disablePerformanceIfNeeded = disablePerformanceIfNeeded;
|
|
22
20
|
function printPerformanceMeasuresIfNeeded() {
|
|
23
|
-
var _a;
|
|
24
21
|
if (worker_config_1.config.profile) {
|
|
25
22
|
const measures = {};
|
|
26
|
-
|
|
23
|
+
performance?.forEachMeasure?.((measureName, duration) => {
|
|
27
24
|
measures[measureName] = duration;
|
|
28
25
|
});
|
|
29
26
|
console.table(measures);
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.system = void 0;
|
|
13
4
|
const path_1 = require("path");
|
|
@@ -34,7 +25,10 @@ const deletedFiles = new Map();
|
|
|
34
25
|
const timeoutCallbacks = new Set();
|
|
35
26
|
// based on the ts.ignorePaths
|
|
36
27
|
const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
|
|
37
|
-
exports.system =
|
|
28
|
+
exports.system = {
|
|
29
|
+
...typescript_1.typescript.sys,
|
|
30
|
+
useCaseSensitiveFileNames: true,
|
|
31
|
+
realpath(path) {
|
|
38
32
|
return getReadFileSystem(path).realPath(path);
|
|
39
33
|
},
|
|
40
34
|
fileExists(path) {
|
|
@@ -57,8 +51,7 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
|
|
|
57
51
|
exports.system.invokeFileDeleted(path);
|
|
58
52
|
},
|
|
59
53
|
directoryExists(path) {
|
|
60
|
-
|
|
61
|
-
return Boolean((_a = getReadFileSystem(path).readStats(path)) === null || _a === void 0 ? void 0 : _a.isDirectory());
|
|
54
|
+
return Boolean(getReadFileSystem(path).readStats(path)?.isDirectory());
|
|
62
55
|
},
|
|
63
56
|
createDirectory(path) {
|
|
64
57
|
getWriteFileSystem(path).createDir(path);
|
|
@@ -87,7 +80,7 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
|
|
|
87
80
|
},
|
|
88
81
|
watchDirectory(path, callback, recursive = false) {
|
|
89
82
|
return createWatcher(recursive ? recursiveDirectoryWatcherCallbacksMap : directoryWatcherCallbacksMap, path, callback);
|
|
90
|
-
},
|
|
83
|
+
},
|
|
91
84
|
// use immediate instead of timeout to avoid waiting 250ms for batching files changes
|
|
92
85
|
setTimeout: (callback, timeout, ...args) => {
|
|
93
86
|
const timeoutId = setImmediate(() => {
|
|
@@ -96,16 +89,16 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
|
|
|
96
89
|
});
|
|
97
90
|
timeoutCallbacks.add(timeoutId);
|
|
98
91
|
return timeoutId;
|
|
99
|
-
},
|
|
92
|
+
},
|
|
93
|
+
clearTimeout: (timeoutId) => {
|
|
100
94
|
clearImmediate(timeoutId);
|
|
101
95
|
timeoutCallbacks.delete(timeoutId);
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
96
|
+
},
|
|
97
|
+
async waitForQueued() {
|
|
98
|
+
while (timeoutCallbacks.size > 0) {
|
|
99
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
100
|
+
}
|
|
101
|
+
isInitialRun = false;
|
|
109
102
|
},
|
|
110
103
|
invokeFileCreated(path) {
|
|
111
104
|
const normalizedPath = normalizeAndResolvePath(path);
|
|
@@ -139,7 +132,8 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
|
|
|
139
132
|
},
|
|
140
133
|
setArtifacts(nextArtifacts) {
|
|
141
134
|
artifacts = nextArtifacts;
|
|
142
|
-
}
|
|
135
|
+
},
|
|
136
|
+
};
|
|
143
137
|
function createWatcher(watchersMap, path, callback) {
|
|
144
138
|
const normalizedPath = normalizeAndResolvePath(path);
|
|
145
139
|
const watchers = watchersMap.get(normalizedPath) || [];
|
|
@@ -209,7 +203,7 @@ function getReadFileSystem(path) {
|
|
|
209
203
|
if (isInitialRun && !mem_file_system_1.memFileSystem.exists(path) && passive_file_system_1.passiveFileSystem.exists(path)) {
|
|
210
204
|
// copy file to memory on initial run
|
|
211
205
|
const stats = passive_file_system_1.passiveFileSystem.readStats(path);
|
|
212
|
-
if (stats
|
|
206
|
+
if (stats?.isFile()) {
|
|
213
207
|
const content = passive_file_system_1.passiveFileSystem.readFile(path);
|
|
214
208
|
if (content) {
|
|
215
209
|
mem_file_system_1.memFileSystem.writeFile(path, content);
|
|
@@ -14,16 +14,14 @@ function startTracingIfNeeded(compilerOptions) {
|
|
|
14
14
|
}
|
|
15
15
|
exports.startTracingIfNeeded = startTracingIfNeeded;
|
|
16
16
|
function stopTracingIfNeeded(program) {
|
|
17
|
-
var _a;
|
|
18
17
|
const compilerOptions = program.getCompilerOptions();
|
|
19
18
|
if (typeof compilerOptions.generateTrace === 'string' &&
|
|
20
|
-
typeof
|
|
19
|
+
typeof traceableTypescript.tracing?.stopTracing === 'function') {
|
|
21
20
|
traceableTypescript.tracing.stopTracing();
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
exports.stopTracingIfNeeded = stopTracingIfNeeded;
|
|
25
24
|
function dumpTracingLegendIfNeeded() {
|
|
26
|
-
|
|
27
|
-
(_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.dumpLegend();
|
|
25
|
+
traceableTypescript.tracing?.dumpLegend();
|
|
28
26
|
}
|
|
29
27
|
exports.dumpTracingLegendIfNeeded = dumpTracingLegendIfNeeded;
|
package/lib/utils/async/pool.js
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.createPool = void 0;
|
|
13
4
|
const abort_error_1 = require("./abort-error");
|
|
14
5
|
function createPool(size) {
|
|
15
6
|
let pendingPromises = [];
|
|
16
7
|
const pool = {
|
|
17
|
-
submit(task, signal) {
|
|
18
|
-
|
|
19
|
-
while (pendingPromises.length >= pool.size) {
|
|
20
|
-
abort_error_1.AbortError.throwIfAborted(signal);
|
|
21
|
-
yield Promise.race(pendingPromises).catch(() => undefined);
|
|
22
|
-
}
|
|
8
|
+
async submit(task, signal) {
|
|
9
|
+
while (pendingPromises.length >= pool.size) {
|
|
23
10
|
abort_error_1.AbortError.throwIfAborted(signal);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
await Promise.race(pendingPromises).catch(() => undefined);
|
|
12
|
+
}
|
|
13
|
+
abort_error_1.AbortError.throwIfAborted(signal);
|
|
14
|
+
const taskPromise = task(signal).finally(() => {
|
|
15
|
+
pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
|
|
29
16
|
});
|
|
17
|
+
pendingPromises.push(taskPromise);
|
|
18
|
+
return taskPromise;
|
|
30
19
|
},
|
|
31
20
|
size,
|
|
32
21
|
get pending() {
|
|
@@ -34,12 +23,12 @@ function createPool(size) {
|
|
|
34
23
|
},
|
|
35
24
|
get drained() {
|
|
36
25
|
// eslint-disable-next-line no-async-promise-executor
|
|
37
|
-
return new Promise((resolve) =>
|
|
26
|
+
return new Promise(async (resolve) => {
|
|
38
27
|
while (pendingPromises.length > 0) {
|
|
39
|
-
|
|
28
|
+
await Promise.race(pendingPromises).catch(() => undefined);
|
|
40
29
|
}
|
|
41
30
|
resolve(undefined);
|
|
42
|
-
})
|
|
31
|
+
});
|
|
43
32
|
},
|
|
44
33
|
};
|
|
45
34
|
return pool;
|
|
@@ -34,8 +34,7 @@ function createIsIgnored(ignored, excluded) {
|
|
|
34
34
|
}
|
|
35
35
|
class InclusiveNodeWatchFileSystem {
|
|
36
36
|
get watcher() {
|
|
37
|
-
|
|
38
|
-
return this.watchFileSystem.watcher || ((_a = this.watchFileSystem.wfs) === null || _a === void 0 ? void 0 : _a.watcher);
|
|
37
|
+
return this.watchFileSystem.watcher || this.watchFileSystem.wfs?.watcher;
|
|
39
38
|
}
|
|
40
39
|
constructor(watchFileSystem, compiler, pluginState) {
|
|
41
40
|
this.watchFileSystem = watchFileSystem;
|
|
@@ -43,13 +42,12 @@ class InclusiveNodeWatchFileSystem {
|
|
|
43
42
|
this.pluginState = pluginState;
|
|
44
43
|
this.paused = true;
|
|
45
44
|
this.watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed) => {
|
|
46
|
-
var _a, _b, _c, _d;
|
|
47
45
|
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(this.compiler);
|
|
48
46
|
(0, files_change_1.clearFilesChange)(this.compiler);
|
|
49
|
-
const isIgnored = createIsIgnored(options
|
|
47
|
+
const isIgnored = createIsIgnored(options?.ignored, this.pluginState.lastDependencies?.excluded || []);
|
|
50
48
|
// use standard watch file system for files and missing
|
|
51
49
|
const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
|
|
52
|
-
|
|
50
|
+
this.watcher?.on('change', (file) => {
|
|
53
51
|
if (typeof file !== 'string') {
|
|
54
52
|
return;
|
|
55
53
|
}
|
|
@@ -62,7 +60,7 @@ class InclusiveNodeWatchFileSystem {
|
|
|
62
60
|
debug("Detected file change but it's ignored", file);
|
|
63
61
|
}
|
|
64
62
|
});
|
|
65
|
-
|
|
63
|
+
this.watcher?.on('remove', (file) => {
|
|
66
64
|
if (typeof file !== 'string') {
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
@@ -81,22 +79,21 @@ class InclusiveNodeWatchFileSystem {
|
|
|
81
79
|
});
|
|
82
80
|
// calculate what to change
|
|
83
81
|
const prevDirs = Array.from(this.dirsWatchers.keys());
|
|
84
|
-
const nextDirs = Array.from(
|
|
82
|
+
const nextDirs = Array.from(this.pluginState.lastDependencies?.dirs || []);
|
|
85
83
|
const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
|
|
86
84
|
const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
|
|
87
85
|
// update dirs watcher
|
|
88
86
|
dirsToUnwatch.forEach((dirToUnwatch) => {
|
|
89
|
-
|
|
90
|
-
(_a = this.dirsWatchers.get(dirToUnwatch)) === null || _a === void 0 ? void 0 : _a.close();
|
|
87
|
+
this.dirsWatchers.get(dirToUnwatch)?.close();
|
|
91
88
|
this.dirsWatchers.delete(dirToUnwatch);
|
|
92
89
|
});
|
|
93
90
|
dirsToWatch.forEach((dirToWatch) => {
|
|
94
|
-
const interval = typeof
|
|
91
|
+
const interval = typeof options?.poll === 'number' ? options.poll : undefined;
|
|
95
92
|
const dirWatcher = chokidar_1.default.watch(dirToWatch, {
|
|
96
93
|
ignoreInitial: true,
|
|
97
94
|
ignorePermissionErrors: true,
|
|
98
95
|
ignored: (path) => isIgnored(path),
|
|
99
|
-
usePolling:
|
|
96
|
+
usePolling: options?.poll ? true : undefined,
|
|
100
97
|
interval: interval,
|
|
101
98
|
binaryInterval: interval,
|
|
102
99
|
alwaysStat: true,
|
|
@@ -104,12 +101,11 @@ class InclusiveNodeWatchFileSystem {
|
|
|
104
101
|
awaitWriteFinish: true,
|
|
105
102
|
});
|
|
106
103
|
dirWatcher.on('add', (file, stats) => {
|
|
107
|
-
var _a, _b;
|
|
108
104
|
if (this.paused) {
|
|
109
105
|
return;
|
|
110
106
|
}
|
|
111
107
|
const extension = (0, path_1.extname)(file);
|
|
112
|
-
const supportedExtensions =
|
|
108
|
+
const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
|
|
113
109
|
if (!supportedExtensions.includes(extension)) {
|
|
114
110
|
debug('Detected new file add but extension is not supported', file);
|
|
115
111
|
return;
|
|
@@ -117,15 +113,14 @@ class InclusiveNodeWatchFileSystem {
|
|
|
117
113
|
debug('Detected new file add', file);
|
|
118
114
|
this.deletedFiles.delete(file);
|
|
119
115
|
(0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
|
|
120
|
-
|
|
116
|
+
this.watcher?._onChange(dirToWatch, stats?.mtimeMs || stats?.ctimeMs || 1, file, 'rename');
|
|
121
117
|
});
|
|
122
118
|
dirWatcher.on('unlink', (file) => {
|
|
123
|
-
var _a, _b;
|
|
124
119
|
if (this.paused) {
|
|
125
120
|
return;
|
|
126
121
|
}
|
|
127
122
|
const extension = (0, path_1.extname)(file);
|
|
128
|
-
const supportedExtensions =
|
|
123
|
+
const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
|
|
129
124
|
if (!supportedExtensions.includes(extension)) {
|
|
130
125
|
debug('Detected new file remove but extension is not supported', file);
|
|
131
126
|
return;
|
|
@@ -137,27 +132,31 @@ class InclusiveNodeWatchFileSystem {
|
|
|
137
132
|
debug('Detected new file remove', file);
|
|
138
133
|
this.deletedFiles.add(file);
|
|
139
134
|
(0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
|
|
140
|
-
|
|
135
|
+
this.watcher?._onRemove(dirToWatch, file, 'rename');
|
|
141
136
|
});
|
|
142
137
|
this.dirsWatchers.set(dirToWatch, dirWatcher);
|
|
143
138
|
});
|
|
144
139
|
this.paused = false;
|
|
145
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
...standardWatcher,
|
|
142
|
+
close: () => {
|
|
146
143
|
(0, files_change_1.clearFilesChange)(this.compiler);
|
|
147
144
|
if (standardWatcher) {
|
|
148
145
|
standardWatcher.close();
|
|
149
146
|
}
|
|
150
147
|
this.dirsWatchers.forEach((dirWatcher) => {
|
|
151
|
-
dirWatcher
|
|
148
|
+
dirWatcher?.close();
|
|
152
149
|
});
|
|
153
150
|
this.dirsWatchers.clear();
|
|
154
151
|
this.paused = true;
|
|
155
|
-
},
|
|
152
|
+
},
|
|
153
|
+
pause: () => {
|
|
156
154
|
if (standardWatcher) {
|
|
157
155
|
standardWatcher.pause();
|
|
158
156
|
}
|
|
159
157
|
this.paused = true;
|
|
160
|
-
}
|
|
158
|
+
},
|
|
159
|
+
};
|
|
161
160
|
};
|
|
162
161
|
this.dirsWatchers = new Map();
|
|
163
162
|
this.deletedFiles = new Set();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-checker-rspack-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rspack",
|
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"@rspack/core": "^1.0.0",
|
|
45
45
|
"typescript": ">=3.8.0"
|
|
46
46
|
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"@rspack/core": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
47
52
|
"devDependencies": {
|
|
48
53
|
"@jest/console": "^27.0.0",
|
|
49
54
|
"@rspack/core": "^1.1.3",
|