diff options
Diffstat (limited to 'packages/webapi')
-rw-r--r-- | packages/webapi/package.json | 4 | ||||
-rw-r--r-- | packages/webapi/run/build.js | 1 | ||||
-rw-r--r-- | packages/webapi/src/lib/fetch.ts | 13 |
3 files changed, 8 insertions, 10 deletions
diff --git a/packages/webapi/package.json b/packages/webapi/package.json index c657ba1eb..9ae7668a7 100644 --- a/packages/webapi/package.json +++ b/packages/webapi/package.json @@ -49,6 +49,9 @@ ], "bugs": "https://github.com/withastro/astro/issues", "homepage": "https://github.com/withastro/astro/tree/main/packages/webapi#readme", + "dependencies": { + "node-fetch": "^3.2.4" + }, "devDependencies": { "@rollup/plugin-alias": "^3.1.9", "@rollup/plugin-inject": "^4.0.4", @@ -65,7 +68,6 @@ "formdata-polyfill": "^4.0.10", "magic-string": "^0.25.9", "mocha": "^9.2.2", - "node-fetch": "^3.2.4", "rollup": "^2.74.1", "rollup-plugin-terser": "^7.0.2", "tslib": "^2.4.0", diff --git a/packages/webapi/run/build.js b/packages/webapi/run/build.js index 3bde958f0..754e7950a 100644 --- a/packages/webapi/run/build.js +++ b/packages/webapi/run/build.js @@ -178,6 +178,7 @@ async function build() { inputOptions: { input: 'src/polyfill.ts', plugins: plugins, + external: ['node-fetch'], onwarn(warning, warn) { if (warning.code !== 'UNRESOLVED_IMPORT') warn(warning) }, diff --git a/packages/webapi/src/lib/fetch.ts b/packages/webapi/src/lib/fetch.ts index c62c46e30..5dad4e5b4 100644 --- a/packages/webapi/src/lib/fetch.ts +++ b/packages/webapi/src/lib/fetch.ts @@ -3,7 +3,8 @@ import { Headers, Request, Response, -} from 'node-fetch/src/index.js' +} from 'node-fetch' +import type { RequestInit } from 'node-fetch' import Stream from 'node:stream' import * as _ from './utils' @@ -11,7 +12,7 @@ export { Headers, Request, Response } export const fetch = { fetch( - resource: string | URL | Request, + resource: string | Request, init?: Partial<FetchInit> ): Promise<Response> { const resourceURL = new URL( @@ -62,13 +63,7 @@ export const fetch = { type USVString = {} & string interface FetchInit { - body: - | Blob - | BufferSource - | FormData - | URLSearchParams - | ReadableStream - | USVString + body: RequestInit['body'] cache: | 'default' | 'no-store' |