From c275fba927267751349347f68a095764b7997092 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sat, 24 Feb 2024 20:39:37 +0300 Subject: [PATCH] perf: replace node-fetch with node-fetch-native --- package-lock.json | 18 ++++++++++++++++-- package.json | 6 +++--- scripts/build-dts.mjs | 2 +- src/vendor.ts | 9 ++++----- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 995f748445..0714991abb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "madge": "^6.1.0", "minimist": "^1.2.8", "node-fetch": "3.3.2", + "node-fetch-native": "^1.6.2", "prettier": "^2.8.8", "ps-tree": "^1.2.0", "tsd": "^0.28.1", @@ -41,8 +42,9 @@ "engines": { "node": ">= 16.0.0" }, - "peerDependencies": { - "@types/node": ">=18.16.3" + "optionalDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/node": ">=20.11.19" } }, "node_modules/@ampproject/remapping": { @@ -4693,6 +4695,12 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/node-fetch-native": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.2.tgz", + "integrity": "sha512-69mtXOFZ6hSkYiXAVB5SqaRvrbITC/NPyqv7yuu/qw0nmgPyYbIMYYNIDhNtwPrzk0ptrimrLz/hhjvm4w5Z+w==", + "dev": true + }, "node_modules/node-releases": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", @@ -10195,6 +10203,12 @@ "formdata-polyfill": "^4.0.10" } }, + "node-fetch-native": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.2.tgz", + "integrity": "sha512-69mtXOFZ6hSkYiXAVB5SqaRvrbITC/NPyqv7yuu/qw0nmgPyYbIMYYNIDhNtwPrzk0ptrimrLz/hhjvm4w5Z+w==", + "dev": true + }, "node-releases": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", diff --git a/package.json b/package.json index 0644ae2488..17d7fbc3ce 100644 --- a/package.json +++ b/package.json @@ -58,12 +58,12 @@ "@types/node": ">=20.11.19" }, "devDependencies": { + "@stryker-mutator/core": "^6.4.2", "@types/fs-extra": "^11.0.4", + "@types/minimist": "^1.2.5", "@types/node": ">=20.11.19", "@types/ps-tree": "^1.1.6", - "@types/minimist": "^1.2.5", "@types/which": "^3.0.3", - "@stryker-mutator/core": "^6.4.2", "c8": "^7.13.0", "chalk": "^5.3.0", "dts-bundle-generator": "^9.3.1", @@ -75,7 +75,7 @@ "globby": "^14.0.1", "madge": "^6.1.0", "minimist": "^1.2.8", - "node-fetch": "3.3.2", + "node-fetch-native": "^1.6.2", "prettier": "^2.8.8", "ps-tree": "^1.2.0", "tsd": "^0.28.1", diff --git a/scripts/build-dts.mjs b/scripts/build-dts.mjs index 0a1bf600d9..b1f2eb587a 100644 --- a/scripts/build-dts.mjs +++ b/scripts/build-dts.mjs @@ -29,7 +29,7 @@ const entry = { '@nodelib/fs.walk', 'fast-glob', '@types/jsonfile', - 'node-fetch', + 'node-fetch-native', 'chalk', 'globby', 'webpod', diff --git a/src/vendor.ts b/src/vendor.ts index b017921c5e..09843dca43 100644 --- a/src/vendor.ts +++ b/src/vendor.ts @@ -24,12 +24,11 @@ import { } from 'globby' import * as yaml from 'yaml' import * as _fs from 'fs-extra' +import type { fetch } from 'node-fetch-native' -export { - default as nodeFetch, - type RequestInfo, - type RequestInit, -} from 'node-fetch' +export { fetch as nodeFetch } from 'node-fetch-native' +export type RequestInfo = Parameters[0] +export type RequestInit = Parameters[1] export const globbyModule = { globby,