@netlify/plugin-nextjs 5.2.1 → 5.3.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 (33) hide show
  1. package/dist/build/advanced-api-routes.js +1 -1
  2. package/dist/build/cache.js +1 -1
  3. package/dist/build/content/prerendered.js +4 -4
  4. package/dist/build/content/server.js +10 -9
  5. package/dist/build/content/static.js +4 -4
  6. package/dist/build/functions/edge.js +2 -2
  7. package/dist/build/functions/server.js +4 -4
  8. package/dist/build/image-cdn.js +17 -33
  9. package/dist/build/plugin-context.js +17 -5
  10. package/dist/build/templates/handler-monorepo.tmpl.js +1 -3
  11. package/dist/build/templates/handler.tmpl.js +1 -3
  12. package/dist/build/verification.js +2 -2
  13. package/dist/esm-chunks/{chunk-PDPDW32D.js → chunk-5QSXBV7L.js} +1 -1
  14. package/dist/esm-chunks/{chunk-PJG75HGC.js → chunk-EFGWM7RS.js} +38 -655
  15. package/dist/esm-chunks/{chunk-VZNKO4OO.js → chunk-FHR56UHE.js} +56 -111
  16. package/dist/esm-chunks/{chunk-Y3K5Q6FP.js → chunk-GNGHTHMQ.js} +51 -86
  17. package/dist/esm-chunks/{chunk-5JVNISGM.js → chunk-OEQOKJGE.js} +1 -2
  18. package/dist/esm-chunks/{package-SCUAWNXR.js → package-HC2KHZCZ.js} +10 -10
  19. package/dist/index.js +3 -3
  20. package/dist/run/config.js +1 -1
  21. package/dist/run/constants.js +1 -1
  22. package/dist/run/handlers/cache.cjs +74 -230
  23. package/dist/run/handlers/server.js +353 -501
  24. package/dist/run/handlers/tracer.cjs +36 -60
  25. package/dist/run/handlers/tracing.js +1192 -1592
  26. package/dist/run/headers.js +2 -2
  27. package/dist/run/next.cjs +42 -78
  28. package/dist/run/revalidate.js +1 -1
  29. package/dist/run/systemlog.cjs +98 -0
  30. package/dist/shared/blobkey.js +1 -1
  31. package/edge-runtime/lib/response.ts +6 -3
  32. package/package.json +1 -1
  33. package/dist/run/systemlog.js +0 -107
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  __require
9
- } from "../esm-chunks/chunk-5JVNISGM.js";
9
+ } from "../esm-chunks/chunk-OEQOKJGE.js";
10
10
 
11
11
  // src/build/advanced-api-routes.ts
12
12
  import { existsSync } from "node:fs";
@@ -4,7 +4,7 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import "../esm-chunks/chunk-5JVNISGM.js";
7
+ import "../esm-chunks/chunk-OEQOKJGE.js";
8
8
 
9
9
  // src/build/cache.ts
10
10
  import { existsSync } from "node:fs";
@@ -6,17 +6,17 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../../esm-chunks/chunk-VZNKO4OO.js";
9
+ } from "../../esm-chunks/chunk-FHR56UHE.js";
10
10
  import {
11
11
  wrapTracer
12
- } from "../../esm-chunks/chunk-PDPDW32D.js";
12
+ } from "../../esm-chunks/chunk-5QSXBV7L.js";
13
13
  import {
14
14
  init_esm,
15
15
  trace
16
- } from "../../esm-chunks/chunk-Y3K5Q6FP.js";
16
+ } from "../../esm-chunks/chunk-GNGHTHMQ.js";
17
17
  import {
18
18
  __toESM
19
- } from "../../esm-chunks/chunk-5JVNISGM.js";
19
+ } from "../../esm-chunks/chunk-OEQOKJGE.js";
20
20
 
21
21
  // src/build/content/prerendered.ts
22
22
  init_esm();
