Skip to content

Commit

Permalink
Move node-fetch to optionalDependencies and add warning on fallback
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
sr229 authored Jan 3, 2025
1 parent 1b041fc commit 24c6585
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
"typescript": "^5.0.0"
},
"dependencies": {
"form-data": "^4.0.0",
"form-data": "^4.0.0"
},
"optionalDependencies": {
"node-fetch": "^2.6.7"
}
}
10 changes: 10 additions & 0 deletions src/sagiri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ import sites from "./sites";

// compatibility with older versions of nodejs. This will be removed in the future once LTS versions of nodejs has moved above 21.x
let fetchFn;
const disableWarning = process.env.SAGIRI_DISABLE_NODE_FETCH_WARNING === "true" ? true : false;

if (globalThis.fetch === undefined) {
if (!disableWarning)
console.warn(`
WARNING: Starting in Sagiri 4.3.x, the node-fetch fallback will be removed in favor of using Node.js's native
fetch implementation. Furthermore, CJS exports will cease to work. 4.3.0 will be a transitionary period for
everyone relying on the old implementation. If you wish to use older LTS versions, stick to Sagiri 4.2.x
which will be supported until EOY 2025.
To disable this warning, add SAGIRI_DISABLE_NODE_FETCH_WARNING="true" in your environment variable.
`)
fetchFn = nodeFetch.default;
} else {
fetchFn = globalThis.fetch;
Expand Down

0 comments on commit 24c6585

Please sign in to comment.