From 46ae94e02928ac9d1bff7bda46c26843874c73ac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 Jan 2024 05:11:59 +0000 Subject: [PATCH 1/4] chore: release synckit --- .changeset/neat-rings-joke.md | 5 ----- .changeset/ten-sheep-applaud.md | 5 ----- CHANGELOG.md | 24 +++++++++++++++++------- package.json | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 .changeset/neat-rings-joke.md delete mode 100644 .changeset/ten-sheep-applaud.md diff --git a/.changeset/neat-rings-joke.md b/.changeset/neat-rings-joke.md deleted file mode 100644 index c1f0c3b6b..000000000 --- a/.changeset/neat-rings-joke.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"synckit": patch ---- - -refactor: lazy initialize caches diff --git a/.changeset/ten-sheep-applaud.md b/.changeset/ten-sheep-applaud.md deleted file mode 100644 index fc7e0ef88..000000000 --- a/.changeset/ten-sheep-applaud.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"synckit": minor ---- - -feat!: use a single SharedArrayBuffer, remove useless `bufferSize` option diff --git a/CHANGELOG.md b/CHANGELOG.md index 04291e759..5fbcf1170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # synckit +## 0.9.0 + +### Minor Changes + +- [#154](https://github.com/un-ts/synckit/pull/154) [`2541a1e`](https://github.com/un-ts/synckit/commit/2541a1e9b3d0e8f01f29f78ac53cb835936f6a30) Thanks [@onigoetz](https://github.com/onigoetz)! - feat!: use a single SharedArrayBuffer, remove useless `bufferSize` option + +### Patch Changes + +- [#156](https://github.com/un-ts/synckit/pull/156) [`be4648c`](https://github.com/un-ts/synckit/commit/be4648c45a698aee1be8e267b78542b13c8596aa) Thanks [@JounQin](https://github.com/JounQin)! - refactor: lazy initialize caches + ## 0.8.8 ### Patch Changes @@ -16,11 +26,11 @@ ````ts export interface GlobalShim { - moduleName: string + moduleName: string; /** * `undefined` means side effect only */ - globalName?: string + globalName?: string; /** * 1. `undefined` or empty string means `default`, for example: * ```js @@ -33,7 +43,7 @@ * ``` * */ - named?: string | null + named?: string | null; /** * If not `false`, the shim will only be applied when the original `globalName` unavailable, * for example you may only want polyfill `globalThis.fetch` when it's unavailable natively: @@ -45,21 +55,21 @@ * } * ``` */ - conditional?: boolean + conditional?: boolean; } ```` You can aslo reuse the exported `DEFAULT_GLOBAL_SHIMS_PRESET` for extanding: ```js - import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from 'synckit' + import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from "synckit"; - const syncFn = createSyncFn(require.resolve('./worker'), { + const syncFn = createSyncFn(require.resolve("./worker"), { globalShims: [ ...DEFAULT_GLOBAL_SHIMS_PRESET, // your own shim here ], - }) + }); ``` ## 0.8.6 diff --git a/package.json b/package.json index e8736214c..74e8a04c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "synckit", - "version": "0.8.8", + "version": "0.9.0", "type": "module", "description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.", "repository": "git+https://github.com/un-ts/synckit.git", From 123098cf33dbc9034511f336e32578354effac2c Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 4 Jan 2024 13:17:25 +0800 Subject: [PATCH 2/4] chore: add prettier as dev dependency --- CHANGELOG.md | 14 +++++++------- package.json | 2 ++ yarn.lock | 9 +++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fbcf1170..c3b4cf5a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,11 +26,11 @@ ````ts export interface GlobalShim { - moduleName: string; + moduleName: string /** * `undefined` means side effect only */ - globalName?: string; + globalName?: string /** * 1. `undefined` or empty string means `default`, for example: * ```js @@ -43,7 +43,7 @@ * ``` * */ - named?: string | null; + named?: string | null /** * If not `false`, the shim will only be applied when the original `globalName` unavailable, * for example you may only want polyfill `globalThis.fetch` when it's unavailable natively: @@ -55,21 +55,21 @@ * } * ``` */ - conditional?: boolean; + conditional?: boolean } ```` You can aslo reuse the exported `DEFAULT_GLOBAL_SHIMS_PRESET` for extanding: ```js - import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from "synckit"; + import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from 'synckit' - const syncFn = createSyncFn(require.resolve("./worker"), { + const syncFn = createSyncFn(require.resolve('./worker'), { globalShims: [ ...DEFAULT_GLOBAL_SHIMS_PRESET, // your own shim here ], - }); + }) ``` ## 0.8.6 diff --git a/package.json b/package.json index 74e8a04c5..1047a2b2b 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "execa": "^8.0.1", "jest": "^29.7.0", "patch-package": "^8.0.0", + "prettier": "^3.1.1", "sync-threads": "^1.0.1", "ts-expect": "^1.3.0", "ts-jest": "^29.1.1", @@ -80,6 +81,7 @@ "yarn-deduplicate": "^6.0.2" }, "resolutions": { + "prettier": "^3.1.1", "synckit": "link:." }, "commitlint": { diff --git a/yarn.lock b/yarn.lock index f7e0e4fdf..b4bb1e515 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9438,12 +9438,7 @@ prettier-plugin-toml@^2.0.1: dependencies: "@taplo/lib" "^0.4.0-alpha.2" -prettier@2, prettier@>=2.3, prettier@^2.7.1: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== - -prettier@^3.1.1: +prettier@2, prettier@>=2.3, prettier@^2.7.1, prettier@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" integrity sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw== @@ -11275,9 +11270,11 @@ sync-threads@^1.0.1: synckit@^0.8.5: version "0.0.0" + uid "" synckit@^0.8.6: version "0.0.0" + uid "" "synckit@link:.": version "0.0.0" From 96797ab8f1030f5c79e561bf22121cbd96188684 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 4 Jan 2024 13:24:54 +0800 Subject: [PATCH 3/4] docs: resort options and envs --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4f509489f..1f324198c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) -Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support. +Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript and Yarn P'n'P support. ## TOC @@ -111,18 +111,18 @@ export interface GlobalShim { ### Options -1. `timeout` same as env `SYNCKIT_TIMEOUT` -2. `execArgv` same as env `SYNCKIT_EXEC_ARGV` -3. `tsRunner` same as env `SYNCKIT_TS_RUNNER` +1. `execArgv` same as env `SYNCKIT_EXEC_ARGV` +2. `globalShims`: Similar like env `SYNCKIT_GLOBAL_SHIMS` but much more flexible which can be a `GlobalShim` `Array`, see `GlobalShim`'s [definition](#types) for more details +3. `timeout` same as env `SYNCKIT_TIMEOUT` 4. `transferList`: Please refer Node.js [`worker_threads`](https://nodejs.org/api/worker_threads.html#:~:text=Default%3A%20true.-,transferList,-%3CObject%5B%5D%3E%20If) documentation -5. `globalShims`: Similar like env `SYNCKIT_GLOBAL_SHIMS` but much more flexible which can be a `GlobalShim` `Array`, see `GlobalShim`'s [definition](#types) for more details +5. `tsRunner` same as env `SYNCKIT_TS_RUNNER` ### Envs -1. `SYNCKIT_TIMEOUT`: `timeout` for performing the async job (no default) -2. `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) -3. `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 -4. `SYNCKIT_GLOBAL_SHIMS`: Whether to enable the default `DEFAULT_GLOBAL_SHIMS_PRESET` as `globalShims` +1. `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) +2. `SYNCKIT_GLOBAL_SHIMS`: Whether to enable the default `DEFAULT_GLOBAL_SHIMS_PRESET` as `globalShims` +3. `SYNCKIT_TIMEOUT`: `timeout` for performing the async job (no default) +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 ### TypeScript From b5e95bb33424f396a6a3da7226f189621679eae6 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 4 Jan 2024 13:29:30 +0800 Subject: [PATCH 4/4] test: ignore covered line --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 1df444056..8ef71b1f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -473,7 +473,9 @@ function startWorkerThread>( // We store a single Byte in the SharedArrayBuffer // for the notification, we can used a fixed size sharedBufferView ??= new Int32Array( - (sharedBuffer ??= new SharedArrayBuffer(INT32_BYTES)), + /* istanbul ignore next */ (sharedBuffer ??= new SharedArrayBuffer( + INT32_BYTES, + )), 0, 1, )