@netlify/plugin-nextjs 5.1.1 → 5.2.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.
Files changed (42) hide show
  1. package/dist/build/advanced-api-routes.js +121 -4
  2. package/dist/build/cache.js +25 -4
  3. package/dist/build/content/prerendered.js +234 -8
  4. package/dist/build/content/server.js +259 -14
  5. package/dist/build/content/static.js +96 -11
  6. package/dist/build/functions/edge.js +511 -5
  7. package/dist/build/functions/server.js +131 -12
  8. package/dist/build/image-cdn.js +1626 -3
  9. package/dist/build/plugin-context.js +236 -5
  10. package/dist/build/templates/handler-monorepo.tmpl.js +3 -0
  11. package/dist/build/templates/handler.tmpl.js +3 -0
  12. package/dist/build/verification.js +81 -8
  13. package/dist/esm-chunks/{package-YB7ERSH4.js → package-ZBRSUKN7.js} +6 -6
  14. package/dist/index.js +25 -36
  15. package/dist/run/config.js +25 -6
  16. package/dist/run/constants.js +7 -5
  17. package/dist/run/handlers/cache.cjs +6 -567
  18. package/dist/run/handlers/request-context.cjs +8 -1
  19. package/dist/run/handlers/server.js +20 -22
  20. package/dist/run/handlers/tracing.js +1 -1
  21. package/dist/run/headers.js +198 -8
  22. package/dist/run/next.cjs +49 -567
  23. package/dist/{esm-chunks/chunk-PMRBBOBY.js → run/regional-blob-store.cjs} +117 -263
  24. package/dist/run/revalidate.js +17 -3
  25. package/dist/run/systemlog.js +94 -3
  26. package/dist/shared/blobkey.js +15 -3
  27. package/package.json +1 -1
  28. package/dist/esm-chunks/chunk-3NYX5FXN.js +0 -188
  29. package/dist/esm-chunks/chunk-3SUDZQ7L.js +0 -40
  30. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  31. package/dist/esm-chunks/chunk-74THQNRG.js +0 -110
  32. package/dist/esm-chunks/chunk-BG455SFE.js +0 -133
  33. package/dist/esm-chunks/chunk-F5VQRN6L.js +0 -127
  34. package/dist/esm-chunks/chunk-HYBEXB2Z.js +0 -105
  35. package/dist/esm-chunks/chunk-MCEOSJH6.js +0 -1637
  36. package/dist/esm-chunks/chunk-MRD3XSKD.js +0 -248
  37. package/dist/esm-chunks/chunk-OBKVBMAL.js +0 -524
  38. package/dist/esm-chunks/chunk-PH26UF2W.js +0 -86
  39. package/dist/esm-chunks/chunk-RL4K4CVH.js +0 -27
  40. package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
  41. package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
  42. package/dist/esm-chunks/chunk-ZKJEJNSJ.js +0 -278
