@netlify/plugin-nextjs 5.0.0-beta.9 → 5.0.0-rc.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.
@@ -9,7 +9,7 @@ import {
9
9
  copyStaticContent,
10
10
  publishStaticDir,
11
11
  unpublishStaticDir
12
- } from "../../esm-chunks/chunk-ZWFKLYLH.js";
12
+ } from "../../esm-chunks/chunk-WQIG4U66.js";
13
13
  import "../../esm-chunks/chunk-VZNKO4OO.js";
14
14
  import "../../esm-chunks/chunk-TYCYFZ22.js";
15
15
  import "../../esm-chunks/chunk-5JVNISGM.js";
@@ -6,9 +6,9 @@
6
6
 
7
7
  import {
8
8
  createEdgeHandlers
9
- } from "../../esm-chunks/chunk-YIE34LVX.js";
9
+ } from "../../esm-chunks/chunk-UX4JCTAE.js";
10
10
  import "../../esm-chunks/chunk-VZNKO4OO.js";
11
- import "../../esm-chunks/chunk-DWC6JSN7.js";
11
+ import "../../esm-chunks/chunk-PGQNT7XM.js";
12
12
  import "../../esm-chunks/chunk-5JVNISGM.js";
13
13
  export {
14
14
  createEdgeHandlers
@@ -6,10 +6,10 @@
6
6
 
7
7
  import {
8
8
  createServerHandler
9
- } from "../../esm-chunks/chunk-T6AZTXZF.js";
9
+ } from "../../esm-chunks/chunk-FTCARYDZ.js";
10
10
  import "../../esm-chunks/chunk-4J4A5OE2.js";
11
11
  import "../../esm-chunks/chunk-VZNKO4OO.js";
12
- import "../../esm-chunks/chunk-DWC6JSN7.js";
12
+ import "../../esm-chunks/chunk-PGQNT7XM.js";
13
13
  import "../../esm-chunks/chunk-UYKENJEU.js";
14
14
  import "../../esm-chunks/chunk-5JVNISGM.js";
15
15
  export {
@@ -5,9 +5,11 @@
5
5
  })();
6
6
 
7
7
  import {
8
+ generateRegexFromPattern,
8
9
  setImageConfig
9
- } from "../esm-chunks/chunk-TOK7TKP3.js";
10
+ } from "../esm-chunks/chunk-XXBTIYSL.js";
10
11
  import "../esm-chunks/chunk-5JVNISGM.js";
11
12
  export {
13
+ generateRegexFromPattern,
12
14
  setImageConfig
13
15
  };
@@ -8,7 +8,7 @@ import {
8
8
  EDGE_HANDLER_NAME,
9
9
  PluginContext,
10
10
  SERVER_HANDLER_NAME
11
- } from "../esm-chunks/chunk-DWC6JSN7.js";
11
+ } from "../esm-chunks/chunk-PGQNT7XM.js";
12
12
  import "../esm-chunks/chunk-5JVNISGM.js";
13
13
  export {
14
14
  EDGE_HANDLER_NAME,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-VZNKO4OO.js";
15
15
  import {
16
16
  SERVER_HANDLER_NAME
17
- } from "./chunk-DWC6JSN7.js";
17
+ } from "./chunk-PGQNT7XM.js";
18
18
  import {
19
19
  __toESM
20
20
  } from "./chunk-5JVNISGM.js";
