feat: use native fetch instead of node-fetch#52
Merged
Conversation
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>
There was a problem hiding this comment.
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-fetchusage and rely on the globalfetchavailable in Node.js 18+. - Export native
Response(value + type) fromsrc/index.tsinstead of re-exporting fromnode-fetch. - Add
engines.node >=18and replace@types/node-fetchwith@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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.