diff --git a/.changeset/funny-meals-speak.md b/.changeset/funny-meals-speak.md deleted file mode 100644 index 1cb65fdd3..000000000 --- a/.changeset/funny-meals-speak.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -"synckit": patch ---- - -feat: add new `globalShims` option, what means you can env `SYNCKIT_GLOBAL_SHIMS=1` to enable auto polyfilling for some modules, for example: `fetch` from `node-fetch`, `performance` from `node:perf_hooks`. - -You can also pass a custom `globalShims` option as `GlobalShim` `Array` to custom your own shims: - -````ts -export interface GlobalShim { - moduleName: string - /** - * `undefined` means side effect only - */ - globalName?: string - /** - * 1. `undefined` or empty string means `default`, for example: - * ```js - * import globalName from 'module-name' - * ``` - * - * 2. `null` means namespaced, for example: - * ```js - * import * as globalName from 'module-name' - * ``` - * - */ - 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: - * ```js - * import fetch from 'node-fetch' - * - * if (!globalThis.fetch) { - * globalThis.fetch = fetch - * } - * ``` - */ - conditional?: boolean -} -```` - -You can aslo reuse the exported `DEFAULT_GLOBAL_SHIMS_PRESET` for extanding: - -```js -import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from 'synckit' - -const syncFn = createSyncFn(require.resolve('./worker'), { - globalShims: [ - ...DEFAULT_GLOBAL_SHIMS_PRESET, - // your own shim here - ] -}) -``` diff --git a/CHANGELOG.md b/CHANGELOG.md index d0cc9e8ae..1cb3eca3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,61 @@ # synckit +## 0.8.7 + +### Patch Changes + +- [#145](https://github.com/un-ts/synckit/pull/145) [`b2affa0`](https://github.com/un-ts/synckit/commit/b2affa0e639bcdf252b7115402f22765aabedf3c) Thanks [@JounQin](https://github.com/JounQin)! - feat: add new `globalShims` option, what means you can env `SYNCKIT_GLOBAL_SHIMS=1` to enable auto polyfilling for some modules, for example: `fetch` from `node-fetch`, `performance` from `node:perf_hooks`. + + You can also pass a custom `globalShims` option as `GlobalShim` `Array` to custom your own shims: + + ````ts + export interface GlobalShim { + moduleName: string + /** + * `undefined` means side effect only + */ + globalName?: string + /** + * 1. `undefined` or empty string means `default`, for example: + * ```js + * import globalName from 'module-name' + * ``` + * + * 2. `null` means namespaced, for example: + * ```js + * import * as globalName from 'module-name' + * ``` + * + */ + 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: + * ```js + * import fetch from 'node-fetch' + * + * if (!globalThis.fetch) { + * globalThis.fetch = fetch + * } + * ``` + */ + conditional?: boolean + } + ```` + + You can aslo reuse the exported `DEFAULT_GLOBAL_SHIMS_PRESET` for extanding: + + ```js + import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from 'synckit' + + const syncFn = createSyncFn(require.resolve('./worker'), { + globalShims: [ + ...DEFAULT_GLOBAL_SHIMS_PRESET, + // your own shim here + ], + }) + ``` + ## 0.8.6 ### Patch Changes diff --git a/package.json b/package.json index 49d807d54..700038a62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "synckit", - "version": "0.8.6", + "version": "0.8.7", "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",