diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aaab14f1..f89764a1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,8 @@ jobs: strategy: matrix: - deno-version: [latest, rc] + # deno-version: [latest, rc] + deno-version: [latest] steps: - uses: actions/checkout@v4.2.2 diff --git a/bun.lockb b/bun.lockb index 334d498b..f4f4c640 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 6008065a..7467604c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sagiri", - "version": "4.2.3", + "version": "4.3.0", "description": "A simple, lightweight and actually good JS wrapper for the SauceNAO API.", "license": "MIT", "main": "./dist/sagiri.cjs", @@ -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" } } diff --git a/src/sagiri.ts b/src/sagiri.ts index ba74af15..0df22a77 100644 --- a/src/sagiri.ts +++ b/src/sagiri.ts @@ -1,4 +1,3 @@ -import * as nodeFetch from "node-fetch"; import type { IOptions } from "./interfaces"; import { env } from "node:process"; import { Buffer } from "node:buffer"; @@ -8,13 +7,26 @@ import FormData from "form-data"; import { generateMask, resolveResult } from "./util"; import { SagiriClientError, SagiriServerError } from "./errors"; import type { IResponse, IResult } from "./response"; +import * as process from "node:process"; 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) { - fetchFn = nodeFetch.default; + 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. + `) + + // eslint-disable-next-line @typescript-eslint/no-require-imports + fetchFn = require("node-fetch"); } else { fetchFn = globalThis.fetch; }