synckit 0.8.3 → 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/lib/index.cjs +55 -35
- package/lib/index.d.ts +2 -1
- package/lib/index.js +14 -39
- package/lib/index.js.map +1 -1
- package/package.json +3 -121
package/lib/index.cjs
CHANGED
@@ -56,7 +56,7 @@ const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARGV == null ? void 0 : SYNCKIT_EXEC_ARG
|
|
56
56
|
const DEFAULT_TS_RUNNER = SYNCKIT_TS_RUNNER || TsRunner.TsNode;
|
57
57
|
const MTS_SUPPORTED_NODE_VERSION = 16;
|
58
58
|
const syncFnCache = /* @__PURE__ */ new Map();
|
59
|
-
|
59
|
+
function extractProperties(object) {
|
60
60
|
if (object && typeof object === "object") {
|
61
61
|
const properties = {};
|
62
62
|
for (const key in object) {
|
@@ -64,7 +64,7 @@ const extractProperties = (object) => {
|
|
64
64
|
}
|
65
65
|
return properties;
|
66
66
|
}
|
67
|
-
}
|
67
|
+
}
|
68
68
|
function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
69
69
|
if (!path__default["default"].isAbsolute(workerPath)) {
|
70
70
|
throw new Error("`workerPath` must be absolute");
|
@@ -73,7 +73,10 @@ function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
|
73
73
|
if (cachedSyncFn) {
|
74
74
|
return cachedSyncFn;
|
75
75
|
}
|
76
|
-
const syncFn = startWorkerThread(
|
76
|
+
const syncFn = startWorkerThread(
|
77
|
+
workerPath,
|
78
|
+
typeof bufferSizeOrOptions === "number" ? { bufferSize: bufferSizeOrOptions, timeout } : bufferSizeOrOptions
|
79
|
+
);
|
77
80
|
syncFnCache.set(workerPath, syncFn);
|
78
81
|
return syncFn;
|
79
82
|
}
|
@@ -162,8 +165,14 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
162
165
|
}
|
163
166
|
if (process.versions.pnp) {
|
164
167
|
const nodeOptions = NODE_OPTIONS == null ? void 0 : NODE_OPTIONS.split(/\s+/);
|
165
|
-
|
166
|
-
|
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)) {
|
167
176
|
execArgv = ["-r", pnpApiPath, ...execArgv];
|
168
177
|
const pnpLoaderPath = path__default["default"].resolve(pnpApiPath, "../.pnp.loader.mjs");
|
169
178
|
if (isFile(pnpLoaderPath)) {
|
@@ -202,16 +211,21 @@ function startWorkerThread(workerPath, {
|
|
202
211
|
TsRunner.SWC,
|
203
212
|
...isTsxSupported ? [] : [TsRunner.TSX]
|
204
213
|
].includes(tsRunner)) {
|
205
|
-
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
|
+
);
|
206
217
|
}
|
207
218
|
}
|
208
219
|
const useEval = isTs && !tsUseEsm;
|
209
|
-
const worker = new node_worker_threads.Worker(
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
+
);
|
215
229
|
let nextID = 0;
|
216
230
|
const syncFn = (...args) => {
|
217
231
|
const id = nextID++;
|
@@ -246,32 +260,38 @@ function runAsWorker(fn) {
|
|
246
260
|
}
|
247
261
|
const { workerPort } = node_worker_threads.workerData;
|
248
262
|
try {
|
249
|
-
node_worker_threads.parentPort.on(
|
250
|
-
|
251
|
-
(
|
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 }) => {
|
252
285
|
const sharedBufferView = new Int32Array(sharedBuffer);
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
}
|
259
|
-
workerPort.postMessage(msg);
|
286
|
+
workerPort.postMessage({
|
287
|
+
id,
|
288
|
+
error,
|
289
|
+
properties: extractProperties(error)
|
290
|
+
});
|
260
291
|
Atomics.add(sharedBufferView, 0, 1);
|
261
292
|
Atomics.notify(sharedBufferView, 0);
|
262
|
-
}
|
263
|
-
|
264
|
-
} catch (error) {
|
265
|
-
node_worker_threads.parentPort.on("message", ({ sharedBuffer, id }) => {
|
266
|
-
const sharedBufferView = new Int32Array(sharedBuffer);
|
267
|
-
workerPort.postMessage({
|
268
|
-
id,
|
269
|
-
error,
|
270
|
-
properties: extractProperties(error)
|
271
|
-
});
|
272
|
-
Atomics.add(sharedBufferView, 0, 1);
|
273
|
-
Atomics.notify(sharedBufferView, 0);
|
274
|
-
});
|
293
|
+
}
|
294
|
+
);
|
275
295
|
}
|
276
296
|
}
|
277
297
|
|
package/lib/index.d.ts
CHANGED
@@ -20,7 +20,8 @@ export interface SynckitOptions {
|
|
20
20
|
execArgv?: string[];
|
21
21
|
tsRunner?: TsRunner;
|
22
22
|
}
|
23
|
-
export declare
|
23
|
+
export declare function extractProperties<T extends object>(object: T): T;
|
24
|
+
export declare function extractProperties<T>(object?: T): T | undefined;
|
24
25
|
export declare function createSyncFn<T extends AnyAsyncFn>(workerPath: string, bufferSize?: number, timeout?: number): Syncify<T>;
|
25
26
|
export declare function createSyncFn<T extends AnyAsyncFn>(workerPath: string, options?: SynckitOptions): Syncify<T>;
|
26
27
|
export declare const isFile: (path: string) => boolean;
|
package/lib/index.js
CHANGED
@@ -3,21 +3,14 @@ import fs from 'node:fs';
|
|
3
3
|
import { createRequire } from 'node:module';
|
4
4
|
import path from 'node:path';
|
5
5
|
import { pathToFileURL } from 'node:url';
|
6
|
-
import { MessageChannel, Worker, receiveMessageOnPort,
|
7
|
-
// type-coverage:ignore-next-line -- we can't control
|
8
|
-
workerData, parentPort, } from 'node:worker_threads';
|
6
|
+
import { MessageChannel, Worker, receiveMessageOnPort, workerData, parentPort, } from 'node:worker_threads';
|
9
7
|
import { findUp, tryExtensions } from '@pkgr/utils';
|
10
8
|
export * from './types.js';
|
11
9
|
export const TsRunner = {
|
12
|
-
// https://github.com/TypeStrong/ts-node
|
13
10
|
TsNode: 'ts-node',
|
14
|
-
// https://github.com/egoist/esbuild-register
|
15
11
|
EsbuildRegister: 'esbuild-register',
|
16
|
-
// https://github.com/folke/esbuild-runner
|
17
12
|
EsbuildRunner: 'esbuild-runner',
|
18
|
-
// https://github.com/swc-project/swc-node/tree/master/packages/register
|
19
13
|
SWC: 'swc',
|
20
|
-
// https://github.com/esbuild-kit/tsx
|
21
14
|
TSX: 'tsx',
|
22
15
|
};
|
23
16
|
const { SYNCKIT_BUFFER_SIZE, SYNCKIT_TIMEOUT, SYNCKIT_EXEC_ARGV, SYNCKIT_TS_RUNNER, NODE_OPTIONS, } = process.env;
|
@@ -26,16 +19,12 @@ export const DEFAULT_BUFFER_SIZE = SYNCKIT_BUFFER_SIZE
|
|
26
19
|
: undefined;
|
27
20
|
export const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : undefined;
|
28
21
|
export const DEFAULT_WORKER_BUFFER_SIZE = DEFAULT_BUFFER_SIZE || 1024;
|
29
|
-
/* istanbul ignore next */
|
30
22
|
export const DEFAULT_EXEC_ARGV = (SYNCKIT_EXEC_ARGV === null || SYNCKIT_EXEC_ARGV === void 0 ? void 0 : SYNCKIT_EXEC_ARGV.split(',')) || [];
|
31
23
|
export const DEFAULT_TS_RUNNER = (SYNCKIT_TS_RUNNER ||
|
32
24
|
TsRunner.TsNode);
|
33
25
|
export const MTS_SUPPORTED_NODE_VERSION = 16;
|
34
26
|
const syncFnCache = new Map();
|
35
|
-
|
36
|
-
// error objects to have extra properties such as "warnings" so implement the
|
37
|
-
// property copying manually.
|
38
|
-
export const extractProperties = (object) => {
|
27
|
+
export function extractProperties(object) {
|
39
28
|
if (object && typeof object === 'object') {
|
40
29
|
const properties = {};
|
41
30
|
for (const key in object) {
|
@@ -43,7 +32,7 @@ export const extractProperties = (object) => {
|
|
43
32
|
}
|
44
33
|
return properties;
|
45
34
|
}
|
46
|
-
}
|
35
|
+
}
|
47
36
|
export function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
48
37
|
if (!path.isAbsolute(workerPath)) {
|
49
38
|
throw new Error('`workerPath` must be absolute');
|
@@ -52,8 +41,7 @@ export function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
|
52
41
|
if (cachedSyncFn) {
|
53
42
|
return cachedSyncFn;
|
54
43
|
}
|
55
|
-
const syncFn = startWorkerThread(workerPath,
|
56
|
-
/* istanbul ignore next */ typeof bufferSizeOrOptions === 'number'
|
44
|
+
const syncFn = startWorkerThread(workerPath, typeof bufferSizeOrOptions === 'number'
|
57
45
|
? { bufferSize: bufferSizeOrOptions, timeout }
|
58
46
|
: bufferSizeOrOptions);
|
59
47
|
syncFnCache.set(workerPath, syncFn);
|
@@ -61,7 +49,7 @@ export function createSyncFn(workerPath, bufferSizeOrOptions, timeout) {
|
|
61
49
|
}
|
62
50
|
const cjsRequire = typeof require === 'undefined'
|
63
51
|
? createRequire(import.meta.url)
|
64
|
-
:
|
52
|
+
: require;
|
65
53
|
const dataUrl = (code) => new URL(`data:text/javascript,${encodeURIComponent(code)}`);
|
66
54
|
export const isFile = (path) => {
|
67
55
|
try {
|
@@ -151,12 +139,16 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
151
139
|
}
|
152
140
|
}
|
153
141
|
}
|
154
|
-
/* istanbul ignore if -- https://github.com/facebook/jest/issues/5274 */
|
155
142
|
if (process.versions.pnp) {
|
156
143
|
const nodeOptions = NODE_OPTIONS === null || NODE_OPTIONS === void 0 ? void 0 : NODE_OPTIONS.split(/\s+/);
|
157
|
-
|
158
|
-
|
159
|
-
pnpApiPath
|
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]))) &&
|
160
152
|
!execArgv.includes(pnpApiPath)) {
|
161
153
|
execArgv = ['-r', pnpApiPath, ...execArgv];
|
162
154
|
const pnpLoaderPath = path.resolve(pnpApiPath, '../.pnp.loader.mjs');
|
@@ -173,7 +165,6 @@ const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
|
|
173
165
|
execArgv,
|
174
166
|
};
|
175
167
|
};
|
176
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
177
168
|
function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE, timeout = DEFAULT_TIMEOUT, execArgv = DEFAULT_EXEC_ARGV, tsRunner = DEFAULT_TS_RUNNER, } = {}) {
|
178
169
|
const { port1: mainPort, port2: workerPort } = new MessageChannel();
|
179
170
|
const { isTs, ext, tsUseEsm, workerPath: finalWorkerPath, execArgv: finalExecArgv, } = setupTsRunner(workerPath, { execArgv, tsRunner });
|
@@ -181,15 +172,11 @@ function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE
|
|
181
172
|
if (/\.[cm]ts$/.test(finalWorkerPath)) {
|
182
173
|
const isTsxSupported = !tsUseEsm ||
|
183
174
|
Number.parseFloat(process.versions.node) >= MTS_SUPPORTED_NODE_VERSION;
|
184
|
-
/* istanbul ignore if */
|
185
175
|
if ([
|
186
|
-
// https://github.com/egoist/esbuild-register/issues/79
|
187
176
|
TsRunner.EsbuildRegister,
|
188
|
-
// https://github.com/folke/esbuild-runner/issues/67
|
189
177
|
TsRunner.EsbuildRunner,
|
190
|
-
// https://github.com/swc-project/swc-node/issues/667
|
191
178
|
TsRunner.SWC,
|
192
|
-
...
|
179
|
+
...(isTsxSupported ? [] : [TsRunner.TSX]),
|
193
180
|
].includes(tsRunner)) {
|
194
181
|
throw new Error(`${tsRunner} is not supported for ${ext} files yet` +
|
195
182
|
(isTsxSupported
|
@@ -216,13 +203,11 @@ function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE
|
|
216
203
|
const msg = { sharedBuffer, id, args };
|
217
204
|
worker.postMessage(msg);
|
218
205
|
const status = Atomics.wait(sharedBufferView, 0, 0, timeout);
|
219
|
-
/* istanbul ignore if */
|
220
206
|
if (!['ok', 'not-equal'].includes(status)) {
|
221
207
|
throw new Error('Internal error: Atomics.wait() failed: ' + status);
|
222
208
|
}
|
223
209
|
const { id: id2, result, error, properties, } = receiveMessageOnPort(mainPort)
|
224
210
|
.message;
|
225
|
-
/* istanbul ignore if */
|
226
211
|
if (id !== id2) {
|
227
212
|
throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
228
213
|
}
|
@@ -234,16 +219,13 @@ function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE
|
|
234
219
|
worker.unref();
|
235
220
|
return syncFn;
|
236
221
|
}
|
237
|
-
/* istanbul ignore next */
|
238
222
|
export function runAsWorker(fn) {
|
239
|
-
// type-coverage:ignore-next-line -- we can't control
|
240
223
|
if (!workerData) {
|
241
224
|
return;
|
242
225
|
}
|
243
226
|
const { workerPort } = workerData;
|
244
227
|
try {
|
245
228
|
parentPort.on('message', ({ sharedBuffer, id, args }) => {
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
247
229
|
;
|
248
230
|
(() => __awaiter(this, void 0, void 0, function* () {
|
249
231
|
const sharedBufferView = new Int32Array(sharedBuffer);
|
@@ -259,13 +241,6 @@ export function runAsWorker(fn) {
|
|
259
241
|
Atomics.notify(sharedBufferView, 0);
|
260
242
|
}))();
|
261
243
|
});
|
262
|
-
/**
|
263
|
-
* @see https://github.com/un-ts/synckit/issues/94
|
264
|
-
*
|
265
|
-
* Starting the worker can fail, due to syntax error, for example. In that case
|
266
|
-
* we just fail all incoming messages with whatever error message we got.
|
267
|
-
* Otherwise incoming messages will hang forever waiting for a reply.
|
268
|
-
*/
|
269
244
|
}
|
270
245
|
catch (error) {
|
271
246
|
parentPort.on('message', ({ sharedBuffer, id }) => {
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
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,EAC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AC1D;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,44 +1,12 @@
|
|
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
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
|
-
"packageManager": "yarn@1.22.19",
|
42
10
|
"engines": {
|
43
11
|
"node": "^14.18.0 || >=16.0.0"
|
44
12
|
},
|
@@ -64,94 +32,8 @@
|
|
64
32
|
"synchronize",
|
65
33
|
"synckit"
|
66
34
|
],
|
67
|
-
"scripts": {
|
68
|
-
"benchmark": "run-s benchmark:*",
|
69
|
-
"benchmark-export": "run-s benchmark-export:*",
|
70
|
-
"benchmark-export:cjs": "yarn benchmark:cjs > benchmarks/benchmark.cjs.txt",
|
71
|
-
"benchmark-export:esm": "yarn benchmark:esm> benchmarks/benchmark.esm.txt",
|
72
|
-
"benchmark:cjs": "node benchmarks/benchmark.cjs",
|
73
|
-
"benchmark:esm": "node benchmarks/benchmark.js",
|
74
|
-
"build": "run-p build:*",
|
75
|
-
"build:r": "r -f cjs",
|
76
|
-
"build:ts": "tsc -p src",
|
77
|
-
"lint": "run-p lint:*",
|
78
|
-
"lint:es": "eslint . --cache -f friendly --max-warnings 10",
|
79
|
-
"lint:tsc": "tsc --noEmit",
|
80
|
-
"prepare": "patch-package && simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
|
81
|
-
"prerelease": "yarn build",
|
82
|
-
"release": "changeset publish",
|
83
|
-
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
84
|
-
"typecov": "type-coverage"
|
85
|
-
},
|
86
35
|
"dependencies": {
|
87
|
-
"@pkgr/utils": "^2.3.
|
36
|
+
"@pkgr/utils": "^2.3.1",
|
88
37
|
"tslib": "^2.4.0"
|
89
|
-
},
|
90
|
-
"devDependencies": {
|
91
|
-
"@1stg/lib-config": "^9.0.2",
|
92
|
-
"@changesets/changelog-github": "^0.4.6",
|
93
|
-
"@changesets/cli": "^2.23.2",
|
94
|
-
"@swc-node/register": "^1.5.1",
|
95
|
-
"@types/jest": "^28.1.5",
|
96
|
-
"@types/node": "^18.0.4",
|
97
|
-
"deasync": "^0.1.27",
|
98
|
-
"esbuild-register": "^3.3.3",
|
99
|
-
"esbuild-runner": "^2.2.1",
|
100
|
-
"execa": "^6.1.0",
|
101
|
-
"jest": "^28.1.3",
|
102
|
-
"patch-package": "^6.4.7",
|
103
|
-
"sync-threads": "^1.0.1",
|
104
|
-
"ts-expect": "^1.3.0",
|
105
|
-
"ts-jest": "^28.0.6",
|
106
|
-
"ts-node": "^10.9.1",
|
107
|
-
"tsx": "^3.8.0",
|
108
|
-
"type-coverage": "^2.22.0",
|
109
|
-
"typescript": "^4.7.4",
|
110
|
-
"yarn-deduplicate": "^5.0.0"
|
111
|
-
},
|
112
|
-
"resolutions": {
|
113
|
-
"prettier": "^2.7.1"
|
114
|
-
},
|
115
|
-
"commitlint": {
|
116
|
-
"extends": "@1stg"
|
117
|
-
},
|
118
|
-
"jest": {
|
119
|
-
"preset": "ts-jest",
|
120
|
-
"testEnvironment": "node",
|
121
|
-
"collectCoverage": true,
|
122
|
-
"extensionsToTreatAsEsm": [
|
123
|
-
".ts"
|
124
|
-
],
|
125
|
-
"moduleNameMapper": {
|
126
|
-
"^(\\.{1,2}/.*)\\.js$": "$1",
|
127
|
-
"^synckit$": "<rootDir>/src"
|
128
|
-
},
|
129
|
-
"globals": {
|
130
|
-
"ts-jest": {
|
131
|
-
"useESM": true,
|
132
|
-
"tsconfig": {
|
133
|
-
"importHelpers": false
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
},
|
138
|
-
"prettier": "@1stg/prettier-config",
|
139
|
-
"renovate": {
|
140
|
-
"extends": [
|
141
|
-
"@1stg"
|
142
|
-
]
|
143
|
-
},
|
144
|
-
"typeCoverage": {
|
145
|
-
"atLeast": 100,
|
146
|
-
"cache": true,
|
147
|
-
"detail": true,
|
148
|
-
"ignoreAsAssertion": true,
|
149
|
-
"ignoreFiles": [
|
150
|
-
"**/*.d.ts"
|
151
|
-
],
|
152
|
-
"ignoreNonNullAssertion": true,
|
153
|
-
"showRelativePath": true,
|
154
|
-
"strict": true,
|
155
|
-
"update": true
|
156
38
|
}
|
157
|
-
}
|
39
|
+
}
|