@netlify/plugin-nextjs 5.0.0-beta.9 → 5.0.0-rc.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/dist/build/content/static.js +1 -1
- package/dist/build/functions/edge.js +2 -2
- package/dist/build/functions/server.js +2 -2
- package/dist/build/image-cdn.js +3 -1
- package/dist/build/plugin-context.js +1 -1
- package/dist/esm-chunks/{chunk-NL5YH5N6.js → chunk-3SUDZQ7L.js} +1 -1
- package/dist/esm-chunks/{chunk-DWC6JSN7.js → chunk-655Y7ISI.js} +23 -7
- package/dist/esm-chunks/{chunk-T6AZTXZF.js → chunk-GAZUUVZW.js} +1 -1
- package/dist/esm-chunks/chunk-RL4K4CVH.js +27 -0
- package/dist/esm-chunks/{chunk-AU7XDLZH.js → chunk-UTCWWUFW.js} +10 -3
- package/dist/esm-chunks/{chunk-ZWFKLYLH.js → chunk-WQIG4U66.js} +5 -4
- package/dist/esm-chunks/chunk-XXBTIYSL.js +7199 -0
- package/dist/esm-chunks/chunk-ZZOGIP2V.js +531 -0
- package/dist/esm-chunks/{package-6DFWHFJA.js → package-QW5XSFQ4.js} +9 -5
- package/dist/index.js +8 -13
- package/dist/run/config.js +1 -1
- package/dist/run/handlers/cache.cjs +10 -0
- package/dist/run/handlers/server.js +6 -6
- package/dist/run/handlers/tracing.js +1 -1
- package/dist/run/headers.js +1 -1
- package/dist/run/next.cjs +6 -1
- package/dist/run/revalidate.js +1 -1
- package/edge-runtime/lib/next-request.ts +14 -9
- package/edge-runtime/lib/response.ts +4 -3
- package/edge-runtime/lib/util.ts +1 -1
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-TOK7TKP3.js +0 -28
- package/dist/esm-chunks/chunk-WT2HN3M6.js +0 -255
- package/dist/esm-chunks/chunk-YIE34LVX.js +0 -134
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
copyStaticContent,
|
|
10
10
|
publishStaticDir,
|
|
11
11
|
unpublishStaticDir
|
|
12
|
-
} from "../../esm-chunks/chunk-
|
|
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-
|
|
9
|
+
} from "../../esm-chunks/chunk-ZZOGIP2V.js";
|
|
10
10
|
import "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
11
|
-
import "../../esm-chunks/chunk-
|
|
11
|
+
import "../../esm-chunks/chunk-655Y7ISI.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-
|
|
9
|
+
} from "../../esm-chunks/chunk-GAZUUVZW.js";
|
|
10
10
|
import "../../esm-chunks/chunk-4J4A5OE2.js";
|
|
11
11
|
import "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
12
|
-
import "../../esm-chunks/chunk-
|
|
12
|
+
import "../../esm-chunks/chunk-655Y7ISI.js";
|
|
13
13
|
import "../../esm-chunks/chunk-UYKENJEU.js";
|
|
14
14
|
import "../../esm-chunks/chunk-5JVNISGM.js";
|
|
15
15
|
export {
|
package/dist/build/image-cdn.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
+
generateRegexFromPattern,
|
|
8
9
|
setImageConfig
|
|
9
|
-
} from "../esm-chunks/chunk-
|
|
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
|
};
|
|
@@ -14,7 +14,7 @@ import { existsSync } from "node:fs";
|
|
|
14
14
|
import { readFile } from "node:fs/promises";
|
|
15
15
|
import { join, resolve } from "node:path";
|
|
16
16
|
var getRunConfig = async () => {
|
|
17
|
-
return JSON.parse(await readFile(resolve(RUN_CONFIG), "utf-8"));
|
|
17
|
+
return JSON.parse(await readFile(resolve(PLUGIN_DIR, RUN_CONFIG), "utf-8"));
|
|
18
18
|
};
|
|
19
19
|
var setRunConfig = (config) => {
|
|
20
20
|
const cacheHandler = join(PLUGIN_DIR, ".netlify/dist/run/handlers/cache.cjs");
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// src/build/plugin-context.ts
|
|
9
|
-
import { readFileSync } from "node:fs";
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
10
10
|
import { readFile } from "node:fs/promises";
|
|
11
11
|
import { join, relative, resolve } from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
@@ -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);
|
|
@@ -43,7 +47,7 @@ var PluginContext = class {
|
|
|
43
47
|
* The working directory inside the lambda that is used for monorepos to execute the serverless function
|
|
44
48
|
*/
|
|
45
49
|
get lambdaWorkingDirectory() {
|
|
46
|
-
return join("/var/task", this.
|
|
50
|
+
return join("/var/task", this.distDirParent);
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
53
|
* Retrieves the root of the `.next/standalone` directory
|
|
@@ -60,17 +64,17 @@ var PluginContext = class {
|
|
|
60
64
|
const dir = this.buildConfig.distDir ?? DEFAULT_PUBLISH_DIR;
|
|
61
65
|
return relative(process.cwd(), resolve(this.packagePath, dir));
|
|
62
66
|
}
|
|
63
|
-
/**
|
|
64
|
-
get
|
|
67
|
+
/** Represents the parent directory of the .next folder or custom distDir */
|
|
68
|
+
get distDirParent() {
|
|
65
69
|
return join(this.distDir, "..");
|
|
66
70
|
}
|
|
67
71
|
/** The `.next` folder or what the custom dist dir is set to */
|
|
68
72
|
get nextDistDir() {
|
|
69
|
-
return relative(this.
|
|
73
|
+
return relative(this.distDirParent, this.distDir);
|
|
70
74
|
}
|
|
71
75
|
/** Retrieves the `.next/standalone/` directory monorepo aware */
|
|
72
76
|
get standaloneDir() {
|
|
73
|
-
return join(this.standaloneRootDir, this.
|
|
77
|
+
return join(this.standaloneRootDir, this.distDirParent);
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
80
|
* Absolute path of the directory that is published and deployed to the Netlify CDN
|
|
@@ -102,7 +106,7 @@ var PluginContext = class {
|
|
|
102
106
|
if (this.packagePath.length === 0) {
|
|
103
107
|
return this.serverHandlerRootDir;
|
|
104
108
|
}
|
|
105
|
-
return join(this.serverHandlerRootDir, this.
|
|
109
|
+
return join(this.serverHandlerRootDir, this.distDirParent);
|
|
106
110
|
}
|
|
107
111
|
get nextServerHandler() {
|
|
108
112
|
if (this.packagePath.length !== 0) {
|
|
@@ -166,6 +170,18 @@ var PluginContext = class {
|
|
|
166
170
|
failBuild(message, error) {
|
|
167
171
|
return this.utils.build.failBuild(message, error instanceof Error ? { error } : void 0);
|
|
168
172
|
}
|
|
173
|
+
verifyPublishDir() {
|
|
174
|
+
if (!existsSync(this.publishDir)) {
|
|
175
|
+
this.failBuild(
|
|
176
|
+
`Your publish directory was not found at: ${this.publishDir}, please check your build settings`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (this.publishDir === this.resolve(this.packagePath)) {
|
|
180
|
+
this.failBuild(
|
|
181
|
+
`Your publish directory cannot be the same as the base directory of your site, please check your build settings`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
169
185
|
};
|
|
170
186
|
|
|
171
187
|
export {
|
|
@@ -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
|
-
|
|
635
|
-
|
|
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);
|
|
@@ -57,8 +57,9 @@ var copyStaticAssets = async (ctx) => {
|
|
|
57
57
|
};
|
|
58
58
|
var publishStaticDir = async (ctx) => {
|
|
59
59
|
try {
|
|
60
|
-
await
|
|
61
|
-
await
|
|
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.
|
|
70
|
+
if (existsSync(ctx.tempPublishDir)) {
|
|
70
71
|
await rename(ctx.publishDir, ctx.staticDir);
|
|
71
|
-
await rename(ctx.
|
|
72
|
+
await rename(ctx.tempPublishDir, ctx.publishDir);
|
|
72
73
|
}
|
|
73
74
|
} catch {
|
|
74
75
|
}
|