Skip to content

Remove cross-fetch dependency in favor of global fetch - #134

Merged
jaxoncreed merged 4 commits into
mainfrom
copilot/remove-cross-fetch-usage-again
Jul 24, 2026
Merged

Remove cross-fetch dependency in favor of global fetch#134
jaxoncreed merged 4 commits into
mainfrom
copilot/remove-cross-fetch-usage-again

Conversation

Copilot AI commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Supercedes #124. Note this is a breaking change since Node 18 will be the minimum node version supported after this change. This is not an issue since the current maintenance version of node is Node 20.

fetch is globally available since Node 18, which is now the minimum supported version. Remove the cross-fetch polyfill across the monorepo.

  • Source files: Remove cross-fetch imports from guaranteeFetch.ts, authFetch.ts, UnauthenticatedSolidLdoProvider.tsx, and test helpers in solid-type-index and solid-react — all now use the global fetch
  • Package dependencies: Remove cross-fetch from dependencies/devDependencies in connected-solid, ldo, react, connected-nextgraph, and solid-react
// Before
import crossFetch from "cross-fetch";
export function guaranteeFetch(fetchInput?: typeof fetch): typeof fetch {
  return fetchInput || crossFetch;
}

// After
export function guaranteeFetch(fetchInput?: typeof fetch): typeof fetch {
  return fetchInput || fetch;
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Remove cross-fetch usage</issue_title>
<issue_description>fetch is a global object as of Node 18; which is now the oldest supported version of Node. Thus it is safe to remove the cross-fetch global and just use fetch in the next major release.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Remove cross-fetch usage in codebase Remove cross-fetch dependency in favor of global fetch Mar 8, 2026
Copilot finished work on behalf of jeswr March 8, 2026 12:19
@jeswr
jeswr marked this pull request as ready for review March 8, 2026 13:54
Copilot AI review requested due to automatic review settings March 8, 2026 13:54
@jeswr

jeswr commented Mar 8, 2026

Copy link
Copy Markdown
Collaborator

Supercedes #124

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes the cross-fetch polyfill across the monorepo and switches all internal usage to the global fetch now that Node 18+ is assumed.

Changes:

  • Replace cross-fetch imports/usages with the global fetch in runtime code and test helpers.
  • Update guaranteeFetch and its test to default to global fetch.
  • Remove cross-fetch from package dependencies/devDependencies and update the workspace lockfile.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/test-solid-server/src/authFetch.ts Drops cross-fetch import; relies on global fetch for auth flow requests.
packages/solid-type-index/test/fileData.ts Removes cross-fetch type import; uses global fetch typing for helpers.
packages/solid-react/test/fileData.ts Removes cross-fetch import; uses global fetch in test setup.
packages/solid-react/src/UnauthenticatedSolidLdoProvider.tsx Replaces cross-fetch with global fetch in auth context provider.
packages/solid-react/package.json Removes direct cross-fetch dependency.
packages/react/package.json Removes direct cross-fetch dependency.
packages/ldo/package.json Removes direct cross-fetch devDependency.
packages/connected-solid/test/guaranteeFetch.test.ts Updates expectation to default to global fetch.
packages/connected-solid/src/util/guaranteeFetch.ts Updates implementation/docs to default to global fetch.
packages/connected-solid/package.json Removes direct cross-fetch dependency.
packages/connected-nextgraph/package.json Removes direct cross-fetch dependency.
package-lock.json Reflects dependency graph changes after removing direct cross-fetch deps.

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

Comment thread packages/connected-solid/src/util/guaranteeFetch.ts Outdated
@jeswr
jeswr requested a review from jaxoncreed March 8, 2026 14:02
Copilot AI and others added 4 commits July 16, 2026 23:58
Since fetch is a global object as of Node 18 (the oldest supported version),
cross-fetch is no longer needed. This removes:

- cross-fetch imports from source and test files
- cross-fetch from package.json dependencies in all affected packages
- Updates guaranteeFetch to fall back to global fetch
- Updates tests to verify against global fetch

Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
and add `DOM` to tsconfig `lib` to make up for missing polyfills
previously brought by cross-fetch.

Note: Adding DOM to a global config is suboptimal. It can be misleading
when running LDO in Node.js and other non-browser environments.
This can be improved, but requires deep restructuring of tsconfig.json
across the monorepo. Possible follow-up.
@mrkvon
mrkvon force-pushed the copilot/remove-cross-fetch-usage-again branch from f43ffc3 to 980bfca Compare July 17, 2026 16:21
@mrkvon

mrkvon commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

I rebased this with main and resolved conflicts. Also replaced outstanding cross-fetch introduced later. Let's try to get this PR resolved.

I also added DOM to tsconfig lib array to make up for missing polyfills. It seems like cross-fetch had previously brought DOM types with it, and removing it caused a pile of new type errors.

Note: Adding DOM to global tsconfig is suboptimal. Most of the LDO packages can be used in non-browser environments. Adding DOM to these packages can be misleading as it includes unsupported types. This can be improved, but requires deep restructuring of tsconfig.json across the monorepo. Possible follow-up.

@jeswr

jeswr commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

LGTM - thanks for doing the work @mrkvon

cc @jaxoncreed

@jaxoncreed jaxoncreed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jaxoncreed
jaxoncreed merged commit 6a2acc9 into main Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove cross-fetch usage

5 participants