@@ -6,40 +6,41 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../../esm-chunks/chunk-VZNKO4OO.js";
9
+ } from "../../esm-chunks/chunk-FHR56UHE.js";
10
10
  import {
11
11
  wrapTracer
12
- } from "../../esm-chunks/chunk-PDPDW32D.js";
12
+ } from "../../esm-chunks/chunk-5QSXBV7L.js";
13
13
  import {
14
14
  init_esm,
15
15
  trace
16
- } from "../../esm-chunks/chunk-Y3K5Q6FP.js";
16
+ } from "../../esm-chunks/chunk-GNGHTHMQ.js";
17
17
  import {
18
18
  require_semver
19
- } from "../../esm-chunks/chunk-PJG75HGC.js";
19
+ } from "../../esm-chunks/chunk-EFGWM7RS.js";
20
20
  import {
21
21
  __toESM
22
- } from "../../esm-chunks/chunk-5JVNISGM.js";
22
+ } from "../../esm-chunks/chunk-OEQOKJGE.js";
23
23
 
24
24
  // src/build/content/server.ts
25
25
  init_esm();
26
26
  import { existsSync } from "node:fs";
27
27
  import {
28
+ access,
28
29
  cp,
29
30
  mkdir,
30
31
  readFile,
31
32
  readdir,
32
33
  readlink,
33
34
  symlink,
34
- writeFile,
35
- access
35
+ writeFile
36
36
  } from "node:fs/promises";
37
37
  import { createRequire } from "node:module";
38
38
  import { dirname, join, resolve, sep } from "node:path";
39
- import { sep as posixSep, join as posixJoin } from "node:path/posix";
39
+ import { join as posixJoin, sep as posixSep } from "node:path/posix";
40
40
  var import_fast_glob = __toESM(require_out(), 1);
41
41
  var import_semver = __toESM(require_semver(), 1);
42
42
  import { RUN_CONFIG } from "../../run/constants.js";
43
+ import { logger } from "../../run/systemlog.cjs";
43
44
  import { verifyNextVersion } from "../verification.js";
44
45
  var tracer = wrapTracer(trace.getTracer("Next runtime"));
45
46
  var toPosixPath = (path) => path.split(sep).join(posixSep);
@@ -226,7 +227,7 @@ var writeTagsManifest = async (ctx) => {
226
227
  tags = meta.headers["x-next-cache-tags"];
227
228
  } catch {
228
229
  if (!definition.dataRoute?.endsWith("/default.rsc")) {
229
- console.log(`Unable to read cache tags for: ${path}`);
230
+ logger.log(`Unable to read cache tags for: ${path}`);
230
231
  }
231
232
  }
232
233
  }
@@ -6,17 +6,17 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../../esm-chunks/chunk-VZNKO4OO.js";
9
+ } from "../../esm-chunks/chunk-FHR56UHE.js";
10
10
  import {
11
11
  wrapTracer
12
- } from "../../esm-chunks/chunk-PDPDW32D.js";
12
+ } from "../../esm-chunks/chunk-5QSXBV7L.js";
13
13
  import {
14
14
  init_esm,
15
15
  trace
16
- } from "../../esm-chunks/chunk-Y3K5Q6FP.js";
16
+ } from "../../esm-chunks/chunk-GNGHTHMQ.js";
17
17
  import {
18
18
  __toESM
19
- } from "../../esm-chunks/chunk-5JVNISGM.js";
19
+ } from "../../esm-chunks/chunk-OEQOKJGE.js";
20
20
 
21
21
  // src/build/content/static.ts
22
22
  init_esm();
@@ -6,11 +6,11 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../../esm-chunks/chunk-VZNKO4OO.js";
9
+ } from "../../esm-chunks/chunk-FHR56UHE.js";
10
10
  import {
11
11
  __commonJS,
12
12
  __toESM
13
- } from "../../esm-chunks/chunk-5JVNISGM.js";
13
+ } from "../../esm-chunks/chunk-OEQOKJGE.js";
14
14
 
15
15
  // node_modules/path-to-regexp/dist/index.js
