Remove node-fetch dependency from @segment/analytics-node#1348
Remove node-fetch dependency from @segment/analytics-node#1348MichaelGHSeg wants to merge 5 commits intomasterfrom
Conversation
Since the package requires Node >= 20 (which has native globalThis.fetch), the node-fetch fallback in fetch.ts was dead code that never executed. All supported platforms (Node 20+, Vercel Edge, Cloudflare Workers, browsers) provide native fetch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ff2f3b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1348 +/- ##
==========================================
+ Coverage 91.23% 91.31% +0.08%
==========================================
Files 163 163
Lines 4393 4388 -5
Branches 1055 1052 -3
==========================================
- Hits 4008 4007 -1
+ Misses 385 381 -4
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request removes the node-fetch dependency from @segment/analytics-node since the package requires Node >= 20, which has native globalThis.fetch support. The node-fetch fallback logic was dead code as all supported platforms (Node 20+, Vercel Edge, Cloudflare Workers, browsers) provide native fetch.
Changes:
- Simplified
fetch.tsto directly useglobalThis.fetchwithout fallback logic - Removed
node-fetchfrom package dependencies - Updated typedef tests to remove node-fetch compatibility test
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/node/src/lib/fetch.ts | Simplified fetch implementation to directly use globalThis.fetch, removing node-fetch fallback and EdgeRuntime checks |
| packages/node/package.json | Removed node-fetch dependency from dependencies list |
| packages/node/src/tests/typedef-tests.ts | Removed HTTPFetchFn import and node-fetch compatibility test, updated test description |
| yarn.lock | Updated lockfile to reflect node-fetch removal from @segment/analytics-node dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
.changeset/remove-node-fetch.md
Outdated
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| '@segment/analytics-node': patch | |||
There was a problem hiding this comment.
Should this be a major version bump?
silesky
left a comment
There was a problem hiding this comment.
Should this be a major version bump?
Someone on Node < 18 ignoring the engines field would break since node-fetch is no longer bundled as a fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
node-fetchdependency since the package requires Node >= 20, which has nativeglobalThis.fetchnode-fetchfallback infetch.tswas dead code — all supported platforms (Node 20+, Vercel Edge, Cloudflare Workers, browsers) provide native fetchfetch.tsto directly useglobalThis.fetchMotivation
Modernize dependencies —
node-fetchis unnecessary since the Node 20 minimum version requirement was established. Customers (e.g. Atlassian via Flex SDK) are asking for reduced/modernized dependency trees.Test plan
🤖 Generated with Claude Code