ts-checker-rspack-plugin 1.2.1 → 1.2.2
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/README.md +2 -2
- package/lib/getDependenciesWorker.js +19 -7
- package/lib/getIssuesWorker.js +19 -7
- package/lib/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ yarn add -D ts-checker-rspack-plugin
|
|
|
39
39
|
pnpm add -D ts-checker-rspack-plugin
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
The minimal Rspack config with [builtin:swc-loader](https://rspack.
|
|
42
|
+
The minimal Rspack config with [builtin:swc-loader](https://rspack.rs/guide/features/builtin-swc-loader).
|
|
43
43
|
|
|
44
44
|
```js
|
|
45
45
|
// rspack.config.mjs
|
|
@@ -199,7 +199,7 @@ This plugin provides some custom Rspack hooks:
|
|
|
199
199
|
| `issues` | `SyncWaterfallHook` | `issues, compilation` | Issues have been received and will be reported. It's a waterfall hook, so you can modify the list of received issues. |
|
|
200
200
|
|
|
201
201
|
To access plugin hooks and tap into the event, we need to use the `getCompilerHooks` static method.
|
|
202
|
-
When we call this method with a [Rspack compiler instance](https://rspack.
|
|
202
|
+
When we call this method with a [Rspack compiler instance](https://rspack.rs/api/javascript-api/compiler), it returns the object with
|
|
203
203
|
[tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
|
|
204
204
|
|
|
205
205
|
```js
|
|
@@ -21,20 +21,30 @@ var __webpack_require__ = {};
|
|
|
21
21
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
22
|
})();
|
|
23
23
|
var __webpack_exports__ = {};
|
|
24
|
-
const
|
|
25
|
-
var
|
|
24
|
+
const external_node_process_namespaceObject = require("node:process");
|
|
25
|
+
var external_node_process_default = /*#__PURE__*/ __webpack_require__.n(external_node_process_namespaceObject);
|
|
26
|
+
function isClosedIpcChannelError(error) {
|
|
27
|
+
if ('object' == typeof error && null !== error && 'code' in error) {
|
|
28
|
+
const CLOSED_IPC_ERROR_CODES = new Set([
|
|
29
|
+
'ERR_IPC_CHANNEL_CLOSED',
|
|
30
|
+
'EPIPE'
|
|
31
|
+
]);
|
|
32
|
+
return CLOSED_IPC_ERROR_CODES.has(error.code);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
26
36
|
function exposeRpc(fn) {
|
|
27
37
|
const sendMessage = (message)=>new Promise((resolve, reject)=>{
|
|
28
|
-
if (
|
|
38
|
+
if (external_node_process_default().send) if (external_node_process_default().connected) external_node_process_default().send(message, void 0, void 0, (error)=>{
|
|
29
39
|
if (error) reject(error);
|
|
30
40
|
else resolve(void 0);
|
|
31
41
|
});
|
|
32
|
-
else reject(new Error(`Process ${
|
|
33
|
-
else reject(new Error(`Process ${
|
|
42
|
+
else reject(new Error(`Process ${external_node_process_default().pid} doesn't have open IPC channels`));
|
|
43
|
+
else reject(new Error(`Process ${external_node_process_default().pid} doesn't have IPC channels`));
|
|
34
44
|
});
|
|
35
45
|
const handleMessage = async (message)=>{
|
|
36
46
|
if ('call' === message.type) {
|
|
37
|
-
if (!
|
|
47
|
+
if (!external_node_process_default().send) return;
|
|
38
48
|
let value;
|
|
39
49
|
let error;
|
|
40
50
|
try {
|
|
@@ -54,14 +64,16 @@ function exposeRpc(fn) {
|
|
|
54
64
|
value
|
|
55
65
|
});
|
|
56
66
|
} catch (sendError) {
|
|
67
|
+
if (isClosedIpcChannelError(sendError)) return void console.warn('[type-check] Skipped because the parent process exited. Build may have failed or been interrupted.');
|
|
57
68
|
if (error) console.error(error);
|
|
58
69
|
console.error(sendError);
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
};
|
|
62
|
-
|
|
73
|
+
external_node_process_default().on('message', handleMessage);
|
|
63
74
|
}
|
|
64
75
|
require("child_process");
|
|
76
|
+
const external_process_namespaceObject = require("process");
|
|
65
77
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
66
78
|
function getRpcWorkerData() {
|
|
67
79
|
return JSON.parse(external_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
|
package/lib/getIssuesWorker.js
CHANGED
|
@@ -21,20 +21,30 @@ var __webpack_require__ = {};
|
|
|
21
21
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
22
|
})();
|
|
23
23
|
var __webpack_exports__ = {};
|
|
24
|
-
const
|
|
25
|
-
var
|
|
24
|
+
const external_node_process_namespaceObject = require("node:process");
|
|
25
|
+
var external_node_process_default = /*#__PURE__*/ __webpack_require__.n(external_node_process_namespaceObject);
|
|
26
|
+
function isClosedIpcChannelError(error) {
|
|
27
|
+
if ('object' == typeof error && null !== error && 'code' in error) {
|
|
28
|
+
const CLOSED_IPC_ERROR_CODES = new Set([
|
|
29
|
+
'ERR_IPC_CHANNEL_CLOSED',
|
|
30
|
+
'EPIPE'
|
|
31
|
+
]);
|
|
32
|
+
return CLOSED_IPC_ERROR_CODES.has(error.code);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
26
36
|
function exposeRpc(fn) {
|
|
27
37
|
const sendMessage = (message)=>new Promise((resolve, reject)=>{
|
|
28
|
-
if (
|
|
38
|
+
if (external_node_process_default().send) if (external_node_process_default().connected) external_node_process_default().send(message, void 0, void 0, (error)=>{
|
|
29
39
|
if (error) reject(error);
|
|
30
40
|
else resolve(void 0);
|
|
31
41
|
});
|
|
32
|
-
else reject(new Error(`Process ${
|
|
33
|
-
else reject(new Error(`Process ${
|
|
42
|
+
else reject(new Error(`Process ${external_node_process_default().pid} doesn't have open IPC channels`));
|
|
43
|
+
else reject(new Error(`Process ${external_node_process_default().pid} doesn't have IPC channels`));
|
|
34
44
|
});
|
|
35
45
|
const handleMessage = async (message)=>{
|
|
36
46
|
if ('call' === message.type) {
|
|
37
|
-
if (!
|
|
47
|
+
if (!external_node_process_default().send) return;
|
|
38
48
|
let value;
|
|
39
49
|
let error;
|
|
40
50
|
try {
|
|
@@ -54,14 +64,16 @@ function exposeRpc(fn) {
|
|
|
54
64
|
value
|
|
55
65
|
});
|
|
56
66
|
} catch (sendError) {
|
|
67
|
+
if (isClosedIpcChannelError(sendError)) return void console.warn('[type-check] Skipped because the parent process exited. Build may have failed or been interrupted.');
|
|
57
68
|
if (error) console.error(error);
|
|
58
69
|
console.error(sendError);
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
};
|
|
62
|
-
|
|
73
|
+
external_node_process_default().on('message', handleMessage);
|
|
63
74
|
}
|
|
64
75
|
require("child_process");
|
|
76
|
+
const external_process_namespaceObject = require("process");
|
|
65
77
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
66
78
|
function getRpcWorkerData() {
|
|
67
79
|
return JSON.parse(external_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
|
package/lib/index.js
CHANGED
|
@@ -356,7 +356,7 @@ function getPluginHooks(compiler) {
|
|
|
356
356
|
}
|
|
357
357
|
return hooks;
|
|
358
358
|
}
|
|
359
|
-
|
|
359
|
+
require("node:process");
|
|
360
360
|
function createControlledPromise() {
|
|
361
361
|
let resolve = ()=>void 0;
|
|
362
362
|
let reject = ()=>void 0;
|
|
@@ -432,6 +432,7 @@ function uuid() {
|
|
|
432
432
|
return new Array(4).fill(0).map(()=>Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join('-');
|
|
433
433
|
}
|
|
434
434
|
const external_child_process_namespaceObject = require("child_process");
|
|
435
|
+
const external_process_namespaceObject = require("process");
|
|
435
436
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
436
437
|
function createRpcWorker(modulePath, data, memoryLimit) {
|
|
437
438
|
const options = {
|