@opennextjs/aws 3.10.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
//#override imports
|
|
2
2
|
import { fetchExternalImage, fetchInternalImage, imageOptimizer, } from "next/dist/server/image-optimizer";
|
|
3
|
+
import { compareSemver } from "../../../utils/semver.js";
|
|
3
4
|
import { debug } from "../../logger.js";
|
|
4
5
|
//#override optimizeImage
|
|
5
6
|
export async function optimizeImage(headers, imageParams, nextConfig, handleRequest) {
|
|
6
7
|
const { isAbsolute, href } = imageParams;
|
|
8
|
+
// Signature for the fetch Image functions have changed in Next.js 15.5.16 and 16.2.5, so we need to check the version to determine how to call them.
|
|
9
|
+
const isAfter1625 = compareSemver(globalThis.nextVersion, ">=", "16.2.5");
|
|
10
|
+
const isAfter15516 = compareSemver(globalThis.nextVersion, ">=", "15.5.16") &&
|
|
11
|
+
compareSemver(globalThis.nextVersion, "<", "16");
|
|
12
|
+
const isNewArgsForInternalFetch = isAfter1625 || isAfter15516;
|
|
13
|
+
// The default value for maximumResponseBody is 50KB in Next code
|
|
14
|
+
// https://github.com/vercel/next.js/blob/0f38c522/packages/next/src/shared/lib/image-config.ts#L164
|
|
15
|
+
const maximumResponseBody = nextConfig.images?.maximumResponseBody || 50_000_000;
|
|
7
16
|
const imageUpstream = isAbsolute
|
|
8
|
-
?
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
? // https://github.com/vercel/next.js/blob/bfe2ab4/packages/next/src/server/image-optimizer.ts#L711
|
|
18
|
+
await (isNewArgsForInternalFetch
|
|
19
|
+
? fetchExternalImage(href, false, maximumResponseBody)
|
|
20
|
+
: //@ts-expect-error - fetchExternalImage signature has changed in Next.js 16, it has an extra boolean parameter.
|
|
21
|
+
fetchExternalImage(href))
|
|
22
|
+
: await (isNewArgsForInternalFetch
|
|
23
|
+
? fetchInternalImage(href,
|
|
24
|
+
// @ts-expect-error - It is supposed to be an IncomingMessage object, but only the headers are used.
|
|
25
|
+
{ headers }, {}, // res object is not necessary as it's not actually used.
|
|
26
|
+
maximumResponseBody, handleRequest)
|
|
27
|
+
: // @ts-expect-error - fetchInternalImage signature has changed in Next.js 15.5.16 and 16.2.5
|
|
28
|
+
fetchInternalImage(href, { headers }, {}, // res object is not necessary as it's not actually used.
|
|
29
|
+
handleRequest));
|
|
15
30
|
const result = await imageOptimizer(imageUpstream, imageParams,
|
|
16
31
|
// @ts-ignore
|
|
17
32
|
nextConfig, false);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"access": "public"
|
|
4
4
|
},
|
|
5
5
|
"name": "@opennextjs/aws",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "4.0.0",
|
|
7
7
|
"bin": {
|
|
8
8
|
"open-next": "./dist/index.js"
|
|
9
9
|
},
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"typescript": "5.9.3"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"next": ">=15.5.
|
|
63
|
+
"next": ">=15.5.16 <16 || >=16.2.5"
|
|
64
64
|
},
|
|
65
65
|
"bugs": {
|
|
66
66
|
"url": "https://github.com/opennextjs/opennextjs-aws/issues"
|