@netlify/plugin-nextjs 5.7.0-ipx.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,9 +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";
395
- import { createIpxEdgeAcceptHandler } from "./ipx.js";
396
+ var toPosixPath = (path) => path.split(sep).join(posixSep);
396
397
  var writeEdgeManifest = async (ctx, manifest) => {
397
398
  await mkdir(ctx.edgeFunctionsDir, { recursive: true });
398
399
  await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
@@ -459,10 +460,16 @@ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
459
460
  const shimPath = join(edgeRuntimeDir, "shim/index.js");
460
461
  const shim = await readFile(shimPath, "utf8");
461
462
  const parts = [shim];
463
+ const outputFile = join(destDir, `server/${name}.js`);
462
464
  if (wasm?.length) {
463
- parts.push(
464
- `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"
465
468
  );
469
+ const base64ModulePathRelativeToOutputFile = toPosixPath(
470
+ relative(dirname(outputFile), base64ModulePath)
471
+ );
472
+ parts.push(`import { decode as _base64Decode } from "${base64ModulePathRelativeToOutputFile}";`);
466
473
  for (const wasmChunk of wasm ?? []) {
467
474
  const data = await readFile(join(srcDir, wasmChunk.filePath));
468
475
  parts.push(
@@ -477,9 +484,9 @@ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
477
484
  parts.push(`;// Concatenated file: ${file}
478
485
  `, entrypoint);
479
486
  }
480
- const exports = `export default _ENTRIES["middleware_${name}"].default;`;
481
- await mkdir(dirname(join(destDir, `server/${name}.js`)), { recursive: true });
482
- await writeFile(join(destDir, `server/${name}.js`), [...parts, exports].join("\n"));
487
+ const exports = `const middlewareEntryKey = Object.keys(_ENTRIES).find(entryKey => entryKey.startsWith("middleware_${name}")); export default _ENTRIES[middlewareEntryKey].default;`;
488
+ await mkdir(dirname(outputFile), { recursive: true });
489
+ await writeFile(outputFile, [...parts, exports].join("\n"));
483
490
  };
484
491
  var createEdgeHandler = async (ctx, definition) => {
485
492
  await copyHandlerDependencies(ctx, definition);
@@ -514,9 +521,6 @@ var createEdgeHandlers = async (ctx) => {
514
521
  version: 1,
515
522
  functions: netlifyDefinitions
516
523
  };
517
- if (ctx.imageService === "ipx") {
518
- await createIpxEdgeAcceptHandler(ctx, netlifyManifest);
519
- }
520
524
  await writeEdgeManifest(ctx, netlifyManifest);
521
525
  };
522
526
  export {
@@ -1528,7 +1528,6 @@ var require_picomatch2 = __commonJS({
1528
1528
 
1529
1529
  // src/build/image-cdn.ts
1530
1530
  var import_picomatch = __toESM(require_picomatch2(), 1);
1531
- import { createIpxHandler } from "./functions/ipx.js";
1532
1531
  function generateRegexFromPattern(pattern) {
1533
1532
  return (0, import_picomatch.makeRe)(pattern).source;
1534
1533
  }
@@ -1539,71 +1538,67 @@ var setImageConfig = async (ctx) => {
1539
1538
  if (imageLoader !== "default") {
1540
1539
  return;
1541
1540
  }
1542
- if (ctx.imageService === "ipx") {
1543
- await createIpxHandler(ctx);
1544
- } else {
1545
- ctx.netlifyConfig.redirects.push(
1546
- {
1547
- from: imageEndpointPath,
1548
- // w and q are too short to be used as params with id-length rule
1549
- // but we are forced to do so because of the next/image loader decides on their names
1550
- // eslint-disable-next-line id-length
1551
- query: { url: ":url", w: ":width", q: ":quality" },
1552
- to: "/.netlify/images?url=:url&w=:width&q=:quality",
1553
- status: 200
1554
- },
1555
- // when migrating from @netlify/plugin-nextjs@4 image redirect to ipx might be cached in the browser
1556
- {
1557
- from: "/_ipx/*",
1558
- // w and q are too short to be used as params with id-length rule
1559
- // but we are forced to do so because of the next/image loader decides on their names
1560
- // eslint-disable-next-line id-length
1561
- query: { url: ":url", w: ":width", q: ":quality" },
1562
- to: "/.netlify/images?url=:url&w=:width&q=:quality",
1563
- status: 200
1564
- }
1565
- );
1566
- if (remotePatterns?.length !== 0 || domains?.length !== 0) {
1567
- ctx.netlifyConfig.images ||= { remote_images: [] };
1568
- ctx.netlifyConfig.images.remote_images ||= [];
1569
- if (remotePatterns && remotePatterns.length !== 0) {
1570
- for (const remotePattern of remotePatterns) {
1571
- let { protocol, hostname, port, pathname } = remotePattern;
1572
- if (pathname) {
1573
- pathname = pathname.startsWith("/") ? pathname : `/${pathname}`;
1574
- }
1575
- const combinedRemotePattern = `${protocol ?? "http?(s)"}://${hostname}${port ? `:${port}` : ""}${pathname ?? "/**"}`;
1576
- try {
1577
- ctx.netlifyConfig.images.remote_images.push(
1578
- generateRegexFromPattern(combinedRemotePattern)
1579
- );
1580
- } catch (error) {
1581
- ctx.failBuild(
1582
- `Failed to generate Image CDN remote image regex from Next.js remote pattern: ${JSON.stringify(
1583
- { remotePattern, combinedRemotePattern },
1584
- null,
1585
- 2
1586
- )}`,
1587
- error
1588
- );
1589
- }
1541
+ ctx.netlifyConfig.redirects.push(
1542
+ {
1543
+ from: imageEndpointPath,
1544
+ // w and q are too short to be used as params with id-length rule
1545
+ // but we are forced to do so because of the next/image loader decides on their names
1546
+ // eslint-disable-next-line id-length
1547
+ query: { url: ":url", w: ":width", q: ":quality" },
1548
+ to: "/.netlify/images?url=:url&w=:width&q=:quality",
1549
+ status: 200
1550
+ },
1551
+ // when migrating from @netlify/plugin-nextjs@4 image redirect to ipx might be cached in the browser
1552
+ {
1553
+ from: "/_ipx/*",
1554
+ // w and q are too short to be used as params with id-length rule
1555
+ // but we are forced to do so because of the next/image loader decides on their names
1556
+ // eslint-disable-next-line id-length
1557
+ query: { url: ":url", w: ":width", q: ":quality" },
1558
+ to: "/.netlify/images?url=:url&w=:width&q=:quality",
1559
+ status: 200
1560
+ }
1561
+ );
1562
+ if (remotePatterns?.length !== 0 || domains?.length !== 0) {
1563
+ ctx.netlifyConfig.images ||= { remote_images: [] };
1564
+ ctx.netlifyConfig.images.remote_images ||= [];
1565
+ if (remotePatterns && remotePatterns.length !== 0) {
1566
+ for (const remotePattern of remotePatterns) {
1567
+ let { protocol, hostname, port, pathname } = remotePattern;
1568
+ if (pathname) {
1569
+ pathname = pathname.startsWith("/") ? pathname : `/${pathname}`;
1570
+ }
1571
+ const combinedRemotePattern = `${protocol ?? "http?(s)"}://${hostname}${port ? `:${port}` : ""}${pathname ?? "/**"}`;
1572
+ try {
1573
+ ctx.netlifyConfig.images.remote_images.push(
1574
+ generateRegexFromPattern(combinedRemotePattern)
1575
+ );
1576
+ } catch (error) {
1577
+ ctx.failBuild(
1578
+ `Failed to generate Image CDN remote image regex from Next.js remote pattern: ${JSON.stringify(
1579
+ { remotePattern, combinedRemotePattern },
1580
+ null,
1581
+ 2
1582
+ )}`,
1583
+ error
1584
+ );
1590
1585
  }
1591
1586
  }
1592
- if (domains && domains.length !== 0) {
1593
- for (const domain of domains) {
1594
- const patternFromDomain = `http?(s)://${domain}/**`;
1595
- try {
1596
- ctx.netlifyConfig.images.remote_images.push(generateRegexFromPattern(patternFromDomain));
1597
- } catch (error) {
1598
- ctx.failBuild(
1599
- `Failed to generate Image CDN remote image regex from Next.js domain: ${JSON.stringify(
1600
- { domain, patternFromDomain },
1601
- null,
1602
- 2
1603
- )}`,
1604
- error
1605
- );
1606
- }
1587
+ }
1588
+ if (domains && domains.length !== 0) {
1589
+ for (const domain of domains) {
1590
+ const patternFromDomain = `http?(s)://${domain}/**`;
1591
+ try {
1592
+ ctx.netlifyConfig.images.remote_images.push(generateRegexFromPattern(patternFromDomain));
1593
+ } catch (error) {
1594
+ ctx.failBuild(
1595
+ `Failed to generate Image CDN remote image regex from Next.js domain: ${JSON.stringify(
1596
+ { domain, patternFromDomain },
1597
+ null,
1598
+ 2
1599
+ )}`,
1600
+ error
1601
+ );
1607
1602
  }
1608
1603
  }
1609
1604
  }
@@ -23,7 +23,6 @@ var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
23
23
  var PLUGIN_DIR = join(MODULE_DIR, "../..");
24
24
  var DEFAULT_PUBLISH_DIR = ".next";
25
25
  var SERVER_HANDLER_NAME = "___netlify-server-handler";
26
- var IPX_HANDLER_NAME = "_ipx";
27
26
  var EDGE_HANDLER_NAME = "___netlify-edge-handler";
28
27
  var PluginContext = class {
29
28
  featureFlags;
@@ -117,9 +116,6 @@ var PluginContext = class {
117
116
  const REQUIRED_BUILD_VERSION = ">=29.41.5";
118
117
  return (0, import_semver.satisfies)(this.buildVersion, REQUIRED_BUILD_VERSION, { includePrerelease: true });
119
118
  }
120
- get imageService() {
121
- return "ipx";
122
- }
123
119
  /**
124
120
  * Absolute path of the directory containing the files for the serverless lambda function
125
121
  * `.netlify/functions-internal`
@@ -131,10 +127,6 @@ var PluginContext = class {
131
127
  get serverHandlerRootDir() {
132
128
  return join(this.serverFunctionsDir, SERVER_HANDLER_NAME);
133
129
  }
134
- /** Absolute path of the ipx handler */
135
- get ipxHandlerRootDir() {
136
- return join(this.serverFunctionsDir, IPX_HANDLER_NAME);
137
- }
138
130
  get serverHandlerDir() {
139
131
  if (this.relativeAppDir.length === 0) {
140
132
  return this.serverHandlerRootDir;
@@ -161,10 +153,6 @@ var PluginContext = class {
161
153
  get edgeHandlerDir() {
162
154
  return join(this.edgeFunctionsDir, EDGE_HANDLER_NAME);
163
155
  }
164
- /** Absolute path of the ipx edge handler */
165
- get ipxEdgeHandlerRootDir() {
166
- return join(this.edgeFunctionsDir, IPX_HANDLER_NAME);
167
- }
168
156
  constructor(options) {
169
157
  this.constants = options.constants;
170
158
  this.featureFlags = options.featureFlags;
@@ -288,7 +276,6 @@ var PluginContext = class {
288
276
  };
289
277
  export {
290
278
  EDGE_HANDLER_NAME,
291
- IPX_HANDLER_NAME,
292
279
  PluginContext,
293
280
  SERVER_HANDLER_NAME
294
281
  };
@@ -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-ipx.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";
@@ -55,9 +55,6 @@ var bugs = {
55
55
  url: "https://github.com/netlify/next-runtime/issues"
56
56
  };
57
57
  var homepage = "https://github.com/netlify/next-runtime#readme";
58
- var dependencies = {
59
- "@netlify/ipx": "^1.4.6"
60
- };
61
58
  var devDependencies = {
62
59
  "@fastly/http-compute-js": "1.1.4",
63
60
  "@netlify/blobs": "^7.3.0",
@@ -66,7 +63,7 @@ var devDependencies = {
66
63
  "@netlify/edge-functions": "^2.10.0",
67
64
  "@netlify/eslint-config-node": "^7.0.1",
68
65
  "@netlify/functions": "^2.8.1",
69
- "@netlify/serverless-functions-api": "^1.22.0",
66
+ "@netlify/serverless-functions-api": "^1.23.0",
70
67
  "@netlify/zip-it-and-ship-it": "^9.37.3",
71
68
  "@opentelemetry/api": "^1.8.0",
72
69
  "@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
@@ -107,6 +104,7 @@ var clean_package = {
107
104
  indent: 2,
108
105
  remove: [
109
106
  "clean-package",
107
+ "dependencies",
110
108
  "devDependencies",
111
109
  "scripts"
112
110
  ]
@@ -125,7 +123,6 @@ var package_default = {
125
123
  license,
126
124
  bugs,
127
125
  homepage,
128
- dependencies,
129
126
  devDependencies,
130
127
  "clean-package": clean_package
131
128
  };
@@ -133,7 +130,6 @@ export {
133
130
  bugs,
134
131
  clean_package as "clean-package",
135
132
  package_default as default,
136
- dependencies,
137
133
  description,
138
134
  devDependencies,
139
135
  engines,
@@ -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;
@@ -3161,8 +3161,7 @@ var server_default = async (request, context) => {
3161
3161
  span.setAttribute("responseCacheKey", requestContext.responseCacheKey);
3162
3162
  }
3163
3163
  await adjustDateHeader({ headers: response.headers, request, span, tracer, requestContext });
3164
- const useDurableCache = context.flags.get("serverless_functions_nextjs_durable_cache_disable") !== true;
3165
- setCacheControlHeaders(response.headers, request, requestContext, useDurableCache);
3164
+ setCacheControlHeaders(response.headers, request, requestContext);
3166
3165
  setCacheTagsHeaders(response.headers, requestContext);
3167
3166
  setVaryHeaders(response.headers, request, nextConfig);
3168
3167
  setCacheStatusHeader(response.headers);
@@ -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-O63J727E.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,
@@ -142,12 +142,11 @@ var adjustDateHeader = async ({
142
142
  headers.set("x-nextjs-date", headers.get("date") ?? lastModifiedDate.toUTCString());
143
143
  headers.set("date", lastModifiedDate.toUTCString());
144
144
  };
145
- var setCacheControlHeaders = (headers, request, requestContext, useDurableCache) => {
146
- const durableCacheDirective = useDurableCache ? ", durable" : "";
145
+ var setCacheControlHeaders = (headers, request, requestContext) => {
147
146
  if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
148
147
  const cdnCacheControl = (
149
148
  // if we are serving already stale response, instruct edge to not attempt to cache that response
150
- headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate" : `s-maxage=${requestContext.routeHandlerRevalidate === false ? 31536e3 : requestContext.routeHandlerRevalidate}, stale-while-revalidate=31536000${durableCacheDirective}`
149
+ headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate" : `s-maxage=${requestContext.routeHandlerRevalidate === false ? 31536e3 : requestContext.routeHandlerRevalidate}, stale-while-revalidate=31536000, durable`
151
150
  );
152
151
  headers.set("netlify-cdn-cache-control", cdnCacheControl);
153
152
  return;
@@ -164,7 +163,7 @@ var setCacheControlHeaders = (headers, request, requestContext, useDurableCache)
164
163
  ...getHeaderValueArray(cacheControl).map(
165
164
  (value) => value === "stale-while-revalidate" ? "stale-while-revalidate=31536000" : value
166
165
  ),
167
- ...useDurableCache ? ["durable"] : []
166
+ "durable"
168
167
  ].join(", ")
169
168
  );
170
169
  headers.set("cache-control", browserCacheControl || "public, max-age=0, must-revalidate");
@@ -173,7 +172,7 @@ var setCacheControlHeaders = (headers, request, requestContext, useDurableCache)
173
172
  }
174
173
  if (cacheControl === null && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control") && requestContext.usedFsRead) {
175
174
  headers.set("cache-control", "public, max-age=0, must-revalidate");
176
- headers.set("netlify-cdn-cache-control", `max-age=31536000${durableCacheDirective}`);
175
+ headers.set("netlify-cdn-cache-control", `max-age=31536000, durable`);
177
176
  }
178
177
  };
179
178
  var setCacheTagsHeaders = (headers, requestContext) => {
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-ipx.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",
@@ -26,8 +26,5 @@
26
26
  "bugs": {
27
27
  "url": "https://github.com/netlify/next-runtime/issues"
28
28
  },
29
- "homepage": "https://github.com/netlify/next-runtime#readme",
30
- "dependencies": {
31
- "@netlify/ipx": "^1.4.6"
32
- }
29
+ "homepage": "https://github.com/netlify/next-runtime#readme"
33
30
  }
@@ -1,83 +0,0 @@
1
-
2
- var require = await (async () => {
3
- var { createRequire } = await import("node:module");
4
- return createRequire(import.meta.url);
5
- })();
6
-
7
- import "../../esm-chunks/chunk-OEQOKJGE.js";
8
-
9
- // src/build/functions/ipx.ts
10
- import { cp, mkdir, writeFile } from "fs/promises";
11
- import { join } from "path";
12
- import { IPX_HANDLER_NAME } from "../plugin-context.js";
13
- var sanitizeEdgePath = (imagesPath) => new URL(imagesPath, process.env.URL || "http://n").pathname;
14
- var getAdjustedImageConfig = (ctx) => {
15
- return {
16
- ...ctx.buildConfig.images,
17
- basePath: [ctx.buildConfig.basePath, IPX_HANDLER_NAME].join("/")
18
- };
19
- };
20
- var createIpxHandler = async (ctx) => {
21
- await mkdir(ctx.ipxHandlerRootDir, { recursive: true });
22
- await cp(
23
- join(ctx.pluginDir, "dist/build/templates/ipx.ts"),
24
- join(ctx.ipxHandlerRootDir, "_ipx.ts")
25
- );
26
- await writeFile(
27
- join(ctx.ipxHandlerRootDir, "imageconfig.json"),
28
- JSON.stringify(getAdjustedImageConfig(ctx))
29
- );
30
- await writeFile(
31
- join(ctx.ipxHandlerRootDir, "_ipx.json"),
32
- JSON.stringify({
33
- version: 1,
34
- config: {
35
- name: "next/image handler",
36
- generator: `${ctx.pluginName}@${ctx.pluginVersion}`,
37
- timeout: 120
38
- }
39
- })
40
- );
41
- ctx.netlifyConfig.redirects.push(
42
- {
43
- from: ctx.buildConfig.images.path,
44
- // eslint-disable-next-line id-length
45
- query: { url: ":url", w: ":width", q: ":quality" },
46
- to: `${ctx.buildConfig.basePath}/${IPX_HANDLER_NAME}/w_:width,q_:quality/:url`,
47
- status: 301
48
- },
49
- {
50
- from: `${ctx.buildConfig.basePath}/${IPX_HANDLER_NAME}/*`,
51
- to: `/.netlify/builders/${IPX_HANDLER_NAME}`,
52
- status: 200
53
- }
54
- );
55
- };
56
- var createIpxEdgeAcceptHandler = async (ctx, netlifyManifest) => {
57
- await mkdir(ctx.ipxEdgeHandlerRootDir, { recursive: true });
58
- await cp(
59
- join(ctx.pluginDir, "dist/build/templates/ipx-edge-accept-handler.ts"),
60
- join(ctx.ipxEdgeHandlerRootDir, "index.ts")
61
- );
62
- await writeFile(
63
- join(ctx.ipxEdgeHandlerRootDir, "imageconfig.json"),
64
- JSON.stringify(getAdjustedImageConfig(ctx))
65
- );
66
- netlifyManifest.functions.push({
67
- function: IPX_HANDLER_NAME,
68
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
69
- // @ts-ignore
70
- name: "next/image handler",
71
- path: ctx.buildConfig.images.path ? sanitizeEdgePath(ctx.buildConfig.images.path) : "/_next/image",
72
- generator: `${ctx.pluginName}@${ctx.pluginVersion}`
73
- });
74
- netlifyManifest.layers ??= [];
75
- netlifyManifest.layers.push({
76
- name: `https://ipx-edge-function-layer.netlify.app/mod.ts`,
77
- flag: "ipx-edge-function-layer-url"
78
- });
79
- };
80
- export {
81
- createIpxEdgeAcceptHandler,
82
- createIpxHandler
83
- };
@@ -1,13 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-ignore
3
- import { getHandler } from 'https://ipx-edge-function-layer.netlify.app/mod.ts'
4
-
5
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
- // @ts-ignore Injected at build time
7
- import imageconfig from './imageconfig.json' assert { type: 'json' }
8
-
9
- export default getHandler({
10
- formats: imageconfig?.formats,
11
- basePath: imageconfig?.basePath,
12
- imageCDNCompat: true,
13
- })
@@ -1,11 +0,0 @@
1
- import { createIPXHandler } from '@netlify/ipx'
2
-
3
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
- // @ts-ignore Injected at build time
5
- import { basePath, domains, remotePatterns } from './imageconfig.json'
6
-
7
- export const handler = createIPXHandler({
8
- basePath,
9
- domains,
10
- remotePatterns,
11
- })