Skip to content

Commit

Permalink
refactor!: drop undici support
Browse files Browse the repository at this point in the history
node 18 and node-fetch-native already benefit from undici
  • Loading branch information
pi0 committed Nov 15, 2022
1 parent d8fc46f commit c7d8c93
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 56 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ const { ofetch } = require('ofetch')
We use [conditional exports](https://nodejs.org/api/packages.html#packages_conditional_exports) to detect Node.js
and automatically use [unjs/node-fetch-native](https://github.com/unjs/node-fetch-native). If `globalThis.fetch` is available, will be used instead. To leverage Node.js 17.5.0 experimental native fetch API use [`--experimental-fetch` flag](https://nodejs.org/dist/latest-v17.x/docs/api/cli.html#--experimental-fetch).

### `undici` support

In order to use experimental fetch implementation from [nodejs/undici](https://github.com/nodejs/undici), You can import from `ofetch/undici`.

```js
import { ofetch } from 'ofetch/undici'
```

On Node.js versions older than `16.5`, node-fetch will be used as the fallback.

### `keepAlive` support

By setting the `FETCH_KEEP_ALIVE` environment variable to `true`, an http/https agent will be registered that keeps sockets around even when there are no outstanding requests, so they can be used for future requests without having to reestablish a TCP connection.
Expand Down
3 changes: 1 addition & 2 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default defineBuildConfig({
},
entries: [
"src/index",
"src/node",
"src/undici"
"src/node"
]
});
8 changes: 0 additions & 8 deletions cjs/undici.cjs

This file was deleted.

9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
"types": "./dist/node.d.ts",
"import": "./dist/node.mjs",
"require": "./cjs/node.cjs"
},
"./undici": {
"types": "./dist/undici.d.ts",
"import": "./dist/undici.mjs",
"require": "./cjs/undici.cjs"
}
},
"main": "./cjs/node.cjs",
Expand All @@ -36,7 +31,6 @@
"files": [
"dist",
"node.d.ts",
"undici.d.ts",
"cjs"
],
"scripts": {
Expand All @@ -51,8 +45,7 @@
"dependencies": {
"destr": "^1.2.1",
"node-fetch-native": "^1.0.1",
"ufo": "^1.0.0",
"undici": "^5.12.0"
"ufo": "^1.0.0"
},
"devDependencies": {
"@types/node": "^18.11.9",
Expand Down
15 changes: 0 additions & 15 deletions playground/undici.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/undici.ts

This file was deleted.

1 change: 0 additions & 1 deletion undici.d.ts

This file was deleted.

0 comments on commit c7d8c93

Please sign in to comment.