ollama / ollama-js

Ollama JavaScript library
https://ollama.com
MIT License
2.28k stars 179 forks source link

dynamic import of whatwg-fetch to allow environments without it #134

Open BruceMacD opened 3 months ago

BruceMacD commented 3 months ago

Got over-zealous on the last change to make fetch a dynamic import. This change allows for the same functionality as #125 but it keeps whatwg-fetch rather than replacing it with node-fetch. This preserves current behavior.

kwaa commented 3 months ago

Maybe also make whatwg-fetch an optional dependency to prevent users who don't need it from installing it?

# package.json
{
- "dependencies": {
-   "whatwg-fetch": "^3.6.20"
- }
+ "peerDependencies": {
+   "whatwg-fetch": "^3.6.20"
+ },
+ "peerDependenciesMeta": {
+   "whatwg-fetch": {
+     "optional": true
+   }
+ }
}

https://caniuse.com/fetch