@@ -27,6 +27,10 @@ var PluginContext = class {
27
27
  get relPublishDir() {
28
28
  return this.constants.PUBLISH_DIR ?? join(this.packagePath, DEFAULT_PUBLISH_DIR);
29
29
  }
30
+ /** Temporary directory for stashing the build output */
31
+ get tempPublishDir() {
32
+ return this.resolve(".netlify/.next");
33
+ }
30
34
  /** Absolute path of the publish directory */
31
35
  get publishDir() {
32
36
  return resolve(this.relPublishDir);
@@ -0,0 +1,27 @@
1
+
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
+ return createRequire(import.meta.url);
5
+ })();
6
+
7
+
8
+ // src/run/revalidate.ts
9
+ var nextResponseProxy = (res, requestContext) => {
10
+ return new Proxy(res, {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ get(target, key) {
13
+ const originalValue = target[key];
14
+ if (key === "revalidate") {
15
+ return async function newRevalidate(...args) {
16
+ requestContext.didPagesRouterOnDemandRevalidate = true;
17
+ return originalValue?.apply(target, args);
18
+ };
19
+ }
20
+ return originalValue;
21
+ }
22
+ });
23
+ };
24
+
25
+ export {
26
+ nextResponseProxy
27
+ };
@@ -613,7 +613,7 @@ var adjustDateHeader = async ({
613
613
  headers.set("x-nextjs-date", headers.get("date") ?? lastModifiedDate.toUTCString());
614
614
  headers.set("date", lastModifiedDate.toUTCString());
615
615
  };
616
- var setCacheControlHeaders = (headers, request) => {
616
+ var setCacheControlHeaders = (headers, request, requestContext) => {
617
617
  const cacheControl = headers.get("cache-control");
618
618
  if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
619
619
  const browserCacheControl = omitHeaderValues(cacheControl, [
@@ -630,9 +630,16 @@ var setCacheControlHeaders = (headers, request) => {
630
630
  headers.set("cache-control", browserCacheControl || "public, max-age=0, must-revalidate");
631
631
  headers.set("netlify-cdn-cache-control", cdnCacheControl);
632
632
  }
633
+ if (cacheControl === null && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control") && requestContext.usedFsRead) {
634
+ headers.set("cache-control", "public, max-age=0, must-revalidate");
635
+ headers.set("netlify-cdn-cache-control", `max-age=31536000`);
636
+ }
633
637
  };
634
- var setCacheTagsHeaders = (headers, request, manifest) => {
635
- const path = new URL(request.url).pathname;
638
+ function getCanonicalPathFromCacheKey(cacheKey) {
639
+ return cacheKey === "/index" ? "/" : cacheKey;
640
+ }
641
+ var setCacheTagsHeaders = (headers, request, manifest, requestContext) => {
642
+ const path = getCanonicalPathFromCacheKey(requestContext.responseCacheKey) ?? new URL(request.url).pathname;
636
643
  const tags = manifest[path];
637
644
  if (tags !== void 0) {
638
645
  headers.set("netlify-cache-tag", tags);
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-VZNKO4OO.js";
10
10
  import {
11
11
  EDGE_HANDLER_NAME
12
- } from "./chunk-DWC6JSN7.js";
12
+ } from "./chunk-PGQNT7XM.js";
13
13
  import {
14
14
  __toESM
15
15
  } from "./chunk-5JVNISGM.js";
@@ -57,8 +57,9 @@ var copyStaticAssets = async (ctx) => {
57
57
  };
58
58
  var publishStaticDir = async (ctx) => {
59
59
  try {
60
- await mkdir(ctx.resolve(".netlify/.next"), { recursive: true });
61
- await rename(ctx.publishDir, ctx.resolve(".netlify/.next"));
60
+ await rm(ctx.tempPublishDir, { recursive: true, force: true });
61
+ await mkdir(ctx.tempPublishDir, { recursive: true });
62
+ await rename(ctx.publishDir, ctx.tempPublishDir);
62
63
  await rename(ctx.staticDir, ctx.publishDir);
63
64
  } catch (error) {
64
65
  ctx.failBuild("Failed publishing static content", error instanceof Error ? { error } : {});
@@ -66,9 +67,9 @@ var publishStaticDir = async (ctx) => {
66
67
  };
67
68
  var unpublishStaticDir = async (ctx) => {
68
69
  try {
69
- if (existsSync(ctx.resolve(".netlify/.next"))) {
70
+ if (existsSync(ctx.tempPublishDir)) {
70
71
  await rename(ctx.publishDir, ctx.staticDir);
71
- await rename(ctx.resolve(".netlify/.next"), ctx.publishDir);
72
+ await rename(ctx.tempPublishDir, ctx.publishDir);
72
73
  }
73
74
  } catch {
74
75
  }