tursodatabase / tursodatabase/libsql-client-ts

Don't require isomorphic-fetch in environments with fetch

Open
#111 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
576
Forks
69
PR merge metrics
No merged PRs in 30d

Description

Requiring isomorphic-fetch swells the size of any packages / Lambdas using libsql by over 100%.

For example, here is the breakdown of a very simple Lambda using @libsql/client:

image

Looking at how these are related:

image

i.e. the primary dependencies introduced by isomorphic-fetch include:

Dependency Size
isomorphic-fetch (including node-fetch) 38.3Kb
whatwg-url (required by isomorphic-fetch via node-fetch) 45.1Kb
tr46 (required by whatwg-url) 294.3Kb
TOTAL 377.7Kb
Percent of node_modules 58.94%

I wonder what environments still need node-fetch anyway? Node 16 has been EOL'ed so Node can be assumed to have native fetch and I believe all versions of Deno and Bun have native fetch too.

Given the API already allows providing a fetch function, would it be possible to assume a native fetch and allow environments that don't have native fetch (or have a deficient/buggy version) to pass in isomorphic-fetch or somesuch as needed rather than have all users pay the cost of node-fetch and friends?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @libsql/client API's existing fetch option and its isomorphic-fetch dependency declaration. Trace how requests obtain fetch, then verify that environments with native fetch no longer pull in the dependency while callers can still provide an alternative fetch implementation when needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, deno, node.js, typescript
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.