tursodatabase / tursodatabase/libsql-client-ts
Don't require isomorphic-fetch in environments with fetch
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:
Looking at how these are related:
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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