Skip to content

feat: use native fetch instead of node-fetch#52

Merged
FreekBes merged 2 commits into
mainfrom
feat/native-fetch
Jun 24, 2026
Merged

feat: use native fetch instead of node-fetch#52
FreekBes merged 2 commits into
mainfrom
feat/native-fetch

Conversation

@FreekBes

Copy link
Copy Markdown
Member

Drop the node-fetch dependency and rely on the global fetch/Response available in Node.js 18+. Adds an engines constraint of node>=18 and swaps @types/node-fetch for @types/node so the global types resolve.

BREAKING CHANGE: node-fetch has been removed. Consumers must run on Node.js 18 or newer, and the exported Response type is now the native (undici) Response rather than node-fetch's. The methods this library uses are identical, but code relying on node-fetch-specific Response behavior (e.g. body as a Node stream) may need adjusting.

Drop the node-fetch dependency and rely on the global fetch/Response
available in Node.js 18+. Adds an engines constraint of node>=18 and
swaps @types/node-fetch for @types/node so the global types resolve.

BREAKING CHANGE: node-fetch has been removed. Consumers must run on
Node.js 18 or newer, and the exported Response type is now the native
(undici) Response rather than node-fetch's. The methods this library
uses are identical, but code relying on node-fetch-specific Response
behavior (e.g. body as a Node stream) may need adjusting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FreekBes FreekBes requested a review from Copilot June 24, 2026 17:03
@FreekBes FreekBes added the enhancement New feature or request label Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the library from node-fetch to Node.js 18+’s built-in fetch/Response (undici-backed), removing the external dependency and updating typings accordingly.

Changes:

  • Remove node-fetch usage and rely on the global fetch available in Node.js 18+.
  • Export native Response (value + type) from src/index.ts instead of re-exporting from node-fetch.
  • Add engines.node >=18 and replace @types/node-fetch with @types/node.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/index.test.ts Switch test mocking from jest.mock('node-fetch') to stubbing global.fetch.
src/index.ts Remove node-fetch import and export native Response from globalThis.
package.json Drop node-fetch, add Node 18+ engines constraint, switch to @types/node.
package-lock.json Lockfile updates reflecting removed direct dependency and updated type packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/index.test.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@FreekBes FreekBes merged commit a878ea2 into main Jun 24, 2026
1 check passed
@FreekBes FreekBes deleted the feat/native-fetch branch June 24, 2026 17:15
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants