donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.42k stars 150 forks source link

Use nodejs's builtin fetch #1531

Closed rotu closed 1 month ago

rotu commented 1 month ago

Node has a fetch function built in, so NodeIO should no longer need a third party library.

donmccurdy commented 1 month ago

My goal is for glTF Transform to support all stable versions of Node.js — currently v18, v20, and v22. It looks like the Node.js fetch function is stable only in v22+, so I don't think we should access it automatically in NodeIO quite yet. But we could certainly update the documentation to show built-in fetch rather than node-fetch, passing that into the NodeIO constructor. I believe this would just require an update to the documentation here:

https://github.com/donmccurdy/glTF-Transform/blob/7aa92bea25d775dea3fd067e6bdfe0eb078849ac/packages/core/src/io/node-io.ts#L31-L42

Users on Node.js v18 and v20 could still use experimental fetch or a third-party library, as needed.