16
16
  var require_dist = __commonJS({
@@ -6,17 +6,17 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../../esm-chunks/chunk-VZNKO4OO.js";
9
+ } from "../../esm-chunks/chunk-FHR56UHE.js";
10
10
  import {
11
11
  wrapTracer
12
- } from "../../esm-chunks/chunk-PDPDW32D.js";
12
+ } from "../../esm-chunks/chunk-5QSXBV7L.js";
13
13
  import {
14
14
  init_esm,
15
15
  trace
16
- } from "../../esm-chunks/chunk-Y3K5Q6FP.js";
16
+ } from "../../esm-chunks/chunk-GNGHTHMQ.js";
17
17
  import {
18
18
  __toESM
19
- } from "../../esm-chunks/chunk-5JVNISGM.js";
19
+ } from "../../esm-chunks/chunk-OEQOKJGE.js";
20
20
 
21
21
  // src/build/functions/server.ts
22
22
  init_esm();
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  __commonJS,
9
9
  __toESM
10
- } from "../esm-chunks/chunk-5JVNISGM.js";
10
+ } from "../esm-chunks/chunk-OEQOKJGE.js";
11
11
 
12
12
  // node_modules/picomatch/lib/constants.js
13
13
  var require_constants = __commonJS({
@@ -239,10 +239,8 @@ var require_utils = __commonJS({
239
239
  };
240
240
  exports.escapeLast = (input, char, lastIdx) => {
241
241
  const idx = input.lastIndexOf(char, lastIdx);
242
- if (idx === -1)
243
- return input;
244
- if (input[idx - 1] === "\\")
245
- return exports.escapeLast(input, char, idx - 1);
242
+ if (idx === -1) return input;
243
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
246
244
  return `${input.slice(0, idx)}\\${input.slice(idx)}`;
247
245
  };
248
246
  exports.removePrefix = (input, state = {}) => {
@@ -409,8 +407,7 @@ var require_scan = __commonJS({
409
407
  slashes.push(index);
410
408
  tokens.push(token);
411
409
  token = { value: "", depth: 0, isGlob: false };
412
- if (finished === true)
413
- continue;
410
+ if (finished === true) continue;
414
411
  if (prev === CHAR_DOT && index === start + 1) {
415
412
  start += 2;
416
413
  continue;
@@ -446,8 +443,7 @@ var require_scan = __commonJS({
446
443
  }
447
444
  }
448
445
  if (code === CHAR_ASTERISK) {
449
- if (prev === CHAR_ASTERISK)
450
- isGlobstar = token.isGlobstar = true;
446
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
451
447
  isGlob = token.isGlob = true;
452
448
  finished = true;
453
449
  if (scanToEnd === true) {
@@ -540,8 +536,7 @@ var require_scan = __commonJS({
540
536
  }
541
537
  }
542
538
  if (opts.unescape === true) {
543
- if (glob)
544
- glob = utils.removeBackslashes(glob);
539
+ if (glob) glob = utils.removeBackslashes(glob);
545
540
  if (base && backslashes === true) {
546
541
  base = utils.removeBackslashes(base);
547
542
  }
@@ -750,8 +745,7 @@ var require_parse = __commonJS({
750
745
  if (extglobs.length && tok.type !== "paren") {
751
746
  extglobs[extglobs.length - 1].inner += tok.value;
752
747
  }
753
- if (tok.value || tok.output)
754
- append(tok);
748
+ if (tok.value || tok.output) append(tok);
755
749
  if (prev && prev.type === "text" && tok.type === "text") {
756
750
  prev.output = (prev.output || prev.value) + tok.value;
757
751
  prev.value += tok.value;
@@ -1066,8 +1060,7 @@ var require_parse = __commonJS({
1066
1060
  }
1067
1061
  if (value === ".") {
1068
1062
  if (state.braces > 0 && prev.type === "dot") {
1069
- if (prev.value === ".")
1070
- prev.output = DOT_LITERAL;
1063
+ if (prev.value === ".") prev.output = DOT_LITERAL;
1071
1064
  const brace = braces[braces.length - 1];
1072
1065
  prev.type = "dots";
1073
1066
  prev.output += value;
@@ -1279,20 +1272,17 @@ var require_parse = __commonJS({
1279
1272
  push(token);
1280
1273
  }
1281
1274
  while (state.brackets > 0) {
1282
- if (opts.strictBrackets === true)
1283
- throw new SyntaxError(syntaxError("closing", "]"));
1275
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1284
1276
  state.output = utils.escapeLast(state.output, "[");
1285
1277
  decrement("brackets");
1286
1278
  }
1287
1279
  while (state.parens > 0) {
1288
- if (opts.strictBrackets === true)
1289
- throw new SyntaxError(syntaxError("closing", ")"));
1280
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1290
1281
  state.output = utils.escapeLast(state.output, "(");
1291
1282
  decrement("parens");
1292
1283
  }
1293
1284
  while (state.braces > 0) {
1294
- if (opts.strictBrackets === true)
1295
- throw new SyntaxError(syntaxError("closing", "}"));
1285
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1296
1286
  state.output = utils.escapeLast(state.output, "{");
1297
1287
  decrement("braces");
1298
1288
  }
@@ -1338,8 +1328,7 @@ var require_parse = __commonJS({
1338
1328
  star = `(${star})`;
1339
1329
  }
1340
1330
  const globstar = (opts2) => {
1341
- if (opts2.noglobstar === true)
1342
- return star;
1331
+ if (opts2.noglobstar === true) return star;
1343
1332
  return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1344
1333
  };
1345
1334
  const create = (str) => {
@@ -1362,11 +1351,9 @@ var require_parse = __commonJS({
1362
1351
  return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1363
1352
  default: {
1364
1353
  const match = /^(.*?)\.(\w+)$/.exec(str);
1365
- if (!match)
1366
- return;
1354
+ if (!match) return;
1367
1355
  const source2 = create(match[1]);
1368
- if (!source2)
1369
- return;
1356
+ if (!source2) return;
1370
1357
  return source2 + DOT_LITERAL + match[2];
1371
1358
  }
1372
1359
  }
@@ -1397,8 +1384,7 @@ var require_picomatch = __commonJS({
1397
1384
  const arrayMatcher = (str) => {
1398
1385
  for (const isMatch of fns) {
1399
1386
  const state2 = isMatch(str);
1400
- if (state2)
1401
- return state2;
1387
+ if (state2) return state2;
1402
1388
  }
1403
1389
  return false;
1404
1390
  };
@@ -1475,8 +1461,7 @@ var require_picomatch = __commonJS({
1475
1461
  };
1476
1462
  picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
1477
1463
  picomatch.parse = (pattern, options) => {
1478
- if (Array.isArray(pattern))
1479
- return pattern.map((p) => picomatch.parse(p, options));
1464
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
1480
1465
  return parse(pattern, { ...options, fastpaths: false });
1481
1466
  };
1482
1467
  picomatch.scan = (input, options) => scan(input, options);
@@ -1515,8 +1500,7 @@ var require_picomatch = __commonJS({
1515
1500
  const opts = options || {};
1516
1501
  return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1517
1502
  } catch (err) {
1518
- if (options && options.debug === true)
1519
- throw err;
1503
+ if (options && options.debug === true) throw err;
1520
1504
  return /$^/;
1521
1505
  }
1522
1506
  };
@@ -4,9 +4,15 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import "../esm-chunks/chunk-5JVNISGM.js";
7
+ import {
8
+ require_semver
9
+ } from "../esm-chunks/chunk-EFGWM7RS.js";
10
+ import {
11
+ __toESM
12
+ } from "../esm-chunks/chunk-OEQOKJGE.js";
8
13
 
9
14
  // src/build/plugin-context.ts
15
+ var import_semver = __toESM(require_semver(), 1);
10
16
  import { existsSync, readFileSync } from "node:fs";
11
17
  import { readFile } from "node:fs/promises";
12
18
  import { join, relative, resolve } from "node:path";
@@ -17,10 +23,11 @@ var DEFAULT_PUBLISH_DIR = ".next";
17
23
  var SERVER_HANDLER_NAME = "___netlify-server-handler";
18
24
  var EDGE_HANDLER_NAME = "___netlify-edge-handler";
19
25
  var PluginContext = class {
20
- utils;
26
+ featureFlags;
21
27
  netlifyConfig;
22
28
  pluginName;
23
29
  pluginVersion;
30
+ utils;
24
31
  constants;
25
32
  packageJSON;
26
33
  /** Absolute path of the next runtime plugin directory */
@@ -101,7 +108,11 @@ var PluginContext = class {
101
108
  return this.constants.NETLIFY_BUILD_VERSION || "v0.0.0";
102
109
  }
103
110
  get useRegionalBlobs() {
104
- return false;
111
+ if (!(this.featureFlags || {})["next-runtime-regional-blobs"]) {
112
+ return false;
113
+ }
114
+ const REQUIRED_BUILD_VERSION = ">=29.41.5";
115
+ return (0, import_semver.satisfies)(this.buildVersion, REQUIRED_BUILD_VERSION, { includePrerelease: true });
105
116
  }
106
117
  /**
107
118
  * Absolute path of the directory containing the files for the serverless lambda function
@@ -138,12 +149,13 @@ var PluginContext = class {
138
149
  return join(this.edgeFunctionsDir, EDGE_HANDLER_NAME);
139
150
  }
140
151
  constructor(options) {
152
+ this.constants = options.constants;
153
+ this.featureFlags = options.featureFlags;
154
+ this.netlifyConfig = options.netlifyConfig;
141
155
  this.packageJSON = JSON.parse(readFileSync(join(PLUGIN_DIR, "package.json"), "utf-8"));
142
156
  this.pluginName = this.packageJSON.name;
143
157
  this.pluginVersion = this.packageJSON.version;
144
- this.constants = options.constants;
145
158
  this.utils = options.utils;
146
- this.netlifyConfig = options.netlifyConfig;
147
159
  }
148
160
  /** Resolves a path correctly with mono repository awareness for .netlify directories mainly */
149
161
  resolveFromPackagePath(...args) {
@@ -16,9 +16,7 @@ export default async function (req, context) {
16
16
  tracing.start()
17
17
  }
18
18
 
19
- const requestContext = createRequestContext(
20
- req.headers.get('x-nf-debug-logging') || req.headers.get('x-next-debug-logging'),
21
- )
19
+ const requestContext = createRequestContext(req.headers.get('x-next-debug-logging'))
22
20
  const tracer = getTracer()
23
21
 
24
22
  const handlerResponse = await runWithRequestContext(requestContext, () => {
@@ -13,9 +13,7 @@ export default async function handler(req, context) {
13
13
  if (process.env.NETLIFY_OTLP_TRACE_EXPORTER_URL) {
14
14
  tracing.start()
15
15
  }
16
- const requestContext = createRequestContext(
17
- req.headers.get('x-nf-debug-logging') || req.headers.get('x-next-debug-logging'),
18
- )
16
+ const requestContext = createRequestContext(req.headers.get('x-next-debug-logging'))
19
17
  const tracer = getTracer()
20
18
 
21
19
  const handlerResponse = await runWithRequestContext(requestContext, () => {
@@ -6,10 +6,10 @@
6
6
 
7
7
  import {
8
8
  require_semver
9
- } from "../esm-chunks/chunk-PJG75HGC.js";
9
+ } from "../esm-chunks/chunk-EFGWM7RS.js";
10
10
  import {
11
11
  __toESM
12
- } from "../esm-chunks/chunk-5JVNISGM.js";
12
+ } from "../esm-chunks/chunk-OEQOKJGE.js";
13
13
 
14
14
  // src/build/verification.ts
15
15
  var import_semver = __toESM(require_semver(), 1);
@@ -8,7 +8,7 @@ import {
8
8
  SpanStatusCode,
9
9
  context,
10
10
  init_esm
11
- } from "./chunk-Y3K5Q6FP.js";
11
+ } from "./chunk-GNGHTHMQ.js";
12
12
 
13
13
  // node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js
14
14
  init_esm();