@netlify/plugin-nextjs 5.10.0-fetch-patch-logs → 5.10.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/advanced-api-routes.js +136 -4
- package/dist/build/cache.js +25 -4
- package/dist/build/content/prerendered.js +293 -11
- package/dist/build/content/server.js +219 -11
- package/dist/build/content/static.js +112 -15
- package/dist/build/functions/edge.js +540 -7
- package/dist/build/functions/server.js +130 -11
- package/dist/build/image-cdn.js +1599 -3
- package/dist/build/plugin-context.js +292 -6
- package/dist/build/verification.js +104 -9
- package/dist/esm-chunks/{package-F536DQ6H.js → package-UN6EVEHD.js} +1 -1
- package/dist/index.js +18 -39
- package/dist/run/config.js +1 -4
- package/dist/run/constants.js +7 -5
- package/dist/run/handlers/cache.cjs +44 -1655
- package/dist/run/handlers/server.js +14 -33
- package/dist/run/handlers/tracer.cjs +2 -114
- package/dist/run/handlers/tracing.js +2 -4
- package/dist/run/handlers/wait-until.cjs +2 -116
- package/dist/run/headers.js +198 -10
- package/dist/run/next.cjs +11 -1624
- package/dist/run/regional-blob-store.cjs +37 -5
- package/dist/run/revalidate.js +24 -3
- package/dist/shared/blobkey.js +15 -3
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-3RQSTU2O.js +0 -554
- package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
- package/dist/esm-chunks/chunk-AMY4NOT5.js +0 -1610
- package/dist/esm-chunks/chunk-DLVROEVU.js +0 -144
- package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
- package/dist/esm-chunks/chunk-HXVWGXWM.js +0 -218
- package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
- package/dist/esm-chunks/chunk-JPTD4GEB.js +0 -309
- package/dist/esm-chunks/chunk-MKMK7FBF.js +0 -132
- package/dist/esm-chunks/chunk-RYJYZQ4X.js +0 -610
- package/dist/esm-chunks/chunk-SGXRYMYQ.js +0 -127
- package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
- package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
- package/dist/esm-chunks/chunk-WHUPSPWV.js +0 -73
- package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
- package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
- package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
- package/dist/esm-chunks/next-LDOXJ7XH.js +0 -567
|
@@ -1,127 +0,0 @@
|
|
|
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/handlers/request-context.cts
|
|
9
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
|
-
|
|
11
|
-
// node_modules/@netlify/functions/dist/chunk-C6P2IO65.mjs
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __esm = (fn, res) => function __init() {
|
|
14
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// node_modules/@netlify/functions/dist/chunk-ATZ7N7EG.mjs
|
|
18
|
-
import { env } from "process";
|
|
19
|
-
var systemLogTag;
|
|
20
|
-
var serializeError;
|
|
21
|
-
var LogLevel;
|
|
22
|
-
var SystemLogger;
|
|
23
|
-
var systemLogger;
|
|
24
|
-
var init_system_logger = __esm({
|
|
25
|
-
"src/lib/system_logger.ts"() {
|
|
26
|
-
systemLogTag = "__nfSystemLog";
|
|
27
|
-
serializeError = (error) => {
|
|
28
|
-
const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
|
|
29
|
-
return {
|
|
30
|
-
error: error.message,
|
|
31
|
-
error_cause: cause,
|
|
32
|
-
error_stack: error.stack
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
36
|
-
LogLevel2[LogLevel2["Debug"] = 1] = "Debug";
|
|
37
|
-
LogLevel2[LogLevel2["Log"] = 2] = "Log";
|
|
38
|
-
LogLevel2[LogLevel2["Error"] = 3] = "Error";
|
|
39
|
-
return LogLevel2;
|
|
40
|
-
})(LogLevel || {});
|
|
41
|
-
SystemLogger = class _SystemLogger {
|
|
42
|
-
fields;
|
|
43
|
-
logLevel;
|
|
44
|
-
constructor(fields = {}, logLevel = 2) {
|
|
45
|
-
this.fields = fields;
|
|
46
|
-
this.logLevel = logLevel;
|
|
47
|
-
}
|
|
48
|
-
doLog(logger, message) {
|
|
49
|
-
if (env.NETLIFY_DEV && !env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
|
|
53
|
-
}
|
|
54
|
-
log(message) {
|
|
55
|
-
if (this.logLevel > 2) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.doLog(console.log, message);
|
|
59
|
-
}
|
|
60
|
-
debug(message) {
|
|
61
|
-
if (this.logLevel > 1) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.doLog(console.debug, message);
|
|
65
|
-
}
|
|
66
|
-
error(message) {
|
|
67
|
-
if (this.logLevel > 3) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this.doLog(console.error, message);
|
|
71
|
-
}
|
|
72
|
-
withLogLevel(level) {
|
|
73
|
-
return new _SystemLogger(this.fields, level);
|
|
74
|
-
}
|
|
75
|
-
withFields(fields) {
|
|
76
|
-
return new _SystemLogger(
|
|
77
|
-
{
|
|
78
|
-
...this.fields,
|
|
79
|
-
...fields
|
|
80
|
-
},
|
|
81
|
-
this.logLevel
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
withError(error) {
|
|
85
|
-
const fields = error instanceof Error ? serializeError(error) : { error };
|
|
86
|
-
return this.withFields(fields);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
systemLogger = new SystemLogger();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// node_modules/@netlify/functions/dist/chunk-7ANA32NV.mjs
|
|
94
|
-
var init_internal = __esm({
|
|
95
|
-
"src/internal.ts"() {
|
|
96
|
-
init_system_logger();
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// node_modules/@netlify/functions/dist/internal.mjs
|
|
101
|
-
init_internal();
|
|
102
|
-
|
|
103
|
-
// src/run/handlers/request-context.cts
|
|
104
|
-
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
105
|
-
var requestContextAsyncLocalStorage;
|
|
106
|
-
function getRequestContextAsyncLocalStorage() {
|
|
107
|
-
if (requestContextAsyncLocalStorage) {
|
|
108
|
-
return requestContextAsyncLocalStorage;
|
|
109
|
-
}
|
|
110
|
-
const extendedGlobalThis = globalThis;
|
|
111
|
-
if (extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY]) {
|
|
112
|
-
return extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY];
|
|
113
|
-
}
|
|
114
|
-
const storage = new AsyncLocalStorage();
|
|
115
|
-
requestContextAsyncLocalStorage = storage;
|
|
116
|
-
extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY] = storage;
|
|
117
|
-
return storage;
|
|
118
|
-
}
|
|
119
|
-
var getRequestContext = () => getRequestContextAsyncLocalStorage().getStore();
|
|
120
|
-
function getLogger() {
|
|
121
|
-
return getRequestContext()?.logger ?? systemLogger;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export {
|
|
125
|
-
getRequestContext,
|
|
126
|
-
getLogger
|
|
127
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var require = await (async () => {
|
|
3
|
-
var { createRequire } = await import("node:module");
|
|
4
|
-
return createRequire(import.meta.url);
|
|
5
|
-
})();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// src/shared/blobkey.ts
|
|
9
|
-
import { Buffer } from "node:buffer";
|
|
10
|
-
import { webcrypto as crypto } from "node:crypto";
|
|
11
|
-
var maxLength = 180;
|
|
12
|
-
async function encodeBlobKey(key) {
|
|
13
|
-
const buffer = Buffer.from(key);
|
|
14
|
-
const base64 = buffer.toString("base64url");
|
|
15
|
-
if (base64.length <= maxLength) {
|
|
16
|
-
return base64;
|
|
17
|
-
}
|
|
18
|
-
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
19
|
-
const hash = Buffer.from(digest).toString("base64url");
|
|
20
|
-
return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
encodeBlobKey
|
|
25
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
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/constants.ts
|
|
9
|
-
import { resolve } from "node:path";
|
|
10
|
-
import { fileURLToPath } from "node:url";
|
|
11
|
-
var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
12
|
-
var PLUGIN_DIR = resolve(`${MODULE_DIR}../../..`);
|
|
13
|
-
var RUN_CONFIG = "run-config.json";
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
MODULE_DIR,
|
|
17
|
-
PLUGIN_DIR,
|
|
18
|
-
RUN_CONFIG
|
|
19
|
-
};
|
|
@@ -1,73 +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 {
|
|
8
|
-
getRequestContext
|
|
9
|
-
} from "./chunk-SGXRYMYQ.js";
|
|
10
|
-
import {
|
|
11
|
-
wrapTracer
|
|
12
|
-
} from "./chunk-5QSXBV7L.js";
|
|
13
|
-
import {
|
|
14
|
-
init_esm,
|
|
15
|
-
trace
|
|
16
|
-
} from "./chunk-GNGHTHMQ.js";
|
|
17
|
-
|
|
18
|
-
// src/run/handlers/tracer.cts
|
|
19
|
-
init_esm();
|
|
20
|
-
var spanMeta = /* @__PURE__ */ new WeakMap();
|
|
21
|
-
var spanCounter = /* @__PURE__ */ new WeakMap();
|
|
22
|
-
function spanHook(span) {
|
|
23
|
-
const originalEnd = span.end.bind(span);
|
|
24
|
-
span.end = (endTime) => {
|
|
25
|
-
originalEnd(endTime);
|
|
26
|
-
const meta = spanMeta.get(span);
|
|
27
|
-
if (meta) {
|
|
28
|
-
const requestContext = getRequestContext();
|
|
29
|
-
if (requestContext?.captureServerTiming) {
|
|
30
|
-
const duration = (typeof endTime === "number" ? endTime : performance.now()) - meta.start;
|
|
31
|
-
const serverTiming = requestContext.serverTiming ?? "";
|
|
32
|
-
const currentRequestSpanCounter = spanCounter.get(requestContext) ?? 1;
|
|
33
|
-
requestContext.serverTiming = `${serverTiming}${serverTiming.length === 0 ? "" : ", "}s${currentRequestSpanCounter};dur=${duration};desc="${meta.name}"`;
|
|
34
|
-
spanCounter.set(requestContext, currentRequestSpanCounter + 1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
spanMeta.delete(span);
|
|
38
|
-
};
|
|
39
|
-
return span;
|
|
40
|
-
}
|
|
41
|
-
var tracer;
|
|
42
|
-
function getTracer() {
|
|
43
|
-
if (!tracer) {
|
|
44
|
-
const baseTracer = trace.getTracer("Next.js Runtime");
|
|
45
|
-
const startSpan = baseTracer.startSpan.bind(baseTracer);
|
|
46
|
-
baseTracer.startSpan = (...args) => {
|
|
47
|
-
const span = startSpan(...args);
|
|
48
|
-
spanMeta.set(span, { start: performance.now(), name: args[0] });
|
|
49
|
-
return spanHook(span);
|
|
50
|
-
};
|
|
51
|
-
const startActiveSpan = baseTracer.startActiveSpan.bind(baseTracer);
|
|
52
|
-
baseTracer.startActiveSpan = (...args) => {
|
|
53
|
-
const [name, ...restOfArgs] = args;
|
|
54
|
-
const augmentedArgs = restOfArgs.map((arg) => {
|
|
55
|
-
if (typeof arg === "function") {
|
|
56
|
-
return (span) => {
|
|
57
|
-
spanMeta.set(span, { start: performance.now(), name: args[0] });
|
|
58
|
-
spanHook(span);
|
|
59
|
-
return arg(span);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return arg;
|
|
63
|
-
});
|
|
64
|
-
return startActiveSpan(name, ...augmentedArgs);
|
|
65
|
-
};
|
|
66
|
-
tracer = wrapTracer(baseTracer);
|
|
67
|
-
}
|
|
68
|
-
return tracer;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export {
|
|
72
|
-
getTracer
|
|
73
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
import { isPromise } from "node:util/types";
|
|
10
|
-
function isRevalidateMethod(key, nextResponseField) {
|
|
11
|
-
return key === "revalidate" && typeof nextResponseField === "function";
|
|
12
|
-
}
|
|
13
|
-
var nextResponseProxy = (res, requestContext) => {
|
|
14
|
-
return new Proxy(res, {
|
|
15
|
-
get(target, key) {
|
|
16
|
-
const originalValue = Reflect.get(target, key);
|
|
17
|
-
if (isRevalidateMethod(key, originalValue)) {
|
|
18
|
-
return function newRevalidate(...args) {
|
|
19
|
-
requestContext.didPagesRouterOnDemandRevalidate = true;
|
|
20
|
-
const result = originalValue.apply(target, args);
|
|
21
|
-
if (result && isPromise(result)) {
|
|
22
|
-
requestContext.trackBackgroundWork(result);
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return originalValue;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
nextResponseProxy
|
|
34
|
-
};
|
|
@@ -1,148 +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 {
|
|
8
|
-
__require
|
|
9
|
-
} from "./chunk-OEQOKJGE.js";
|
|
10
|
-
|
|
11
|
-
// src/build/advanced-api-routes.ts
|
|
12
|
-
import { existsSync } from "node:fs";
|
|
13
|
-
import { readFile } from "node:fs/promises";
|
|
14
|
-
import { join } from "node:path";
|
|
15
|
-
var ApiRouteType = /* @__PURE__ */ ((ApiRouteType2) => {
|
|
16
|
-
ApiRouteType2["SCHEDULED"] = "experimental-scheduled";
|
|
17
|
-
ApiRouteType2["BACKGROUND"] = "experimental-background";
|
|
18
|
-
return ApiRouteType2;
|
|
19
|
-
})(ApiRouteType || {});
|
|
20
|
-
async function getAPIRoutesConfigs(ctx) {
|
|
21
|
-
const uniqueApiRoutes = /* @__PURE__ */ new Set();
|
|
22
|
-
const functionsConfigManifestPath = join(
|
|
23
|
-
ctx.publishDir,
|
|
24
|
-
"server",
|
|
25
|
-
"functions-config-manifest.json"
|
|
26
|
-
);
|
|
27
|
-
if (existsSync(functionsConfigManifestPath)) {
|
|
28
|
-
const functionsConfigManifest = JSON.parse(
|
|
29
|
-
await readFile(functionsConfigManifestPath, "utf-8")
|
|
30
|
-
);
|
|
31
|
-
for (const apiRoute of Object.keys(functionsConfigManifest.functions)) {
|
|
32
|
-
uniqueApiRoutes.add(apiRoute);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const pagesManifestPath = join(ctx.publishDir, "server", "pages-manifest.json");
|
|
36
|
-
if (existsSync(pagesManifestPath)) {
|
|
37
|
-
const pagesManifest = JSON.parse(await readFile(pagesManifestPath, "utf-8"));
|
|
38
|
-
for (const route of Object.keys(pagesManifest)) {
|
|
39
|
-
if (route.startsWith("/api/")) {
|
|
40
|
-
uniqueApiRoutes.add(route);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (uniqueApiRoutes.size === 0) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
const appDir = ctx.resolveFromSiteDir(".");
|
|
48
|
-
const pagesDir = join(appDir, "pages");
|
|
49
|
-
const srcPagesDir = join(appDir, "src", "pages");
|
|
50
|
-
const { pageExtensions } = ctx.requiredServerFiles.config;
|
|
51
|
-
return Promise.all(
|
|
52
|
-
[...uniqueApiRoutes].map(async (apiRoute) => {
|
|
53
|
-
const filePath = getSourceFileForPage(apiRoute, [pagesDir, srcPagesDir], pageExtensions);
|
|
54
|
-
const sharedFields = {
|
|
55
|
-
apiRoute,
|
|
56
|
-
filePath,
|
|
57
|
-
config: {}
|
|
58
|
-
};
|
|
59
|
-
if (filePath) {
|
|
60
|
-
const config = await extractConfigFromFile(filePath, appDir);
|
|
61
|
-
return {
|
|
62
|
-
...sharedFields,
|
|
63
|
-
config
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return sharedFields;
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
var SOURCE_FILE_EXTENSIONS = ["js", "jsx", "ts", "tsx"];
|
|
71
|
-
var getSourceFileForPage = (page, roots, pageExtensions = SOURCE_FILE_EXTENSIONS) => {
|
|
72
|
-
for (const root of roots) {
|
|
73
|
-
for (const extension of pageExtensions) {
|
|
74
|
-
const file = join(root, `${page}.${extension}`);
|
|
75
|
-
if (existsSync(file)) {
|
|
76
|
-
return file;
|
|
77
|
-
}
|
|
78
|
-
const fileAtFolderIndex = join(root, page, `index.${extension}`);
|
|
79
|
-
if (existsSync(fileAtFolderIndex)) {
|
|
80
|
-
return fileAtFolderIndex;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var findModuleFromBase = ({
|
|
86
|
-
paths,
|
|
87
|
-
candidates
|
|
88
|
-
}) => {
|
|
89
|
-
for (const candidate of candidates) {
|
|
90
|
-
try {
|
|
91
|
-
const modulePath = __require.resolve(candidate, { paths });
|
|
92
|
-
if (modulePath) {
|
|
93
|
-
return modulePath;
|
|
94
|
-
}
|
|
95
|
-
} catch {
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
for (const candidate of candidates) {
|
|
99
|
-
try {
|
|
100
|
-
const modulePath = __require.resolve(candidate);
|
|
101
|
-
if (modulePath) {
|
|
102
|
-
return modulePath;
|
|
103
|
-
}
|
|
104
|
-
} catch {
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
};
|
|
109
|
-
var extractConstValue;
|
|
110
|
-
var parseModule;
|
|
111
|
-
var extractConfigFromFile = async (apiFilePath, appDir) => {
|
|
112
|
-
if (!apiFilePath || !existsSync(apiFilePath)) {
|
|
113
|
-
return {};
|
|
114
|
-
}
|
|
115
|
-
const extractConstValueModulePath = findModuleFromBase({
|
|
116
|
-
paths: [appDir],
|
|
117
|
-
candidates: ["next/dist/build/analysis/extract-const-value"]
|
|
118
|
-
});
|
|
119
|
-
const parseModulePath = findModuleFromBase({
|
|
120
|
-
paths: [appDir],
|
|
121
|
-
candidates: ["next/dist/build/analysis/parse-module"]
|
|
122
|
-
});
|
|
123
|
-
if (!extractConstValueModulePath || !parseModulePath) {
|
|
124
|
-
return {};
|
|
125
|
-
}
|
|
126
|
-
if (!extractConstValue && extractConstValueModulePath) {
|
|
127
|
-
extractConstValue = __require(extractConstValueModulePath);
|
|
128
|
-
}
|
|
129
|
-
if (!parseModule && parseModulePath) {
|
|
130
|
-
parseModule = __require(parseModulePath).parseModule;
|
|
131
|
-
}
|
|
132
|
-
const { extractExportedConstValue } = extractConstValue;
|
|
133
|
-
const fileContent = await readFile(apiFilePath, "utf8");
|
|
134
|
-
if (!fileContent.includes("config")) {
|
|
135
|
-
return {};
|
|
136
|
-
}
|
|
137
|
-
const ast = await parseModule(apiFilePath, fileContent);
|
|
138
|
-
try {
|
|
139
|
-
return extractExportedConstValue(ast, "config");
|
|
140
|
-
} catch {
|
|
141
|
-
return {};
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export {
|
|
146
|
-
ApiRouteType,
|
|
147
|
-
getAPIRoutesConfigs
|
|
148
|
-
};
|
|
@@ -1,120 +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 {
|
|
8
|
-
require_out
|
|
9
|
-
} from "./chunk-KGYJQ2U2.js";
|
|
10
|
-
import {
|
|
11
|
-
getAPIRoutesConfigs
|
|
12
|
-
} from "./chunk-ZENB67PD.js";
|
|
13
|
-
import {
|
|
14
|
-
require_semver
|
|
15
|
-
} from "./chunk-APO262HE.js";
|
|
16
|
-
import {
|
|
17
|
-
__toESM
|
|
18
|
-
} from "./chunk-OEQOKJGE.js";
|
|
19
|
-
|
|
20
|
-
// src/build/verification.ts
|
|
21
|
-
var import_fast_glob = __toESM(require_out(), 1);
|
|
22
|
-
var import_semver = __toESM(require_semver(), 1);
|
|
23
|
-
import { existsSync } from "node:fs";
|
|
24
|
-
import { readFile } from "node:fs/promises";
|
|
25
|
-
import { join } from "node:path";
|
|
26
|
-
var SUPPORTED_NEXT_VERSIONS = ">=13.5.0";
|
|
27
|
-
var verifications = /* @__PURE__ */ new Set();
|
|
28
|
-
function verifyPublishDir(ctx) {
|
|
29
|
-
if (!existsSync(ctx.publishDir)) {
|
|
30
|
-
ctx.failBuild(
|
|
31
|
-
`Your publish directory was not found at: ${ctx.publishDir}. Please check your build settings`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
if (ctx.publishDir === ctx.resolveFromPackagePath("")) {
|
|
35
|
-
ctx.failBuild(
|
|
36
|
-
`Your publish directory cannot be the same as the base directory of your site. Please check your build settings`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
ctx.buildConfig;
|
|
41
|
-
} catch {
|
|
42
|
-
ctx.failBuild(
|
|
43
|
-
"Your publish directory does not contain expected Next.js build output. Please check your build settings"
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
if (ctx.buildConfig.output === "standalone" || ctx.buildConfig.output === void 0) {
|
|
47
|
-
if (!existsSync(join(ctx.publishDir, "BUILD_ID"))) {
|
|
48
|
-
ctx.failBuild(
|
|
49
|
-
"Your publish directory does not contain expected Next.js build output. Please check your build settings"
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (!existsSync(ctx.standaloneRootDir)) {
|
|
53
|
-
ctx.failBuild(
|
|
54
|
-
`Your publish directory does not contain expected Next.js build output. Please make sure you are using Next.js version (${SUPPORTED_NEXT_VERSIONS})`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (ctx.nextVersion && !(0, import_semver.satisfies)(ctx.nextVersion, SUPPORTED_NEXT_VERSIONS, { includePrerelease: true })) {
|
|
58
|
-
ctx.failBuild(
|
|
59
|
-
`@netlify/plugin-nextjs@5 requires Next.js version ${SUPPORTED_NEXT_VERSIONS}, but found ${ctx.nextVersion}. Please upgrade your project's Next.js version.`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (ctx.buildConfig.output === "export") {
|
|
64
|
-
if (!ctx.exportDetail?.success) {
|
|
65
|
-
ctx.failBuild(`Your export failed to build. Please check your build settings`);
|
|
66
|
-
}
|
|
67
|
-
if (!existsSync(ctx.exportDetail?.outDirectory)) {
|
|
68
|
-
ctx.failBuild(
|
|
69
|
-
`Your export directory was not found at: ${ctx.exportDetail?.outDirectory}. Please check your build settings`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async function verifyAdvancedAPIRoutes(ctx) {
|
|
75
|
-
const apiRoutesConfigs = await getAPIRoutesConfigs(ctx);
|
|
76
|
-
const unsupportedAPIRoutes = apiRoutesConfigs.filter((apiRouteConfig) => {
|
|
77
|
-
return apiRouteConfig.config.type === "experimental-background" /* BACKGROUND */ || apiRouteConfig.config.type === "experimental-scheduled" /* SCHEDULED */;
|
|
78
|
-
});
|
|
79
|
-
if (unsupportedAPIRoutes.length !== 0) {
|
|
80
|
-
ctx.failBuild(
|
|
81
|
-
`@netlify/plugin-nextjs@5 does not support advanced API routes. The following API routes should be migrated to Netlify background or scheduled functions:
|
|
82
|
-
${unsupportedAPIRoutes.map((apiRouteConfig) => ` - ${apiRouteConfig.apiRoute} (type: "${apiRouteConfig.config.type}")`).join("\n")}
|
|
83
|
-
|
|
84
|
-
Refer to https://ntl.fyi/next-scheduled-bg-function-migration as migration example.`
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
var formDetectionRegex = /<form[^>]*?\s(netlify|data-netlify)[=>\s]/;
|
|
89
|
-
async function verifyNetlifyFormsWorkaround(ctx) {
|
|
90
|
-
const srcDir = ctx.resolveFromSiteDir("public");
|
|
91
|
-
const paths = await (0, import_fast_glob.glob)("**/*.html", {
|
|
92
|
-
cwd: srcDir,
|
|
93
|
-
dot: true
|
|
94
|
-
});
|
|
95
|
-
try {
|
|
96
|
-
for (const path of paths) {
|
|
97
|
-
const html = await readFile(join(srcDir, path), "utf-8");
|
|
98
|
-
if (formDetectionRegex.test(html)) {
|
|
99
|
-
verifications.add("netlifyFormsWorkaround");
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
ctx.failBuild("Failed verifying public files", error);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function verifyNetlifyForms(ctx, html) {
|
|
108
|
-
if (process.env.NETLIFY_NEXT_VERIFY_FORMS !== "0" && process.env.NETLIFY_NEXT_VERIFY_FORMS?.toUpperCase() !== "FALSE" && !verifications.has("netlifyFormsWorkaround") && formDetectionRegex.test(html)) {
|
|
109
|
-
ctx.failBuild(
|
|
110
|
-
"@netlify/plugin-nextjs@5 requires migration steps to support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example."
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export {
|
|
116
|
-
verifyPublishDir,
|
|
117
|
-
verifyAdvancedAPIRoutes,
|
|
118
|
-
verifyNetlifyFormsWorkaround,
|
|
119
|
-
verifyNetlifyForms
|
|
120
|
-
};
|