@netlify/plugin-nextjs 5.7.0 → 5.7.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.
@@ -148,8 +148,8 @@ var writeCacheEntry = async (route, value, lastModified, ctx) => {
148
148
  await writeFile(path, entry, "utf-8");
149
149
  };
150
150
  var routeToFilePath = (path) => path === "/" ? "/index" : path;
151
- var buildPagesCacheValue = async (path) => ({
152
- kind: "PAGE",
151
+ var buildPagesCacheValue = async (path, shouldUseEnumKind) => ({
152
+ kind: shouldUseEnumKind ? "PAGES" : "PAGE",
153
153
  html: await readFile(`${path}.html`, "utf-8"),
154
154
  pageData: JSON.parse(await readFile(`${path}.json`, "utf-8")),
155
155
  headers: void 0,
@@ -181,8 +181,8 @@ var buildAppCacheValue = async (path, shouldUseAppPageKind) => {
181
181
  ...meta
182
182
  };
183
183
  };
184
- var buildRouteCacheValue = async (path, initialRevalidateSeconds) => ({
185
- kind: "ROUTE",
184
+ var buildRouteCacheValue = async (path, initialRevalidateSeconds, shouldUseEnumKind) => ({
185
+ kind: shouldUseEnumKind ? "APP_ROUTE" : "ROUTE",
186
186
  body: await readFile(`${path}.body`, "base64"),
187
187
  ...JSON.parse(await readFile(`${path}.meta`, "utf-8")),
188
188
  revalidate: initialRevalidateSeconds
@@ -200,6 +200,9 @@ var copyPrerenderedContent = async (ctx) => {
200
200
  const shouldUseAppPageKind = ctx.nextVersion ? (0, import_semver.satisfies)(ctx.nextVersion, ">=15.0.0-canary.13 <15.0.0-d || >15.0.0-rc.0", {
201
201
  includePrerelease: true
202
202
  }) : false;
203
+ const shouldUseEnumKind = ctx.nextVersion ? (0, import_semver.satisfies)(ctx.nextVersion, ">=15.0.0-canary.114 <15.0.0-d || >15.0.0-rc.0", {
204
+ includePrerelease: true
205
+ }) : false;
203
206
  await Promise.all(
204
207
  Object.entries(manifest.routes).map(
205
208
  ([route, meta]) => limitConcurrentPrerenderContentHandling(async () => {
@@ -213,7 +216,10 @@ var copyPrerenderedContent = async (ctx) => {
213
216
  if (manifest.notFoundRoutes.includes(route)) {
214
217
  return;
215
218
  }
216
- value = await buildPagesCacheValue(join(ctx.publishDir, "server/pages", key));
219
+ value = await buildPagesCacheValue(
220
+ join(ctx.publishDir, "server/pages", key),
221
+ shouldUseEnumKind
222
+ );
217
223
  break;
218
224
  case meta.dataRoute?.endsWith(".rsc"):
219
225
  value = await buildAppCacheValue(
@@ -224,13 +230,14 @@ var copyPrerenderedContent = async (ctx) => {
224
230
  case meta.dataRoute === null:
225
231
  value = await buildRouteCacheValue(
226
232
  join(ctx.publishDir, "server/app", key),
227
- meta.initialRevalidateSeconds
233
+ meta.initialRevalidateSeconds,
234
+ shouldUseEnumKind
228
235
  );
229
236
  break;
230
237
  default:
231
238
  throw new Error(`Unrecognized content: ${route}`);
232
239
  }
233
- if (value.kind === "PAGE" || value.kind === "APP_PAGE") {
240
+ if (value.kind === "PAGE" || value.kind === "PAGES" || value.kind === "APP_PAGE") {
234
241
  verifyNetlifyForms(ctx, value.html);
235
242
  }
236
243
  await writeCacheEntry(key, value, lastModified, ctx);
@@ -390,8 +390,10 @@ var require_dist = __commonJS({
390
390
  var import_fast_glob = __toESM(require_out(), 1);
391
391
  var import_path_to_regexp = __toESM(require_dist(), 1);
392
392
  import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
393
- import { dirname, join } from "node:path";
393
+ import { dirname, join, relative, sep } from "node:path";
394
+ import { sep as posixSep } from "node:path/posix";
394
395
  import { EDGE_HANDLER_NAME } from "../plugin-context.js";
396
+ var toPosixPath = (path) => path.split(sep).join(posixSep);
395
397
  var writeEdgeManifest = async (ctx, manifest) => {
396
398
  await mkdir(ctx.edgeFunctionsDir, { recursive: true });
397
399
  await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
@@ -458,10 +460,16 @@ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
458
460
  const shimPath = join(edgeRuntimeDir, "shim/index.js");
459
461
  const shim = await readFile(shimPath, "utf8");
460
462
  const parts = [shim];
463
+ const outputFile = join(destDir, `server/${name}.js`);
461
464
  if (wasm?.length) {
462
- parts.push(
463
- `import { decode as _base64Decode } from "../edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts";`
465
+ const base64ModulePath = join(
466
+ destDir,
467
+ "edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts"
464
468
  );
469
+ const base64ModulePathRelativeToOutputFile = toPosixPath(
470
+ relative(dirname(outputFile), base64ModulePath)
471
+ );
472
+ parts.push(`import { decode as _base64Decode } from "${base64ModulePathRelativeToOutputFile}";`);
465
473
  for (const wasmChunk of wasm ?? []) {
466
474
  const data = await readFile(join(srcDir, wasmChunk.filePath));
467
475
  parts.push(
@@ -477,8 +485,8 @@ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
477
485
  `, entrypoint);
478
486
  }
479
487
  const exports = `const middlewareEntryKey = Object.keys(_ENTRIES).find(entryKey => entryKey.startsWith("middleware_${name}")); export default _ENTRIES[middlewareEntryKey].default;`;
480
- await mkdir(dirname(join(destDir, `server/${name}.js`)), { recursive: true });
481
- await writeFile(join(destDir, `server/${name}.js`), [...parts, exports].join("\n"));
488
+ await mkdir(dirname(outputFile), { recursive: true });
489
+ await writeFile(outputFile, [...parts, exports].join("\n"));
482
490
  };
483
491
  var createEdgeHandler = async (ctx, definition) => {
484
492
  await copyHandlerDependencies(ctx, definition);
@@ -8,7 +8,7 @@ import "./chunk-OEQOKJGE.js";
8
8
 
9
9
  // package.json
10
10
  var name = "@netlify/plugin-nextjs";
11
- var version = "5.7.0";
11
+ var version = "5.7.1";
12
12
  var description = "Run Next.js seamlessly on Netlify";
13
13
  var main = "./dist/index.js";
14
14
  var type = "module";
@@ -63,7 +63,7 @@ var devDependencies = {
63
63
  "@netlify/edge-functions": "^2.10.0",
64
64
  "@netlify/eslint-config-node": "^7.0.1",
65
65
  "@netlify/functions": "^2.8.1",
66
- "@netlify/serverless-functions-api": "^1.22.0",
66
+ "@netlify/serverless-functions-api": "^1.23.0",
67
67
  "@netlify/zip-it-and-ship-it": "^9.37.3",
68
68
  "@opentelemetry/api": "^1.8.0",
69
69
  "@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
@@ -95,6 +95,7 @@ var pipeline = (0, import_util.promisify)(import_stream.pipeline);
95
95
 
96
96
  // src/run/handlers/cache.cts
97
97
  var import_constants = require("next/dist/lib/constants.js");
98
+ var import_cache_types = require("../../shared/cache-types.cjs");
98
99
  var import_regional_blob_store = require("../regional-blob-store.cjs");
99
100
  var import_request_context = require("./request-context.cjs");
100
101
  var import_tracer = require("./tracer.cjs");
@@ -166,11 +167,11 @@ var NetlifyCacheHandler = class {
166
167
  if (requestContext.responseCacheTags) {
167
168
  return;
168
169
  }
169
- if (cacheValue.kind === "PAGE" || cacheValue.kind === "APP_PAGE" || cacheValue.kind === "ROUTE") {
170
+ if (cacheValue.kind === "PAGE" || cacheValue.kind === "PAGES" || cacheValue.kind === "APP_PAGE" || cacheValue.kind === "ROUTE" || cacheValue.kind === "APP_ROUTE") {
170
171
  if (cacheValue.headers?.[import_constants.NEXT_CACHE_TAGS_HEADER]) {
171
172
  const cacheTags = cacheValue.headers[import_constants.NEXT_CACHE_TAGS_HEADER].split(",");
172
173
  requestContext.responseCacheTags = cacheTags;
173
- } else if (cacheValue.kind === "PAGE" && typeof cacheValue.pageData === "object") {
174
+ } else if ((cacheValue.kind === "PAGE" || cacheValue.kind === "PAGES") && typeof cacheValue.pageData === "object") {
174
175
  const cacheTags = [`_N_T_${key === "/index" ? "/" : key}`];
175
176
  requestContext.responseCacheTags = cacheTags;
176
177
  }
@@ -233,8 +234,12 @@ var NetlifyCacheHandler = class {
233
234
  lastModified: blob.lastModified,
234
235
  value: blob.value
235
236
  };
236
- case "ROUTE": {
237
- span.addEvent("ROUTE", { lastModified: blob.lastModified, status: blob.value.status });
237
+ case "ROUTE":
238
+ case "APP_ROUTE": {
239
+ span.addEvent(blob.value?.kind, {
240
+ lastModified: blob.lastModified,
241
+ status: blob.value.status
242
+ });
238
243
  const valueWithoutRevalidate = this.captureRouteRevalidateAndRemoveFromObject(blob.value);
239
244
  return {
240
245
  lastModified: blob.lastModified,
@@ -244,8 +249,9 @@ var NetlifyCacheHandler = class {
244
249
  }
245
250
  };
246
251
  }
247
- case "PAGE": {
248
- span.addEvent("PAGE", { lastModified: blob.lastModified });
252
+ case "PAGE":
253
+ case "PAGES": {
254
+ span.addEvent(blob.value?.kind, { lastModified: blob.lastModified });
249
255
  const { revalidate, ...restOfPageValue } = blob.value;
250
256
  await this.injectEntryToPrerenderManifest(key, revalidate);
251
257
  return {
@@ -254,7 +260,7 @@ var NetlifyCacheHandler = class {
254
260
  };
255
261
  }
256
262
  case "APP_PAGE": {
257
- span.addEvent("APP_PAGE", { lastModified: blob.lastModified });
263
+ span.addEvent(blob.value?.kind, { lastModified: blob.lastModified });
258
264
  const { revalidate, rscData, ...restOfPageValue } = blob.value;
259
265
  await this.injectEntryToPrerenderManifest(key, revalidate);
260
266
  return {
@@ -272,14 +278,17 @@ var NetlifyCacheHandler = class {
272
278
  });
273
279
  }
274
280
  transformToStorableObject(data, context) {
275
- if (data?.kind === "ROUTE") {
281
+ if (!data) {
282
+ return null;
283
+ }
284
+ if ((0, import_cache_types.isCachedRouteValue)(data)) {
276
285
  return {
277
286
  ...data,
278
287
  revalidate: context.revalidate,
279
288
  body: data.body.toString("base64")
280
289
  };
281
290
  }
282
- if (data?.kind === "PAGE") {
291
+ if ((0, import_cache_types.isCachedPageValue)(data)) {
283
292
  return {
284
293
  ...data,
285
294
  revalidate: context.revalidate
@@ -307,7 +316,7 @@ var NetlifyCacheHandler = class {
307
316
  lastModified,
308
317
  value
309
318
  });
310
- if (data?.kind === "PAGE") {
319
+ if (data?.kind === "PAGE" || data?.kind === "PAGES") {
311
320
  const requestContext = (0, import_request_context.getRequestContext)();
312
321
  if (requestContext?.didPagesRouterOnDemandRevalidate) {
313
322
  const tag = `_N_T_${key === "/index" ? "/" : key}`;
@@ -360,7 +369,7 @@ var NetlifyCacheHandler = class {
360
369
  let cacheTags = [];
361
370
  if (cacheEntry.value?.kind === "FETCH") {
362
371
  cacheTags = [...tags, ...softTags];
363
- } else if (cacheEntry.value?.kind === "PAGE" || cacheEntry.value?.kind === "APP_PAGE" || cacheEntry.value?.kind === "ROUTE") {
372
+ } else if (cacheEntry.value?.kind === "PAGE" || cacheEntry.value?.kind === "PAGES" || cacheEntry.value?.kind === "APP_PAGE" || cacheEntry.value?.kind === "ROUTE" || cacheEntry.value?.kind === "APP_ROUTE") {
364
373
  cacheTags = cacheEntry.value.headers?.[import_constants.NEXT_CACHE_TAGS_HEADER]?.split(",") || [];
365
374
  } else {
366
375
  return false;
@@ -67385,7 +67385,7 @@ var import_semantic_conventions = __toESM(require_src(), 1);
67385
67385
  import { getLogger } from "./request-context.cjs";
67386
67386
  var {
67387
67387
  default: { version, name }
67388
- } = await import("../../esm-chunks/package-KXKB2T7U.js");
67388
+ } = await import("../../esm-chunks/package-GZ5FMVI4.js");
67389
67389
  var sdk = new import_sdk_node.NodeSDK({
67390
67390
  resource: new import_resources.Resource({
67391
67391
  [import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: name,
package/dist/run/next.cjs CHANGED
@@ -494,6 +494,7 @@ var import_fs_monkey = __toESM(require_lib());
494
494
  var import_request_context = require("./handlers/request-context.cjs");
495
495
  var import_tracer = require("./handlers/tracer.cjs");
496
496
  var import_regional_blob_store = require("./regional-blob-store.cjs");
497
+ process.env.NODE_ENV = "production";
497
498
  console.time("import next server");
498
499
  var { getRequestHandlers } = require("next/dist/server/lib/start-server.js");
499
500
  var ResponseCache = require("next/dist/server/response-cache/index.js").default;
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,4 +19,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/shared/cache-types.cts
17
21
  var cache_types_exports = {};
22
+ __export(cache_types_exports, {
23
+ isCachedPageValue: () => isCachedPageValue,
24
+ isCachedRouteValue: () => isCachedRouteValue
25
+ });
18
26
  module.exports = __toCommonJS(cache_types_exports);
27
+ var isCachedPageValue = (value) => value.kind === "PAGE" || value.kind === "PAGES";
28
+ var isCachedRouteValue = (value) => value.kind === "ROUTE" || value.kind === "APP_ROUTE";
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ isCachedPageValue,
32
+ isCachedRouteValue
33
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.7.0",
3
+ "version": "5.7.1",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",