Skip to content

Commit c5eaca3

Browse files
chore: release synckit (#146)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent b2affa0 commit c5eaca3

3 files changed

Lines changed: 57 additions & 56 deletions

File tree

.changeset/funny-meals-speak.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
# synckit
22

3+
## 0.8.7
4+
5+
### Patch Changes
6+
7+
- [#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`.
8+
9+
You can also pass a custom `globalShims` option as `GlobalShim` `Array` to custom your own shims:
10+
11+
````ts
12+
export interface GlobalShim {
13+
moduleName: string
14+
/**
15+
* `undefined` means side effect only
16+
*/
17+
globalName?: string
18+
/**
19+
* 1. `undefined` or empty string means `default`, for example:
20+
* ```js
21+
* import globalName from 'module-name'
22+
* ```
23+
*
24+
* 2. `null` means namespaced, for example:
25+
* ```js
26+
* import * as globalName from 'module-name'
27+
* ```
28+
*
29+
*/
30+
named?: string | null
31+
/**
32+
* If not `false`, the shim will only be applied when the original `globalName` unavailable,
33+
* for example you may only want polyfill `globalThis.fetch` when it's unavailable natively:
34+
* ```js
35+
* import fetch from 'node-fetch'
36+
*
37+
* if (!globalThis.fetch) {
38+
* globalThis.fetch = fetch
39+
* }
40+
* ```
41+
*/
42+
conditional?: boolean
43+
}
44+
````
45+
46+
You can aslo reuse the exported `DEFAULT_GLOBAL_SHIMS_PRESET` for extanding:
47+
48+
```js
49+
import { DEFAULT_GLOBAL_SHIMS_PRESET, createSyncFn } from 'synckit'
50+
51+
const syncFn = createSyncFn(require.resolve('./worker'), {
52+
globalShims: [
53+
...DEFAULT_GLOBAL_SHIMS_PRESET,
54+
// your own shim here
55+
],
56+
})
57+
```
58+
359
## 0.8.6
460

561
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "synckit",
3-
"version": "0.8.6",
3+
"version": "0.8.7",
44
"type": "module",
55
"description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.",
66
"repository": "git+https://github.com/un-ts/synckit.git",

0 commit comments

Comments
 (0)