@netlify/plugin-nextjs 4.23.1 → 4.23.3

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.
@@ -5,6 +5,7 @@ exports.enableEdgeInNextConfig = exports.writeEdgeFunctions = exports.writeDevEd
5
5
  const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  const fs_extra_1 = require("fs-extra");
8
+ const config_1 = require("./config");
8
9
  const loadMiddlewareManifest = (netlifyConfig) => {
9
10
  const middlewarePath = (0, path_1.resolve)(netlifyConfig.build.publish, 'server', 'middleware-manifest.json');
10
11
  if (!(0, fs_1.existsSync)(middlewarePath)) {
@@ -107,6 +108,10 @@ const writeEdgeFunctions = async (netlifyConfig) => {
107
108
  const edgeFunctionRoot = (0, path_1.resolve)('.netlify', 'edge-functions');
108
109
  await (0, fs_extra_1.emptyDir)(edgeFunctionRoot);
109
110
  await (0, fs_extra_1.copy)(getEdgeTemplatePath('../edge-shared'), (0, path_1.join)(edgeFunctionRoot, 'edge-shared'));
111
+ const { publish } = netlifyConfig.build;
112
+ const nextConfigFile = await (0, config_1.getRequiredServerFiles)(publish);
113
+ const nextConfig = nextConfigFile.config;
114
+ await (0, fs_extra_1.writeJSON)((0, path_1.join)(edgeFunctionRoot, 'edge-shared', 'nextConfig.json'), nextConfig);
110
115
  if (!process.env.NEXT_DISABLE_EDGE_IMAGES) {
111
116
  console.log('Using Netlify Edge Functions for image format detection. Set env var "NEXT_DISABLE_EDGE_IMAGES=true" to disable.');
112
117
  const edgeFunctionDir = (0, path_1.join)(edgeFunctionRoot, 'ipx');
@@ -118,7 +123,7 @@ const writeEdgeFunctions = async (netlifyConfig) => {
118
123
  path: '/_next/image*',
119
124
  });
120
125
  }
121
- if (!process.env.NEXT_DISABLE_NETLIFY_EDGE) {
126
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1') {
122
127
  const middlewareManifest = await (0, exports.loadMiddlewareManifest)(netlifyConfig);
123
128
  if (!middlewareManifest) {
124
129
  console.error("Couldn't find the middleware manifest");
@@ -54,7 +54,7 @@ const matchesRewrite = (file, rewrites) => {
54
54
  exports.matchesRewrite = matchesRewrite;
55
55
  const getMiddleware = async (publish) => {
56
56
  var _a;
57
- if (!process.env.NEXT_DISABLE_NETLIFY_EDGE) {
57
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1') {
58
58
  return [];
59
59
  }
60
60
  const manifestPath = (0, pathe_1.join)(publish, 'server', 'middleware-manifest.json');
@@ -282,19 +282,19 @@ const baseServerReplacements = [
282
282
  const nextServerReplacements = [
283
283
  [
284
284
  `getMiddlewareManifest() {\n if (this.minimalMode) return null;`,
285
- `getMiddlewareManifest() {\n if (this.minimalMode || !process.env.NEXT_DISABLE_NETLIFY_EDGE) return null;`,
285
+ `getMiddlewareManifest() {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return null;`,
286
286
  ],
287
287
  [
288
288
  `generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode) return []`,
289
- `generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode || !process.env.NEXT_DISABLE_NETLIFY_EDGE) return [];`,
289
+ `generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return [];`,
290
290
  ],
291
291
  [
292
292
  `generateCatchAllMiddlewareRoute() {\n if (this.minimalMode) return undefined;`,
293
- `generateCatchAllMiddlewareRoute() {\n if (this.minimalMode || !process.env.NEXT_DISABLE_NETLIFY_EDGE) return undefined;`,
293
+ `generateCatchAllMiddlewareRoute() {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return undefined;`,
294
294
  ],
295
295
  [
296
296
  `getMiddlewareManifest() {\n if (this.minimalMode) {`,
297
- `getMiddlewareManifest() {\n if (!this.minimalMode && process.env.NEXT_DISABLE_NETLIFY_EDGE) {`,
297
+ `getMiddlewareManifest() {\n if (!this.minimalMode && (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1')) {`,
298
298
  ],
299
299
  ];
300
300
  const patchNextFiles = async (root) => {
package/lib/index.js CHANGED
@@ -49,21 +49,21 @@ const plugin = {
49
49
  let usingEdge = false;
50
50
  if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.functions) && Object.keys(middlewareManifest.functions).length !== 0) {
51
51
  usingEdge = true;
52
- if (process.env.NEXT_DISABLE_NETLIFY_EDGE) {
52
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1') {
53
53
  failBuild((0, outdent_1.outdent) `
54
54
  You are using Next.js experimental edge runtime, but have set NEXT_DISABLE_NETLIFY_EDGE to true. This is not supported.
55
- To use edge runtime, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`}.
55
+ To use edge runtime, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`} or set it to false.
56
56
  `);
57
57
  }
58
58
  }
59
59
  if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.middleware) && Object.keys(middlewareManifest.middleware).length !== 0) {
60
60
  usingEdge = true;
61
- if (process.env.NEXT_DISABLE_NETLIFY_EDGE) {
61
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1') {
62
62
  console.log((0, chalk_1.redBright)((0, outdent_1.outdent) `
63
63
  You are using Next.js Middleware without Netlify Edge Functions.
64
64
  This is deprecated because it negatively affects performance and will disable ISR and static rendering.
65
65
  It also disables advanced middleware features from @netlify/next
66
- To get the best performance and use Netlify Edge Functions, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`}.
66
+ To get the best performance and use Netlify Edge Functions, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`} or set it to false.
67
67
  `));
68
68
  }
69
69
  }
@@ -103,13 +103,13 @@ const makeHandler = (conf, app, pageRoot, staticManifest = [], mode = 'ssr') =>
103
103
  // Long-expiry TTL is basically no TTL, so we'll skip it
104
104
  if (ttl > 0 && ttl < ONE_YEAR_IN_SECONDS) {
105
105
  result.ttl = ttl;
106
- requestMode = 'isr';
106
+ requestMode = `odb ttl=${ttl}`;
107
107
  }
108
108
  }
109
109
  multiValueHeaders['cache-control'] = ['public, max-age=0, must-revalidate'];
110
110
  }
111
- multiValueHeaders['x-render-mode'] = [requestMode];
112
- console.log(`[${event.httpMethod}] ${event.path} (${requestMode === null || requestMode === void 0 ? void 0 : requestMode.toUpperCase()}${result.ttl > 0 ? ` ${result.ttl}s` : ''})`);
111
+ multiValueHeaders['x-nf-render-mode'] = [requestMode];
112
+ console.log(`[${event.httpMethod}] ${event.path} (${requestMode === null || requestMode === void 0 ? void 0 : requestMode.toUpperCase()})`);
113
113
  return {
114
114
  ...result,
115
115
  multiValueHeaders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "4.23.1",
3
+ "version": "4.23.3",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "manifest.yml"
11
11
  ],
12
12
  "dependencies": {
13
- "@netlify/esbuild": "0.14.25",
13
+ "@netlify/esbuild": "0.14.39",
14
14
  "@netlify/functions": "^1.2.0",
15
15
  "@netlify/ipx": "^1.2.5",
16
16
  "@vercel/node-bridge": "^2.1.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@delucis/if-env": "^1.1.2",
35
- "@netlify/build": "^27.17.2",
35
+ "@netlify/build": "^27.18.6",
36
36
  "@types/fs-extra": "^9.0.13",
37
37
  "@types/jest": "^27.4.1",
38
38
  "@types/merge-stream": "^1.1.2",
@@ -1,6 +1,7 @@
1
1
  import type { Context } from 'https://edge.netlify.com'
2
2
  // Available at build time
3
3
  import matchers from './matchers.json' assert { type: 'json' }
4
+ import nextConfig from '../edge-shared/nextConfig.json' assert { type: 'json' }
4
5
  import edgeFunction from './bundle.js'
5
6
  import { buildResponse } from '../edge-shared/utils.ts'
6
7
  import { getMiddlewareRouteMatcher, MiddlewareRouteMatch, searchParamsToUrlQuery } from '../edge-shared/next-utils.ts'
@@ -32,7 +33,7 @@ export interface RequestData {
32
33
  name?: string
33
34
  params?: { [key: string]: string }
34
35
  }
35
- url: string
36
+ url: URL
36
37
  body?: ReadableStream<Uint8Array>
37
38
  }
38
39
 
@@ -81,10 +82,11 @@ const handler = async (req: Request, context: Context) => {
81
82
  const request: RequestData = {
82
83
  headers: Object.fromEntries(req.headers.entries()),
83
84
  geo,
84
- url: url.toString(),
85
+ url,
85
86
  method: req.method,
86
87
  ip: context.ip,
87
88
  body: req.body ?? undefined,
89
+ nextConfig,
88
90
  }
89
91
 
90
92
  try {
File without changes