@@ -1,524 +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-VZNKO4OO.js";
10
- import {
11
- EDGE_HANDLER_NAME
12
- } from "./chunk-3NYX5FXN.js";
13
- import {
14
- __commonJS,
15
- __toESM
16
- } from "./chunk-5JVNISGM.js";
17
-
18
- // node_modules/path-to-regexp/dist/index.js
19
- var require_dist = __commonJS({
20
- "node_modules/path-to-regexp/dist/index.js"(exports) {
21
- "use strict";
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.pathToRegexp = exports.tokensToRegexp = exports.regexpToFunction = exports.match = exports.tokensToFunction = exports.compile = exports.parse = void 0;
24
- function lexer(str) {
25
- var tokens = [];
26
- var i = 0;
27
- while (i < str.length) {
28
- var char = str[i];
29
- if (char === "*" || char === "+" || char === "?") {
30
- tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
31
- continue;
32
- }
33
- if (char === "\\") {
34
- tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
35
- continue;
36
- }
37
- if (char === "{") {
38
- tokens.push({ type: "OPEN", index: i, value: str[i++] });
39
- continue;
40
- }
41
- if (char === "}") {
42
- tokens.push({ type: "CLOSE", index: i, value: str[i++] });
43
- continue;
44
- }
45
- if (char === ":") {
46
- var name = "";
47
- var j = i + 1;
48
- while (j < str.length) {
49
- var code = str.charCodeAt(j);
50
- if (
51
- // `0-9`
52
- code >= 48 && code <= 57 || // `A-Z`
53
- code >= 65 && code <= 90 || // `a-z`
54
- code >= 97 && code <= 122 || // `_`
55
- code === 95
56
- ) {
57
- name += str[j++];
58
- continue;
59
- }
60
- break;
61
- }
62
- if (!name)
63
- throw new TypeError("Missing parameter name at ".concat(i));
64
- tokens.push({ type: "NAME", index: i, value: name });
65
- i = j;
66
- continue;
67
- }
68
- if (char === "(") {
69
- var count = 1;
70
- var pattern = "";
71
- var j = i + 1;
72
- if (str[j] === "?") {
73
- throw new TypeError('Pattern cannot start with "?" at '.concat(j));
74
- }
75
- while (j < str.length) {
76
- if (str[j] === "\\") {
77
- pattern += str[j++] + str[j++];
78
- continue;
79
- }
80
- if (str[j] === ")") {
81
- count--;
82
- if (count === 0) {
83
- j++;
84
- break;
85
- }
86
- } else if (str[j] === "(") {
87
- count++;
88
- if (str[j + 1] !== "?") {
89
- throw new TypeError("Capturing groups are not allowed at ".concat(j));
90
- }
91
- }
92
- pattern += str[j++];
93
- }
94
- if (count)
95
- throw new TypeError("Unbalanced pattern at ".concat(i));
96
- if (!pattern)
97
- throw new TypeError("Missing pattern at ".concat(i));
98
- tokens.push({ type: "PATTERN", index: i, value: pattern });
99
- i = j;
100
- continue;
101
- }
102
- tokens.push({ type: "CHAR", index: i, value: str[i++] });
103
- }
104
- tokens.push({ type: "END", index: i, value: "" });
105
- return tokens;
106
- }
107
- function parse(str, options) {
108
- if (options === void 0) {
109
- options = {};
110
- }
111
- var tokens = lexer(str);
112
- var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
113
- var defaultPattern = "[^".concat(escapeString(options.delimiter || "/#?"), "]+?");
114
- var result = [];
115
- var key = 0;
116
- var i = 0;
117
- var path = "";
118
- var tryConsume = function(type) {
119
- if (i < tokens.length && tokens[i].type === type)
120
- return tokens[i++].value;
121
- };
122
- var mustConsume = function(type) {
123
- var value2 = tryConsume(type);
124
- if (value2 !== void 0)
125
- return value2;
126
- var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
127
- throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
128
- };
129
- var consumeText = function() {
130
- var result2 = "";
131
- var value2;
132
- while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
133
- result2 += value2;
134
- }
135
- return result2;
136
- };
137
- while (i < tokens.length) {
138
- var char = tryConsume("CHAR");
139
- var name = tryConsume("NAME");
140
- var pattern = tryConsume("PATTERN");
141
- if (name || pattern) {
142
- var prefix = char || "";
143
- if (prefixes.indexOf(prefix) === -1) {
144
- path += prefix;
145
- prefix = "";
146
- }
147
- if (path) {
148
- result.push(path);
149
- path = "";
150
- }
151
- result.push({
152
- name: name || key++,
153
- prefix,
154
- suffix: "",
155
- pattern: pattern || defaultPattern,
156
- modifier: tryConsume("MODIFIER") || ""
157
- });
158
- continue;
159
- }
160
- var value = char || tryConsume("ESCAPED_CHAR");
161
- if (value) {
162
- path += value;
163
- continue;
164
- }
165
- if (path) {
166
- result.push(path);
167
- path = "";
168
- }
169
- var open = tryConsume("OPEN");
170
- if (open) {
171
- var prefix = consumeText();
172
- var name_1 = tryConsume("NAME") || "";
173
- var pattern_1 = tryConsume("PATTERN") || "";
174
- var suffix = consumeText();
175
- mustConsume("CLOSE");
176
- result.push({
177
- name: name_1 || (pattern_1 ? key++ : ""),
178
- pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
179
- prefix,
180
- suffix,
181
- modifier: tryConsume("MODIFIER") || ""
182
- });
183
- continue;
184
- }
185
- mustConsume("END");
186
- }
187
- return result;
188
- }
189
- exports.parse = parse;
190
- function compile(str, options) {
191
- return tokensToFunction(parse(str, options), options);
192
- }
193
- exports.compile = compile;
194
- function tokensToFunction(tokens, options) {
195
- if (options === void 0) {
196
- options = {};
197
- }
198
- var reFlags = flags(options);
199
- var _a = options.encode, encode = _a === void 0 ? function(x) {
200
- return x;
201
- } : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
202
- var matches = tokens.map(function(token) {
203
- if (typeof token === "object") {
204
- return new RegExp("^(?:".concat(token.pattern, ")$"), reFlags);
205
- }
206
- });
207
- return function(data) {
208
- var path = "";
209
- for (var i = 0; i < tokens.length; i++) {
210
- var token = tokens[i];
211
- if (typeof token === "string") {
212
- path += token;
213
- continue;
214
- }
215
- var value = data ? data[token.name] : void 0;
216
- var optional = token.modifier === "?" || token.modifier === "*";
217
- var repeat = token.modifier === "*" || token.modifier === "+";
218
- if (Array.isArray(value)) {
219
- if (!repeat) {
220
- throw new TypeError('Expected "'.concat(token.name, '" to not repeat, but got an array'));
221
- }
222
- if (value.length === 0) {
223
- if (optional)
224
- continue;
225
- throw new TypeError('Expected "'.concat(token.name, '" to not be empty'));
226
- }
227
- for (var j = 0; j < value.length; j++) {
228
- var segment = encode(value[j], token);
229
- if (validate && !matches[i].test(segment)) {
230
- throw new TypeError('Expected all "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
231
- }
232
- path += token.prefix + segment + token.suffix;
233
- }
234
- continue;
235
- }
236
- if (typeof value === "string" || typeof value === "number") {
237
- var segment = encode(String(value), token);
238
- if (validate && !matches[i].test(segment)) {
239
- throw new TypeError('Expected "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
240
- }
241
- path += token.prefix + segment + token.suffix;
242
- continue;
243
- }
244
- if (optional)
245
- continue;
246
- var typeOfMessage = repeat ? "an array" : "a string";
247
- throw new TypeError('Expected "'.concat(token.name, '" to be ').concat(typeOfMessage));
248
- }
249
- return path;
250
- };
251
- }
252
- exports.tokensToFunction = tokensToFunction;
253
- function match(str, options) {
254
- var keys = [];
255
- var re = pathToRegexp2(str, keys, options);
256
- return regexpToFunction(re, keys, options);
257
- }
258
- exports.match = match;
259
- function regexpToFunction(re, keys, options) {
260
- if (options === void 0) {
261
- options = {};
262
- }
263
- var _a = options.decode, decode = _a === void 0 ? function(x) {
264
- return x;
265
- } : _a;
266
- return function(pathname) {
267
- var m = re.exec(pathname);
268
- if (!m)
269
- return false;
270
- var path = m[0], index = m.index;
271
- var params = /* @__PURE__ */ Object.create(null);
272
- var _loop_1 = function(i2) {
273
- if (m[i2] === void 0)
274
- return "continue";
275
- var key = keys[i2 - 1];
276
- if (key.modifier === "*" || key.modifier === "+") {
277
- params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
278
- return decode(value, key);
279
- });
280
- } else {
281
- params[key.name] = decode(m[i2], key);
282
- }
283
- };
284
- for (var i = 1; i < m.length; i++) {
285
- _loop_1(i);
286
- }
287
- return { path, index, params };
288
- };
289
- }
290
- exports.regexpToFunction = regexpToFunction;
291
- function escapeString(str) {
292
- return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
293
- }
294
- function flags(options) {
295
- return options && options.sensitive ? "" : "i";
296
- }
297
- function regexpToRegexp(path, keys) {
298
- if (!keys)
299
- return path;
300
- var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
301
- var index = 0;
302
- var execResult = groupsRegex.exec(path.source);
303
- while (execResult) {
304
- keys.push({
305
- // Use parenthesized substring match if available, index otherwise
306
- name: execResult[1] || index++,
307
- prefix: "",
308
- suffix: "",
309
- modifier: "",
310
- pattern: ""
311
- });
312
- execResult = groupsRegex.exec(path.source);
313
- }
314
- return path;
315
- }
316
- function arrayToRegexp(paths, keys, options) {
317
- var parts = paths.map(function(path) {
318
- return pathToRegexp2(path, keys, options).source;
319
- });
320
- return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
321
- }
322
- function stringToRegexp(path, keys, options) {
323
- return tokensToRegexp(parse(path, options), keys, options);
324
- }
325
- function tokensToRegexp(tokens, keys, options) {
326
- if (options === void 0) {
327
- options = {};
328
- }
329
- var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
330
- return x;
331
- } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
332
- var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
333
- var delimiterRe = "[".concat(escapeString(delimiter), "]");
334
- var route = start ? "^" : "";
335
- for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
336
- var token = tokens_1[_i];
337
- if (typeof token === "string") {
338
- route += escapeString(encode(token));
339
- } else {
340
- var prefix = escapeString(encode(token.prefix));
341
- var suffix = escapeString(encode(token.suffix));
342
- if (token.pattern) {
343
- if (keys)
344
- keys.push(token);
345
- if (prefix || suffix) {
346
- if (token.modifier === "+" || token.modifier === "*") {
347
- var mod = token.modifier === "*" ? "?" : "";
348
- route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
349
- } else {
350
- route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
351
- }
352
- } else {
353
- if (token.modifier === "+" || token.modifier === "*") {
354
- route += "((?:".concat(token.pattern, ")").concat(token.modifier, ")");
355
- } else {
356
- route += "(".concat(token.pattern, ")").concat(token.modifier);
357
- }
358
- }
359
- } else {
360
- route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
361
- }
362
- }
363
- }
364
- if (end) {
365
- if (!strict)
366
- route += "".concat(delimiterRe, "?");
367
- route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
368
- } else {
369
- var endToken = tokens[tokens.length - 1];
370
- var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
371
- if (!strict) {
372
- route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
373
- }
374
- if (!isEndDelimited) {
375
- route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
376
- }
377
- }
378
- return new RegExp(route, flags(options));
379
- }
380
- exports.tokensToRegexp = tokensToRegexp;
381
- function pathToRegexp2(path, keys, options) {
382
- if (path instanceof RegExp)
383
- return regexpToRegexp(path, keys);
384
- if (Array.isArray(path))
385
- return arrayToRegexp(path, keys, options);
386
- return stringToRegexp(path, keys, options);
387
- }
388
- exports.pathToRegexp = pathToRegexp2;
389
- }
390
- });
391
-
392
- // src/build/functions/edge.ts
393
- var import_fast_glob = __toESM(require_out(), 1);
394
- var import_path_to_regexp = __toESM(require_dist(), 1);
395
- import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
396
- import { dirname, join } from "node:path";
397
- var writeEdgeManifest = async (ctx, manifest) => {
398
- await mkdir(ctx.edgeFunctionsDir, { recursive: true });
399
- await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
400
- };
401
- var copyRuntime = async (ctx, handlerDirectory) => {
402
- const files = await (0, import_fast_glob.glob)("edge-runtime/**/*", {
403
- cwd: ctx.pluginDir,
404
- ignore: ["**/*.test.ts"],
405
- dot: true
406
- });
407
- await Promise.all(
408
- files.map(
409
- (path) => cp(join(ctx.pluginDir, path), join(handlerDirectory, path), { recursive: true })
410
- )
411
- );
412
- };
413
- var augmentMatchers = (matchers, ctx) => {
414
- if (!ctx.buildConfig.i18n) {
415
- return matchers;
416
- }
417
- return matchers.flatMap((matcher) => {
418
- if (matcher.originalSource && matcher.locale !== false) {
419
- return [
420
- matcher,
421
- {
422
- ...matcher,
423
- regexp: (0, import_path_to_regexp.pathToRegexp)(matcher.originalSource).source
424
- }
425
- ];
426
- }
427
- return matcher;
428
- });
429
- };
430
- var writeHandlerFile = async (ctx, { matchers, name }) => {
431
- const nextConfig = ctx.buildConfig;
432
- const handlerName = getHandlerName({ name });
433
- const handlerDirectory = join(ctx.edgeFunctionsDir, handlerName);
434
- const handlerRuntimeDirectory = join(handlerDirectory, "edge-runtime");
435
- await copyRuntime(ctx, handlerDirectory);
436
- await writeFile(
437
- join(handlerRuntimeDirectory, "matchers.json"),
438
- JSON.stringify(augmentMatchers(matchers, ctx))
439
- );
440
- const minimalNextConfig = {
441
- basePath: nextConfig.basePath,
442
- i18n: nextConfig.i18n,
443
- trailingSlash: nextConfig.trailingSlash,
444
- skipMiddlewareUrlNormalize: nextConfig.skipMiddlewareUrlNormalize
445
- };
446
- await writeFile(
447
- join(handlerRuntimeDirectory, "next.config.json"),
448
- JSON.stringify(minimalNextConfig)
449
- );
450
- await writeFile(
451
- join(handlerDirectory, `${handlerName}.js`),
452
- `
453
- import {handleMiddleware} from './edge-runtime/middleware.ts';
454
- import handler from './server/${name}.js';
455
- export default (req, context) => handleMiddleware(req, context, handler);
456
- `
457
- );
458
- };
459
- var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
460
- const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
461
- const destDir = join(ctx.edgeFunctionsDir, getHandlerName({ name }));
462
- const edgeRuntimeDir = join(ctx.pluginDir, "edge-runtime");
463
- const shimPath = join(edgeRuntimeDir, "shim/index.js");
464
- const shim = await readFile(shimPath, "utf8");
465
- const parts = [shim];
466
- if (wasm?.length) {
467
- parts.push(
468
- `import { decode as _base64Decode } from "../edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts";`
469
- );
470
- for (const wasmChunk of wasm ?? []) {
471
- const data = await readFile(join(srcDir, wasmChunk.filePath));
472
- parts.push(
473
- `const ${wasmChunk.name} = _base64Decode(${JSON.stringify(
474
- data.toString("base64")
475
- )}).buffer`
476
- );
477
- }
478
- }
479
- for (const file of files) {
480
- const entrypoint = await readFile(join(srcDir, file), "utf8");
481
- parts.push(`;// Concatenated file: ${file}
482
- `, entrypoint);
483
- }
484
- const exports = `export default _ENTRIES["middleware_${name}"].default;`;
485
- await mkdir(dirname(join(destDir, `server/${name}.js`)), { recursive: true });
486
- await writeFile(join(destDir, `server/${name}.js`), [...parts, exports].join("\n"));
487
- };
488
- var createEdgeHandler = async (ctx, definition) => {
489
- await copyHandlerDependencies(ctx, definition);
490
- await writeHandlerFile(ctx, definition);
491
- };
492
- var getHandlerName = ({ name }) => `${EDGE_HANDLER_NAME}-${name.replace(/\W/g, "-")}`;
493
- var buildHandlerDefinition = (ctx, { name, matchers, page }) => {
494
- const fun = getHandlerName({ name });
495
- const funName = name.endsWith("middleware") ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`;
496
- const cache = name.endsWith("middleware") ? void 0 : "manual";
497
- const generator = `${ctx.pluginName}@${ctx.pluginVersion}`;
498
- return augmentMatchers(matchers, ctx).map((matcher) => ({
499
- function: fun,
500
- name: funName,
501
- pattern: matcher.regexp,
502
- cache,
503
- generator
504
- }));
505
- };
506
- var createEdgeHandlers = async (ctx) => {
507
- await rm(ctx.edgeFunctionsDir, { recursive: true, force: true });
508
- const nextManifest = await ctx.getMiddlewareManifest();
509
- const nextDefinitions = [
510
- ...Object.values(nextManifest.middleware)
511
- // ...Object.values(nextManifest.functions)
512
- ];
513
- await Promise.all(nextDefinitions.map((def) => createEdgeHandler(ctx, def)));
514
- const netlifyDefinitions = nextDefinitions.flatMap((def) => buildHandlerDefinition(ctx, def));
515
- const netlifyManifest = {
516
- version: 1,
517
- functions: netlifyDefinitions
518
- };
519
- await writeEdgeManifest(ctx, netlifyManifest);
520
- };
521
-
522
- export {
523
- createEdgeHandlers
524
- };
@@ -1,86 +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_semver
9
- } from "./chunk-PJG75HGC.js";
10
- import {
11
- getAPIRoutesConfigs
12
- } from "./chunk-BG455SFE.js";
13
- import {
14
- __toESM
15
- } from "./chunk-5JVNISGM.js";
16
-
17
- // src/build/verification.ts
18
- var import_semver = __toESM(require_semver(), 1);
19
- import { existsSync } from "node:fs";
20
- var SUPPORTED_NEXT_VERSIONS = ">=13.5.0";
21
- function verifyPublishDir(ctx) {
22
- if (!existsSync(ctx.publishDir)) {
23
- ctx.failBuild(
24
- `Your publish directory was not found at: ${ctx.publishDir}, please check your build settings`
25
- );
26
- }
27
- if (ctx.publishDir === ctx.resolveFromPackagePath("")) {
28
- ctx.failBuild(
29
- `Your publish directory cannot be the same as the base directory of your site, please check your build settings`
30
- );
31
- }
32
- try {
33
- ctx.buildConfig;
34
- } catch {
35
- ctx.failBuild(
36
- "Your publish directory does not contain expected Next.js build output, please check your build settings"
37
- );
38
- }
39
- if ((ctx.buildConfig.output === "standalone" || ctx.buildConfig.output === void 0) && !existsSync(ctx.standaloneRootDir)) {
40
- ctx.failBuild(
41
- `Your publish directory does not contain expected Next.js build output, please make sure you are using Next.js version (${SUPPORTED_NEXT_VERSIONS})`
42
- );
43
- }
44
- if (ctx.buildConfig.output === "export" && !existsSync(ctx.resolveFromSiteDir("out"))) {
45
- ctx.failBuild(
46
- `Your export directory was not found at: ${ctx.resolveFromSiteDir(
47
- "out"
48
- )}, please check your build settings`
49
- );
50
- }
51
- }
52
- function verifyNextVersion(ctx, nextVersion) {
53
- if (!(0, import_semver.satisfies)(nextVersion, SUPPORTED_NEXT_VERSIONS, { includePrerelease: true })) {
54
- ctx.failBuild(
55
- `@netlify/plugin-next@5 requires Next.js version ${SUPPORTED_NEXT_VERSIONS}, but found ${nextVersion}. Please upgrade your project's Next.js version.`
56
- );
57
- }
58
- }
59
- function verifyBuildConfig(ctx) {
60
- if (ctx.buildConfig.experimental.ppr) {
61
- console.log(
62
- `Partial prerendering is not yet fully supported on Netlify, see https://ntl.fyi/nextjs-ppr for details`
63
- );
64
- }
65
- }
66
- async function verifyNoAdvancedAPIRoutes(ctx) {
67
- const apiRoutesConfigs = await getAPIRoutesConfigs(ctx);
68
- const unsupportedAPIRoutes = apiRoutesConfigs.filter((apiRouteConfig) => {
69
- return apiRouteConfig.config.type === "experimental-background" /* BACKGROUND */ || apiRouteConfig.config.type === "experimental-scheduled" /* SCHEDULED */;
70
- });
71
- if (unsupportedAPIRoutes.length !== 0) {
72
- ctx.failBuild(
73
- `@netlify/plugin-next@5 does not support advanced API routes. The following API routes should be migrated to Netlify background or scheduled functions:
74
- ${unsupportedAPIRoutes.map((apiRouteConfig) => ` - ${apiRouteConfig.apiRoute} (type: "${apiRouteConfig.config.type}")`).join("\n")}
75
-
76
- Refer to https://ntl.fyi/next-scheduled-bg-function-migration as migration example.`
77
- );
78
- }
79
- }
80
-
81
- export {
82
- verifyPublishDir,
83
- verifyNextVersion,
84
- verifyBuildConfig,
85
- verifyNoAdvancedAPIRoutes
86
- };
@@ -1,27 +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
- 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
- };
@@ -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
- };