diff --git a/README.md b/README.md index aa997d8d..07a48941 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build.config.ts b/build.config.ts index c52855d7..4ae9706d 100644 --- a/build.config.ts +++ b/build.config.ts @@ -7,7 +7,6 @@ export default defineBuildConfig({ }, entries: [ "src/index", - "src/node", - "src/undici" + "src/node" ] }); diff --git a/cjs/undici.cjs b/cjs/undici.cjs deleted file mode 100644 index 3b25858d..00000000 --- a/cjs/undici.cjs +++ /dev/null @@ -1,8 +0,0 @@ -const getExport = name => import("../dist/undici.mjs").then(r => r[name]); -const createCaller = name => (input, init) => getExport(name).then(function_ => function_(input, init)); - -exports.fetch = createCaller("fetch"); -exports.ofetch = createCaller("ofetch"); -exports.$fetch = createCaller("$fetch"); -exports.$fetch.raw = (input, init) => getExport("$fetch").then($fetch => $fetch.raw(input, init)); -exports.$fetch.native = (input, init) => getExport("$fetch").then($fetch => $fetch.native(input, init)); diff --git a/package.json b/package.json index 9afeabce..c4849b47 100644 --- a/package.json +++ b/package.json @@ -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", @@ -36,7 +31,6 @@ "files": [ "dist", "node.d.ts", - "undici.d.ts", "cjs" ], "scripts": { @@ -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", diff --git a/playground/undici.ts b/playground/undici.ts deleted file mode 100644 index 801e23e4..00000000 --- a/playground/undici.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { $fetch } from "../src/undici"; - -async function main () { - const r = await $fetch("http://google.com/404"); - // eslint-disable-next-line no-console - console.log(r); -} - -// eslint-disable-next-line unicorn/prefer-top-level-await -main().catch((error) => { - // eslint-disable-next-line no-console - console.error(error); - // eslint-disable-next-line unicorn/no-process-exit - process.exit(1); -}); diff --git a/src/undici.ts b/src/undici.ts deleted file mode 100644 index 414e0897..00000000 --- a/src/undici.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { fetch as undiciFetch } from "undici"; -import { createNodeFetch, Headers } from "./node"; -import { createFetch } from "./base"; - -export * from "./base"; - -export const fetch = globalThis.fetch || undiciFetch || createNodeFetch(); - -export { Headers } from "./node"; - -export const ofetch = createFetch({ fetch, Headers }); -export const $fetch = ofetch; diff --git a/undici.d.ts b/undici.d.ts deleted file mode 100644 index dc463151..00000000 --- a/undici.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./dist/undici";