synckit 0.8.1 → 0.8.4
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 +25 -6
- package/lib/index.cjs +87 -27
- package/lib/index.d.ts +4 -1
- package/lib/index.js +70 -45
- package/lib/index.js.map +1 -1
- package/package.json +4 -119
package/README.md
CHANGED
@@ -19,11 +19,13 @@ Perform async work synchronously in Node.js using `worker_threads` with first-cl
|
|
19
19
|
- [Usage](#usage)
|
20
20
|
- [Install](#install)
|
21
21
|
- [API](#api)
|
22
|
+
- [Options](#options)
|
22
23
|
- [Envs](#envs)
|
23
24
|
- [TypeScript](#typescript)
|
24
25
|
- [`ts-node`](#ts-node)
|
25
26
|
- [`esbuild-register`](#esbuild-register)
|
26
27
|
- [`esbuild-runner`](#esbuild-runner)
|
28
|
+
- [`swc`](#swc)
|
27
29
|
- [`tsx`](#tsx)
|
28
30
|
- [Benchmark](#benchmark)
|
29
31
|
- [Sponsors](#sponsors)
|
@@ -50,7 +52,9 @@ npm i synckit
|
|
50
52
|
import { createSyncFn } from 'synckit'
|
51
53
|
|
52
54
|
// the worker path must be absolute
|
53
|
-
const syncFn = createSyncFn(require.resolve('./worker')
|
55
|
+
const syncFn = createSyncFn(require.resolve('./worker'), {
|
56
|
+
tsRunner: 'tsx', // optional, can be `'ts-node' | 'esbuild-register' | 'esbuild-runner' | 'tsx'`
|
57
|
+
})
|
54
58
|
|
55
59
|
// do whatever you want, you will get the result synchronously!
|
56
60
|
const result = syncFn(...args)
|
@@ -68,12 +72,19 @@ runAsWorker(async (...args) => {
|
|
68
72
|
|
69
73
|
You must make sure, the `result` is serializable by [`Structured Clone Algorithm`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
|
70
74
|
|
75
|
+
### Options
|
76
|
+
|
77
|
+
1. `bufferSize` same as env `SYNCKIT_BUFFER_SIZE`
|
78
|
+
2. `timeout` same as env `SYNCKIT_TIMEOUT`
|
79
|
+
3. `execArgv` same as env `SYNCKIT_EXEC_ARGV`
|
80
|
+
4. `tsRunner` same as env `SYNCKIT_TS_RUNNER`
|
81
|
+
|
71
82
|
### Envs
|
72
83
|
|
73
84
|
1. `SYNCKIT_BUFFER_SIZE`: `bufferSize` to create `SharedArrayBuffer` for `worker_threads` (default as `1024`)
|
74
85
|
2. `SYNCKIT_TIMEOUT`: `timeout` for performing the async job (no default)
|
75
86
|
3. `SYNCKIT_EXEC_ARGV`: List of node CLI options passed to the worker, split with comma `,`. (default as `[]`), see also [`node` docs](https://nodejs.org/api/worker_threads.html)
|
76
|
-
4. `SYNCKIT_TS_RUNNER`: Which TypeScript runner to be used, it could be very useful for development, could be `'ts-node' | 'esbuild-register' | 'esbuild-runner' | 'tsx'`, `'ts-node'` is used by default, make sure you have installed them already
|
87
|
+
4. `SYNCKIT_TS_RUNNER`: Which TypeScript runner to be used, it could be very useful for development, could be `'ts-node' | 'esbuild-register' | 'esbuild-runner' | 'swc' | 'tsx'`, `'ts-node'` is used by default, make sure you have installed them already
|
77
88
|
|
78
89
|
### TypeScript
|
79
90
|
|
@@ -87,15 +98,19 @@ If you want to integrate with [tsconfig-paths](https://www.npmjs.com/package/tsc
|
|
87
98
|
|
88
99
|
#### `esbuild-register`
|
89
100
|
|
90
|
-
Please view
|
101
|
+
Please view [`esbuild-register`][] for its document
|
91
102
|
|
92
103
|
#### `esbuild-runner`
|
93
104
|
|
94
|
-
Please view
|
105
|
+
Please view [`esbuild-runner`][] for its document
|
106
|
+
|
107
|
+
#### `swc`
|
108
|
+
|
109
|
+
Please view [`@swc-node/register`][] for its document
|
95
110
|
|
96
111
|
#### `tsx`
|
97
112
|
|
98
|
-
Please view
|
113
|
+
Please view [`tsx`][] for its document
|
99
114
|
|
100
115
|
## Benchmark
|
101
116
|
|
@@ -117,7 +132,7 @@ You can try it with running `yarn benchmark` by yourself. [Here](./benchmarks/be
|
|
117
132
|
|
118
133
|
| 1stG | RxTS | UnTS |
|
119
134
|
| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
120
|
-
| [](https://opencollective.com/1stG) | [](https://opencollective.com/1stG) | [](https://opencollective.com/rxts) | [](https://opencollective.com/unts) |
|
121
136
|
|
122
137
|
## Changelog
|
123
138
|
|
@@ -127,6 +142,10 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m
|
|
127
142
|
|
128
143
|
[MIT][] © [JounQin][]@[1stG.me][]
|
129
144
|
|
145
|
+
[`esbuild-register`]: https://github.com/egoist/esbuild-register
|
146
|
+
[`esbuild-runner`]: https://github.com/folke/esbuild-runner
|
147
|
+
[`@swc-node/register`]: https://github.com/swc-project/swc-node/tree/master/packages/register
|
148
|
+
[`tsx`]: https://github.com/esbuild-kit/tsx
|
130
149
|
[1stg.me]: https://www.1stg.me
|
131
150
|
[jounqin]: https://GitHub.com/JounQin
|
132
151
|
[mit]: http://opensource.org/licenses/MIT
|
package/lib/index.cjs
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
var fs = require('node:fs');
|
5
6
|
var node_module = require('node:module');
|
6
7
|
var path = require('node:path');
|
7
8
|
var node_url = require('node:url');
|
@@ -10,6 +11,7 @@ var utils = require('@pkgr/utils');
|
|
10
11
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
12
13
|
|
14
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
13
15
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
14
16
|
|
15
17
|
var __async = (__this, __arguments, generator) => {
|
@@ -37,22 +39,24 @@ const TsRunner = {
|
|
37
39
|
TsNode: "ts-node",
|
38
40
|
EsbuildRegister: "esbuild-register",
|
39
41
|
EsbuildRunner: "esbuild-runner",
|
42
|
+
SWC: "swc",
|
40
43
|
TSX: "tsx"
|
41
44
|
};
|
42
45
|
const {
|
43
46
|
SYNCKIT_BUFFER_SIZE,
|
44
47
|
SYNCKIT_TIMEOUT,
|
45
|
-
|
46
|
-
SYNCKIT_TS_RUNNER
|
48
|
+
SYNCKIT_EXEC_ARGV,
|
49
|
+
SYNCKIT_TS_RUNNER,
|
50
|
+
NODE_OPTIONS
|
47
51
|
} = process.env;
|
48
52
|
const DEFAULT_BUFFER_SIZE = SYNCKIT_BUFFER_SIZE ? +SYNCKIT_BUFFER_SIZE : void 0;
|
49
53
|
const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : void 0;
|
50
54
|
const DEFAULT_WORKER_BUFFER_SIZE = DEFAULT_BUFFER_SIZE || 1024;
|
51
|
-
const DEFAULT_EXEC_ARGV = (
|
55
|
+
const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARGV == null ? void 0 : SYNCKIT_EXEC_ARGV.split(",")) || [];
|
52
56
|
const DEFAULT_TS_RUNNER = SYNCKIT_TS_RUNNER || TsRunner.TsNode;
|
53
57
|
const MTS_SUPPORTED_NODE_VERSION = 16;
|
54
58
|
const syncFnCache = /* @__PURE__ */ new Map();
|
55
|
-
|
59
|
+
function extractProperties(object) {
|
56
60
|
if (object && typeof object === "object") {
|
57
61
|
const properties = {};
|
58
62
|
for (const key in object) {
|
@@ -60,7 +64,7 @@ const extractProperties = (object) => {
|
|
60
64
|
}
|
61
65
|
return properties;
|
62
66
|
}
|
63
|
-
}
|
67
|
+
}
|
64
68
|
function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
65
69
|
if (!path__default["default"].isAbsolute(workerPath)) {
|
66
70
|
throw new Error("`workerPath` must be absolute");
|
@@ -69,12 +73,22 @@ function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
|
69
73
|
if (cachedSyncFn) {
|
70
74
|
return cachedSyncFn;
|
71
75
|
}
|
72
|
-
const syncFn = startWorkerThread(
|
76
|
+
const syncFn = startWorkerThread(
|
77
|
+
workerPath,
|
78
|
+
typeof bufferSizeOrOptions === "number" ? { bufferSize: bufferSizeOrOptions, timeout } : bufferSizeOrOptions
|
79
|
+
);
|
73
80
|
syncFnCache.set(workerPath, syncFn);
|
74
81
|
return syncFn;
|
75
82
|
}
|
76
83
|
const cjsRequire = typeof require === "undefined" ? node_module.createRequire(import_meta.url) : require;
|
77
84
|
const dataUrl = (code) => new URL(`data:text/javascript,${encodeURIComponent(code)}`);
|
85
|
+
const isFile = (path2) => {
|
86
|
+
try {
|
87
|
+
return fs__default["default"].statSync(path2).isFile();
|
88
|
+
} catch (e) {
|
89
|
+
return false;
|
90
|
+
}
|
91
|
+
};
|
78
92
|
const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
79
93
|
let ext = path__default["default"].extname(workerPath);
|
80
94
|
if (!/[/\\]node_modules[/\\]/.test(workerPath) && (!ext || /^\.[cm]?js$/.test(ext))) {
|
@@ -132,6 +146,12 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
132
146
|
}
|
133
147
|
break;
|
134
148
|
}
|
149
|
+
case TsRunner.SWC: {
|
150
|
+
if (!execArgv.includes("-r")) {
|
151
|
+
execArgv = ["-r", `@${TsRunner.SWC}-node/register`, ...execArgv];
|
152
|
+
}
|
153
|
+
break;
|
154
|
+
}
|
135
155
|
case TsRunner.TSX: {
|
136
156
|
if (!execArgv.includes("--loader")) {
|
137
157
|
execArgv = ["--loader", TsRunner.TSX, ...execArgv];
|
@@ -143,6 +163,23 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
143
163
|
}
|
144
164
|
}
|
145
165
|
}
|
166
|
+
if (process.versions.pnp) {
|
167
|
+
const nodeOptions = NODE_OPTIONS == null ? void 0 : NODE_OPTIONS.split(/\s+/);
|
168
|
+
let pnpApiPath;
|
169
|
+
try {
|
170
|
+
pnpApiPath = cjsRequire.resolve("pnpapi");
|
171
|
+
} catch (e) {
|
172
|
+
}
|
173
|
+
if (pnpApiPath && !(nodeOptions == null ? void 0 : nodeOptions.some(
|
174
|
+
(option, index) => ["-r", "--require"].includes(option) && pnpApiPath === cjsRequire.resolve(nodeOptions[index + 1])
|
175
|
+
)) && !execArgv.includes(pnpApiPath)) {
|
176
|
+
execArgv = ["-r", pnpApiPath, ...execArgv];
|
177
|
+
const pnpLoaderPath = path__default["default"].resolve(pnpApiPath, "../.pnp.loader.mjs");
|
178
|
+
if (isFile(pnpLoaderPath)) {
|
179
|
+
execArgv = ["--experimental-loader", pnpLoaderPath, ...execArgv];
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
146
183
|
return {
|
147
184
|
ext,
|
148
185
|
isTs,
|
@@ -171,18 +208,24 @@ function startWorkerThread(workerPath, {
|
|
171
208
|
if ([
|
172
209
|
TsRunner.EsbuildRegister,
|
173
210
|
TsRunner.EsbuildRunner,
|
211
|
+
TsRunner.SWC,
|
174
212
|
...isTsxSupported ? [] : [TsRunner.TSX]
|
175
213
|
].includes(tsRunner)) {
|
176
|
-
throw new Error(
|
214
|
+
throw new Error(
|
215
|
+
`${tsRunner} is not supported for ${ext} files yet` + (isTsxSupported ? ", you can try [tsx](https://github.com/esbuild-kit/tsx) instead" : "")
|
216
|
+
);
|
177
217
|
}
|
178
218
|
}
|
179
219
|
const useEval = isTs && !tsUseEsm;
|
180
|
-
const worker = new node_worker_threads.Worker(
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
220
|
+
const worker = new node_worker_threads.Worker(
|
221
|
+
tsUseEsm && tsRunner === TsRunner.TsNode ? dataUrl(`import '${String(workerPathUrl)}'`) : useEval ? `require('${finalWorkerPath.replace(/\\/g, "\\\\")}')` : workerPathUrl,
|
222
|
+
{
|
223
|
+
eval: useEval,
|
224
|
+
workerData: { workerPort },
|
225
|
+
transferList: [workerPort],
|
226
|
+
execArgv: finalExecArgv
|
227
|
+
}
|
228
|
+
);
|
186
229
|
let nextID = 0;
|
187
230
|
const syncFn = (...args) => {
|
188
231
|
const id = nextID++;
|
@@ -216,24 +259,40 @@ function runAsWorker(fn) {
|
|
216
259
|
return;
|
217
260
|
}
|
218
261
|
const { workerPort } = node_worker_threads.workerData;
|
219
|
-
|
220
|
-
(
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
262
|
+
try {
|
263
|
+
node_worker_threads.parentPort.on(
|
264
|
+
"message",
|
265
|
+
({ sharedBuffer, id, args }) => {
|
266
|
+
;
|
267
|
+
(() => __async(this, null, function* () {
|
268
|
+
const sharedBufferView = new Int32Array(sharedBuffer);
|
269
|
+
let msg;
|
270
|
+
try {
|
271
|
+
msg = { id, result: yield fn(...args) };
|
272
|
+
} catch (error) {
|
273
|
+
msg = { id, error, properties: extractProperties(error) };
|
274
|
+
}
|
275
|
+
workerPort.postMessage(msg);
|
276
|
+
Atomics.add(sharedBufferView, 0, 1);
|
277
|
+
Atomics.notify(sharedBufferView, 0);
|
278
|
+
}))();
|
279
|
+
}
|
280
|
+
);
|
281
|
+
} catch (error) {
|
282
|
+
node_worker_threads.parentPort.on(
|
283
|
+
"message",
|
284
|
+
({ sharedBuffer, id }) => {
|
285
|
+
const sharedBufferView = new Int32Array(sharedBuffer);
|
286
|
+
workerPort.postMessage({
|
227
287
|
id,
|
228
288
|
error,
|
229
289
|
properties: extractProperties(error)
|
230
|
-
};
|
290
|
+
});
|
291
|
+
Atomics.add(sharedBufferView, 0, 1);
|
292
|
+
Atomics.notify(sharedBufferView, 0);
|
231
293
|
}
|
232
|
-
|
233
|
-
|
234
|
-
Atomics.notify(sharedBufferView, 0);
|
235
|
-
}))();
|
236
|
-
});
|
294
|
+
);
|
295
|
+
}
|
237
296
|
}
|
238
297
|
|
239
298
|
exports.DEFAULT_BUFFER_SIZE = DEFAULT_BUFFER_SIZE;
|
@@ -245,4 +304,5 @@ exports.MTS_SUPPORTED_NODE_VERSION = MTS_SUPPORTED_NODE_VERSION;
|
|
245
304
|
exports.TsRunner = TsRunner;
|
246
305
|
exports.createSyncFn = createSyncFn;
|
247
306
|
exports.extractProperties = extractProperties;
|
307
|
+
exports.isFile = isFile;
|
248
308
|
exports.runAsWorker = runAsWorker;
|
package/lib/index.d.ts
CHANGED
@@ -4,6 +4,7 @@ export declare const TsRunner: {
|
|
4
4
|
readonly TsNode: "ts-node";
|
5
5
|
readonly EsbuildRegister: "esbuild-register";
|
6
6
|
readonly EsbuildRunner: "esbuild-runner";
|
7
|
+
readonly SWC: "swc";
|
7
8
|
readonly TSX: "tsx";
|
8
9
|
};
|
9
10
|
export declare type TsRunner = ValueOf<typeof TsRunner>;
|
@@ -19,7 +20,9 @@ export interface SynckitOptions {
|
|
19
20
|
execArgv?: string[];
|
20
21
|
tsRunner?: TsRunner;
|
21
22
|
}
|
22
|
-
export declare
|
23
|
+
export declare function extractProperties<T extends object>(object: T): T;
|
24
|
+
export declare function extractProperties<T>(object?: T): T | undefined;
|
23
25
|
export declare function createSyncFn<T extends AnyAsyncFn>(workerPath: string, bufferSize?: number, timeout?: number): Syncify<T>;
|
24
26
|
export declare function createSyncFn<T extends AnyAsyncFn>(workerPath: string, options?: SynckitOptions): Syncify<T>;
|
27
|
+
export declare const isFile: (path: string) => boolean;
|
25
28
|
export declare function runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void;
|
package/lib/index.js
CHANGED
@@ -1,38 +1,30 @@
|
|
1
1
|
import { __awaiter } from "tslib";
|
2
|
+
import fs from 'node:fs';
|
2
3
|
import { createRequire } from 'node:module';
|
3
4
|
import path from 'node:path';
|
4
5
|
import { pathToFileURL } from 'node:url';
|
5
|
-
import { MessageChannel, Worker, receiveMessageOnPort,
|
6
|
-
// type-coverage:ignore-next-line -- we can't control
|
7
|
-
workerData, parentPort, } from 'node:worker_threads';
|
6
|
+
import { MessageChannel, Worker, receiveMessageOnPort, workerData, parentPort, } from 'node:worker_threads';
|
8
7
|
import { findUp, tryExtensions } from '@pkgr/utils';
|
9
8
|
export * from './types.js';
|
10
9
|
export const TsRunner = {
|
11
|
-
// https://github.com/TypeStrong/ts-node
|
12
10
|
TsNode: 'ts-node',
|
13
|
-
// https://github.com/egoist/esbuild-register
|
14
11
|
EsbuildRegister: 'esbuild-register',
|
15
|
-
// https://github.com/folke/esbuild-runner
|
16
12
|
EsbuildRunner: 'esbuild-runner',
|
17
|
-
|
13
|
+
SWC: 'swc',
|
18
14
|
TSX: 'tsx',
|
19
15
|
};
|
20
|
-
const { SYNCKIT_BUFFER_SIZE, SYNCKIT_TIMEOUT,
|
16
|
+
const { SYNCKIT_BUFFER_SIZE, SYNCKIT_TIMEOUT, SYNCKIT_EXEC_ARGV, SYNCKIT_TS_RUNNER, NODE_OPTIONS, } = process.env;
|
21
17
|
export const DEFAULT_BUFFER_SIZE = SYNCKIT_BUFFER_SIZE
|
22
18
|
? +SYNCKIT_BUFFER_SIZE
|
23
19
|
: undefined;
|
24
20
|
export const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : undefined;
|
25
21
|
export const DEFAULT_WORKER_BUFFER_SIZE = DEFAULT_BUFFER_SIZE || 1024;
|
26
|
-
|
27
|
-
export const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARV === null || SYNCKIT_EXEC_ARV === void 0 ? void 0 : SYNCKIT_EXEC_ARV.split(',')) || [];
|
22
|
+
export const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARGV === null || SYNCKIT_EXEC_ARGV === void 0 ? void 0 : SYNCKIT_EXEC_ARGV.split(',')) || [];
|
28
23
|
export const DEFAULT_TS_RUNNER = (SYNCKIT_TS_RUNNER ||
|
29
24
|
TsRunner.TsNode);
|
30
25
|
export const MTS_SUPPORTED_NODE_VERSION = 16;
|
31
26
|
const syncFnCache = new Map();
|
32
|
-
|
33
|
-
// error objects to have extra properties such as "warnings" so implement the
|
34
|
-
// property copying manually.
|
35
|
-
export const extractProperties = (object) => {
|
27
|
+
export function extractProperties(object) {
|
36
28
|
if (object && typeof object === 'object') {
|
37
29
|
const properties = {};
|
38
30
|
for (const key in object) {
|
@@ -40,7 +32,7 @@ export const extractProperties = (object) => {
|
|
40
32
|
}
|
41
33
|
return properties;
|
42
34
|
}
|
43
|
-
}
|
35
|
+
}
|
44
36
|
export function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
45
37
|
if (!path.isAbsolute(workerPath)) {
|
46
38
|
throw new Error('`workerPath` must be absolute');
|
@@ -49,8 +41,7 @@ export function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
|
49
41
|
if (cachedSyncFn) {
|
50
42
|
return cachedSyncFn;
|
51
43
|
}
|
52
|
-
const syncFn = startWorkerThread(workerPath,
|
53
|
-
/* istanbul ignore next */ typeof bufferSizeOrOptions === 'number'
|
44
|
+
const syncFn = startWorkerThread(workerPath, typeof bufferSizeOrOptions === 'number'
|
54
45
|
? { bufferSize: bufferSizeOrOptions, timeout }
|
55
46
|
: bufferSizeOrOptions);
|
56
47
|
syncFnCache.set(workerPath, syncFn);
|
@@ -58,8 +49,16 @@ export function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
|
58
49
|
}
|
59
50
|
const cjsRequire = typeof require === 'undefined'
|
60
51
|
? createRequire(import.meta.url)
|
61
|
-
:
|
52
|
+
: require;
|
62
53
|
const dataUrl = (code) => new URL(`data:text/javascript,${encodeURIComponent(code)}`);
|
54
|
+
export const isFile = (path) => {
|
55
|
+
try {
|
56
|
+
return fs.statSync(path).isFile();
|
57
|
+
}
|
58
|
+
catch (_a) {
|
59
|
+
return false;
|
60
|
+
}
|
61
|
+
};
|
63
62
|
const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
64
63
|
let ext = path.extname(workerPath);
|
65
64
|
if (!/[/\\]node_modules[/\\]/.test(workerPath) &&
|
@@ -123,6 +122,12 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
123
122
|
}
|
124
123
|
break;
|
125
124
|
}
|
125
|
+
case TsRunner.SWC: {
|
126
|
+
if (!execArgv.includes('-r')) {
|
127
|
+
execArgv = ['-r', `@${TsRunner.SWC}-node/register`, ...execArgv];
|
128
|
+
}
|
129
|
+
break;
|
130
|
+
}
|
126
131
|
case TsRunner.TSX: {
|
127
132
|
if (!execArgv.includes('--loader')) {
|
128
133
|
execArgv = ['--loader', TsRunner.TSX, ...execArgv];
|
@@ -134,6 +139,24 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
134
139
|
}
|
135
140
|
}
|
136
141
|
}
|
142
|
+
if (process.versions.pnp) {
|
143
|
+
const nodeOptions = NODE_OPTIONS === null || NODE_OPTIONS === void 0 ? void 0 : NODE_OPTIONS.split(/\s+/);
|
144
|
+
let pnpApiPath;
|
145
|
+
try {
|
146
|
+
pnpApiPath = cjsRequire.resolve('pnpapi');
|
147
|
+
}
|
148
|
+
catch (_a) { }
|
149
|
+
if (pnpApiPath &&
|
150
|
+
!(nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.some((option, index) => ['-r', '--require'].includes(option) &&
|
151
|
+
pnpApiPath === cjsRequire.resolve(nodeOptions[index + 1]))) &&
|
152
|
+
!execArgv.includes(pnpApiPath)) {
|
153
|
+
execArgv = ['-r', pnpApiPath, ...execArgv];
|
154
|
+
const pnpLoaderPath = path.resolve(pnpApiPath, '../.pnp.loader.mjs');
|
155
|
+
if (isFile(pnpLoaderPath)) {
|
156
|
+
execArgv = ['--experimental-loader', pnpLoaderPath, ...execArgv];
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
137
160
|
return {
|
138
161
|
ext,
|
139
162
|
isTs,
|
@@ -142,7 +165,6 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
142
165
|
execArgv,
|
143
166
|
};
|
144
167
|
};
|
145
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
146
168
|
function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE, timeout = DEFAULT_TIMEOUT, execArgv = DEFAULT_EXEC_ARGV, tsRunner = DEFAULT_TS_RUNNER, } = {}) {
|
147
169
|
const { port1: mainPort, port2: workerPort } = new MessageChannel();
|
148
170
|
const { isTs, ext, tsUseEsm, workerPath: finalWorkerPath, execArgv: finalExecArgv, } = setupTsRunner(workerPath, { execArgv, tsRunner });
|
@@ -150,13 +172,11 @@ function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE
|
|
150
172
|
if (/\.[cm]ts$/.test(finalWorkerPath)) {
|
151
173
|
const isTsxSupported = !tsUseEsm ||
|
152
174
|
Number.parseFloat(process.versions.node) >= MTS_SUPPORTED_NODE_VERSION;
|
153
|
-
/* istanbul ignore if */
|
154
175
|
if ([
|
155
|
-
// https://github.com/egoist/esbuild-register/issues/79
|
156
176
|
TsRunner.EsbuildRegister,
|
157
|
-
// https://github.com/folke/esbuild-runner/issues/67
|
158
177
|
TsRunner.EsbuildRunner,
|
159
|
-
|
178
|
+
TsRunner.SWC,
|
179
|
+
...(isTsxSupported ? [] : [TsRunner.TSX]),
|
160
180
|
].includes(tsRunner)) {
|
161
181
|
throw new Error(`${tsRunner} is not supported for ${ext} files yet` +
|
162
182
|
(isTsxSupported
|
@@ -183,13 +203,11 @@ function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE
|
|
183
203
|
const msg = { sharedBuffer, id, args };
|
184
204
|
worker.postMessage(msg);
|
185
205
|
const status = Atomics.wait(sharedBufferView, 0, 0, timeout);
|
186
|
-
/* istanbul ignore if */
|
187
206
|
if (!['ok', 'not-equal'].includes(status)) {
|
188
207
|
throw new Error('Internal error: Atomics.wait() failed: ' + status);
|
189
208
|
}
|
190
209
|
const { id: id2, result, error, properties, } = receiveMessageOnPort(mainPort)
|
191
210
|
.message;
|
192
|
-
/* istanbul ignore if */
|
193
211
|
if (id !== id2) {
|
194
212
|
throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
195
213
|
}
|
@@ -201,33 +219,40 @@ function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE
|
|
201
219
|
worker.unref();
|
202
220
|
return syncFn;
|
203
221
|
}
|
204
|
-
/* istanbul ignore next */
|
205
222
|
export function runAsWorker(fn) {
|
206
|
-
// type-coverage:ignore-next-line -- we can't control
|
207
223
|
if (!workerData) {
|
208
224
|
return;
|
209
225
|
}
|
210
226
|
const { workerPort } = workerData;
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
227
|
+
try {
|
228
|
+
parentPort.on('message', ({ sharedBuffer, id, args }) => {
|
229
|
+
;
|
230
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
231
|
+
const sharedBufferView = new Int32Array(sharedBuffer);
|
232
|
+
let msg;
|
233
|
+
try {
|
234
|
+
msg = { id, result: yield fn(...args) };
|
235
|
+
}
|
236
|
+
catch (error) {
|
237
|
+
msg = { id, error, properties: extractProperties(error) };
|
238
|
+
}
|
239
|
+
workerPort.postMessage(msg);
|
240
|
+
Atomics.add(sharedBufferView, 0, 1);
|
241
|
+
Atomics.notify(sharedBufferView, 0);
|
242
|
+
}))();
|
243
|
+
});
|
244
|
+
}
|
245
|
+
catch (error) {
|
246
|
+
parentPort.on('message', ({ sharedBuffer, id }) => {
|
215
247
|
const sharedBufferView = new Int32Array(sharedBuffer);
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
msg = {
|
222
|
-
id,
|
223
|
-
error,
|
224
|
-
properties: extractProperties(error),
|
225
|
-
};
|
226
|
-
}
|
227
|
-
workerPort.postMessage(msg);
|
248
|
+
workerPort.postMessage({
|
249
|
+
id,
|
250
|
+
error,
|
251
|
+
properties: extractProperties(error),
|
252
|
+
});
|
228
253
|
Atomics.add(sharedBufferView, 0, 1);
|
229
254
|
Atomics.notify(sharedBufferView, 0);
|
230
|
-
})
|
231
|
-
}
|
255
|
+
});
|
256
|
+
}
|
232
257
|
}
|
233
258
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EACL,cAAc,EACd,MAAM,EACN,oBAAoB
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EACL,cAAc,EACd,MAAM,EACN,oBAAoB,EAEpB,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAYnD,cAAc,YAAY,CAAA;AAE1B,MAAM,CAAC,MAAM,QAAQ,GAAG;IAEtB,MAAM,EAAE,SAAS;IAEjB,eAAe,EAAE,kBAAkB;IAEnC,aAAa,EAAE,gBAAgB;IAE/B,GAAG,EAAE,KAAK;IAEV,GAAG,EAAE,KAAK;CACF,CAAA;AAIV,MAAM,EACJ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,GACb,GAAG,OAAO,CAAC,GAAG,CAAA;AAEf,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB;IACpD,CAAC,CAAC,CAAC,mBAAmB;IACtB,CAAC,CAAC,SAAS,CAAA;AAEb,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAA;AAE7E,MAAM,CAAC,MAAM,0B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GAA2B,CAAA;gBAC/B,IAAI;oBACF,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;iBACxC;gBAAC,OAAO,KAAc,EAAE;oBACvB,GAAG,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAA;iBAC1D;gBACD,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;gBAC3B,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;gBACnC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;YACrC,CAAC,CAAA,CAAC,EAAE,CAAA;QACN,CAAC,CACF,CAAA;KASF;IAAC,OAAO,KAAK,EAAE;QACd,UAAW,CAAC,EAAE,CACZ,SAAS,EACT,CAAC,EAAE,YAAY,EAAE,EAAE,EAAsC,EAAE,EAAE;YAC3D,MAAM,gBAAgB,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,CAAA;YACrD,UAAU,CAAC,WAAW,CAAC;gBACrB,EAAE;gBACF,KAAK;gBACL,UAAU,EAAE,iBAAiB,CAAC,KAAK,CAAC;aACrC,CAAC,CAAA;YACF,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YACnC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;QACrC,CAAC,CACF,CAAA;KACF;AACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,41 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "synckit",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.4",
|
4
4
|
"type": "module",
|
5
5
|
"description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.",
|
6
|
-
"repository": "git+https://github.com/
|
6
|
+
"repository": "git+https://github.com/un-ts/synckit.git",
|
7
7
|
"author": "JounQin (https://www.1stG.me) <admin@1stg.me>",
|
8
|
-
"donate": {
|
9
|
-
"recipients": [
|
10
|
-
{
|
11
|
-
"name": "unts",
|
12
|
-
"platform": "opencollective",
|
13
|
-
"address": "https://opencollective.com/unts",
|
14
|
-
"weight": 60
|
15
|
-
},
|
16
|
-
{
|
17
|
-
"name": "rxts",
|
18
|
-
"platform": "opencollective",
|
19
|
-
"address": "https://opencollective.com/rxts",
|
20
|
-
"weight": 20
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"name": "1stG",
|
24
|
-
"email": "i@1stg.me",
|
25
|
-
"weight": 20,
|
26
|
-
"platforms": [
|
27
|
-
{
|
28
|
-
"platform": "opencollective",
|
29
|
-
"address": "https://opencollective.com/1stG"
|
30
|
-
},
|
31
|
-
{
|
32
|
-
"platform": "patreon",
|
33
|
-
"address": "https://www.patreon.com/1stG"
|
34
|
-
}
|
35
|
-
]
|
36
|
-
}
|
37
|
-
]
|
38
|
-
},
|
39
8
|
"funding": "https://opencollective.com/unts",
|
40
9
|
"license": "MIT",
|
41
10
|
"engines": {
|
@@ -63,92 +32,8 @@
|
|
63
32
|
"synchronize",
|
64
33
|
"synckit"
|
65
34
|
],
|
66
|
-
"scripts": {
|
67
|
-
"benchmark": "run-s benchmark:*",
|
68
|
-
"benchmark-export": "run-s benchmark-export:*",
|
69
|
-
"benchmark-export:cjs": "yarn benchmark:cjs > benchmarks/benchmark.cjs.txt",
|
70
|
-
"benchmark-export:esm": "yarn benchmark:esm> benchmarks/benchmark.esm.txt",
|
71
|
-
"benchmark:cjs": "node benchmarks/benchmark.cjs",
|
72
|
-
"benchmark:esm": "node benchmarks/benchmark.js",
|
73
|
-
"build": "run-p build:*",
|
74
|
-
"build:r": "r -f cjs",
|
75
|
-
"build:ts": "tsc -p src",
|
76
|
-
"lint": "run-p lint:*",
|
77
|
-
"lint:es": "eslint . --cache -f friendly --max-warnings 10",
|
78
|
-
"lint:tsc": "tsc --noEmit",
|
79
|
-
"prepare": "patch-package && simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
|
80
|
-
"prerelease": "yarn build",
|
81
|
-
"release": "changeset publish",
|
82
|
-
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
83
|
-
"typecov": "type-coverage"
|
84
|
-
},
|
85
35
|
"dependencies": {
|
86
|
-
"@pkgr/utils": "^2.3.
|
36
|
+
"@pkgr/utils": "^2.3.1",
|
87
37
|
"tslib": "^2.4.0"
|
88
|
-
},
|
89
|
-
"devDependencies": {
|
90
|
-
"@1stg/lib-config": "^9.0.0",
|
91
|
-
"@changesets/changelog-github": "^0.4.5",
|
92
|
-
"@changesets/cli": "^2.23.2",
|
93
|
-
"@types/jest": "^28.1.5",
|
94
|
-
"@types/node": "^18.0.4",
|
95
|
-
"deasync": "^0.1.27",
|
96
|
-
"esbuild-register": "^3.3.3",
|
97
|
-
"esbuild-runner": "^2.2.1",
|
98
|
-
"jest": "^28.1.3",
|
99
|
-
"patch-package": "^6.4.7",
|
100
|
-
"sync-threads": "^1.0.1",
|
101
|
-
"ts-expect": "^1.3.0",
|
102
|
-
"ts-jest": "^28.0.6",
|
103
|
-
"ts-node": "^10.9.1",
|
104
|
-
"tsx": "^3.8.0",
|
105
|
-
"type-coverage": "^2.22.0",
|
106
|
-
"typescript": "^4.7.4",
|
107
|
-
"yarn-deduplicate": "^5.0.0"
|
108
|
-
},
|
109
|
-
"resolutions": {
|
110
|
-
"prettier": "^2.7.1"
|
111
|
-
},
|
112
|
-
"commitlint": {
|
113
|
-
"extends": "@1stg"
|
114
|
-
},
|
115
|
-
"jest": {
|
116
|
-
"preset": "ts-jest",
|
117
|
-
"testEnvironment": "node",
|
118
|
-
"collectCoverage": true,
|
119
|
-
"extensionsToTreatAsEsm": [
|
120
|
-
".ts"
|
121
|
-
],
|
122
|
-
"moduleNameMapper": {
|
123
|
-
"^(\\.{1,2}/.*)\\.js$": "$1",
|
124
|
-
"^synckit$": "<rootDir>/src"
|
125
|
-
},
|
126
|
-
"globals": {
|
127
|
-
"ts-jest": {
|
128
|
-
"useESM": true,
|
129
|
-
"tsconfig": {
|
130
|
-
"importHelpers": false
|
131
|
-
}
|
132
|
-
}
|
133
|
-
}
|
134
|
-
},
|
135
|
-
"prettier": "@1stg/prettier-config",
|
136
|
-
"renovate": {
|
137
|
-
"extends": [
|
138
|
-
"@1stg"
|
139
|
-
]
|
140
|
-
},
|
141
|
-
"typeCoverage": {
|
142
|
-
"atLeast": 100,
|
143
|
-
"cache": true,
|
144
|
-
"detail": true,
|
145
|
-
"ignoreAsAssertion": true,
|
146
|
-
"ignoreFiles": [
|
147
|
-
"**/*.d.ts"
|
148
|
-
],
|
149
|
-
"ignoreNonNullAssertion": true,
|
150
|
-
"showRelativePath": true,
|
151
|
-
"strict": true,
|
152
|
-
"update": true
|
153
38
|
}
|
154
|
-
}
|
39
|
+
}
|