@netlify/plugin-nextjs 4.11.1 → 4.12.1
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.
package/lib/helpers/edge.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateConfig = exports.writeEdgeFunctions = exports.loadMiddlewareManifest = void 0;
|
|
4
|
+
/* eslint-disable max-lines */
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -80,7 +81,10 @@ const writeEdgeFunctions = async (netlifyConfig) => {
|
|
|
80
81
|
if (!process.env.NEXT_USE_NETLIFY_EDGE) {
|
|
81
82
|
console.log('Using Netlify Edge Functions for image format detection. Set env var "NEXT_DISABLE_EDGE_IMAGES=true" to disable.');
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
const edgeFunctionDir = (0, path_1.join)(edgeFunctionRoot, 'ipx');
|
|
85
|
+
await (0, fs_extra_1.ensureDir)(edgeFunctionDir);
|
|
86
|
+
await copyEdgeSourceFile({ edgeFunctionDir, file: 'ipx.ts', target: 'index.ts' });
|
|
87
|
+
await (0, fs_extra_1.copyFile)((0, path_1.join)('.netlify', 'functions-internal', '_ipx', 'imageconfig.json'), (0, path_1.join)(edgeFunctionDir, 'imageconfig.json'));
|
|
84
88
|
manifest.functions.push({
|
|
85
89
|
function: 'ipx',
|
|
86
90
|
path: '/_next/image*',
|
|
@@ -124,3 +128,4 @@ const updateConfig = async (publish) => {
|
|
|
124
128
|
await (0, fs_extra_1.writeJSON)(configFile, config);
|
|
125
129
|
};
|
|
126
130
|
exports.updateConfig = updateConfig;
|
|
131
|
+
/* eslint-enable max-lines */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.1",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@delucis/if-env": "^1.1.2",
|
|
31
|
-
"@netlify/build": "^27.3.
|
|
31
|
+
"@netlify/build": "^27.3.3",
|
|
32
32
|
"@types/fs-extra": "^9.0.13",
|
|
33
33
|
"@types/jest": "^27.4.1",
|
|
34
34
|
"@types/node": "^17.0.25",
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { Accepts } from "https://deno.land/x/accepts@2.1.1/mod.ts";
|
|
2
2
|
import type { Context } from "netlify:edge";
|
|
3
|
-
|
|
3
|
+
// Available at build time
|
|
4
|
+
import imageconfig from "./imageconfig.json" assert {
|
|
4
5
|
type: "json",
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
const defaultFormat = "webp"
|
|
8
9
|
|
|
10
|
+
interface ImageConfig extends Record<string, unknown> {
|
|
11
|
+
formats?: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* Implement content negotiation for images
|
|
11
16
|
*/
|
|
@@ -14,7 +19,7 @@ const defaultFormat = "webp"
|
|
|
14
19
|
const handler = async (req: Request, context: Context) => {
|
|
15
20
|
const { searchParams } = new URL(req.url);
|
|
16
21
|
const accept = new Accepts(req.headers);
|
|
17
|
-
const { formats = [defaultFormat] } = imageconfig;
|
|
22
|
+
const { formats = [defaultFormat] } = imageconfig as ImageConfig;
|
|
18
23
|
if (formats.length === 0) {
|
|
19
24
|
formats.push(defaultFormat);
|
|
20
25
|
}
|