@netlify/plugin-nextjs 5.10.7 → 5.11.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.
Files changed (34) 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 +47 -21
  4. package/dist/build/content/server.js +22 -15
  5. package/dist/build/content/static.js +4 -8
  6. package/dist/build/functions/edge.js +2 -2
  7. package/dist/build/functions/server.js +4 -8
  8. package/dist/build/image-cdn.js +1 -1
  9. package/dist/build/plugin-context.js +2 -2
  10. package/dist/build/templates/handler-monorepo.tmpl.js +0 -5
  11. package/dist/build/templates/handler.tmpl.js +0 -4
  12. package/dist/build/verification.js +3 -3
  13. package/dist/esm-chunks/{chunk-OEQOKJGE.js → chunk-6BT4RYQJ.js} +1 -12
  14. package/dist/esm-chunks/{chunk-APO262HE.js → chunk-F7NTXMLE.js} +26 -10
  15. package/dist/esm-chunks/chunk-FKDTZJRV.js +832 -0
  16. package/dist/esm-chunks/{chunk-NFOLXH6F.js → chunk-YUXQHOYO.js} +1 -1
  17. package/dist/index.js +3 -7
  18. package/dist/run/config.js +3 -3
  19. package/dist/run/constants.js +3 -3
  20. package/dist/run/handlers/cache.cjs +24 -234
  21. package/dist/run/handlers/request-context.cjs +63 -88
  22. package/dist/run/handlers/server.js +9 -6
  23. package/dist/run/handlers/tags-handler.cjs +192 -0
  24. package/dist/run/handlers/tracer.cjs +4 -4
  25. package/dist/run/handlers/use-cache-handler.js +1553 -0
  26. package/dist/run/headers.js +1 -1
  27. package/dist/run/revalidate.js +1 -1
  28. package/dist/shared/blobkey.js +1 -1
  29. package/edge-runtime/lib/routing.ts +12 -2
  30. package/package.json +1 -1
  31. package/dist/esm-chunks/chunk-5QSXBV7L.js +0 -89
  32. package/dist/esm-chunks/chunk-GNGHTHMQ.js +0 -1624
  33. package/dist/esm-chunks/package-SGSU42JZ.js +0 -148
  34. package/dist/run/handlers/tracing.js +0 -68968
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  __require
9
- } from "../esm-chunks/chunk-OEQOKJGE.js";
9
+ } from "../esm-chunks/chunk-6BT4RYQJ.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-OEQOKJGE.js";
7
+ import "../esm-chunks/chunk-6BT4RYQJ.js";
8
8
 
9
9
  // src/build/cache.ts
10
10
  import { existsSync } from "node:fs";
@@ -5,24 +5,20 @@
5
5
  })();
6
6
 
7
7
  import {
8
+ trace,
8
9
  wrapTracer
9
- } from "../../esm-chunks/chunk-5QSXBV7L.js";
10
- import {
11
- init_esm,
12
- trace
13
- } from "../../esm-chunks/chunk-GNGHTHMQ.js";
10
+ } from "../../esm-chunks/chunk-FKDTZJRV.js";
14
11
  import {
15
12
  require_out
16
- } from "../../esm-chunks/chunk-NFOLXH6F.js";
13
+ } from "../../esm-chunks/chunk-YUXQHOYO.js";
17
14
  import {
18
15
  require_semver
19
- } from "../../esm-chunks/chunk-APO262HE.js";
16
+ } from "../../esm-chunks/chunk-F7NTXMLE.js";
20
17
  import {
21
18
  __toESM
22
- } from "../../esm-chunks/chunk-OEQOKJGE.js";
19
+ } from "../../esm-chunks/chunk-6BT4RYQJ.js";
23
20
 
24
21
  // src/build/content/prerendered.ts
25
- init_esm();
26
22
  import { existsSync } from "node:fs";
27
23
  import { mkdir, readFile, writeFile } from "node:fs/promises";
28
24
  import { join } from "node:path";
@@ -63,6 +59,12 @@ var Queue = class {
63
59
  this.#size--;
64
60
  return current.value;
65
61
  }
62
+ peek() {
63
+ if (!this.#head) {
64
+ return;
65
+ }
66
+ return this.#head.value;
67
+ }
66
68
  clear() {
67
69
  this.#head = void 0;
68
70
  this.#tail = void 0;
@@ -78,24 +80,29 @@ var Queue = class {
78
80
  current = current.next;
79
81
  }
80
82
  }
83
+ *drain() {
84
+ while (this.#head) {
85
+ yield this.dequeue();
86
+ }
87
+ }
81
88
  };
82
89
 
83
90
  // node_modules/p-limit/index.js
84
- import { AsyncResource } from "async_hooks";
85
91
  function pLimit(concurrency) {
86
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
87
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
88
- }
92
+ validateConcurrency(concurrency);
89
93
  const queue = new Queue();
90
94
  let activeCount = 0;
91
- const next = () => {
92
- activeCount--;
93
- if (queue.size > 0) {
95
+ const resumeNext = () => {
96
+ if (activeCount < concurrency && queue.size > 0) {
94
97
  queue.dequeue()();
98
+ activeCount++;
95
99
  }
96
100
  };
101
+ const next = () => {
102
+ activeCount--;
103
+ resumeNext();
104
+ };
97
105
  const run = async (function_, resolve, arguments_) => {
98
- activeCount++;
99
106
  const result = (async () => function_(...arguments_))();
100
107
  resolve(result);
101
108
  try {
@@ -105,13 +112,15 @@ function pLimit(concurrency) {
105
112
  next();
106
113
  };
107
114
  const enqueue = (function_, resolve, arguments_) => {
108
- queue.enqueue(
109
- AsyncResource.bind(run.bind(void 0, function_, resolve, arguments_))
115
+ new Promise((internalResolve) => {
116
+ queue.enqueue(internalResolve);
117
+ }).then(
118
+ run.bind(void 0, function_, resolve, arguments_)
110
119
  );
111
120
  (async () => {
112
121
  await Promise.resolve();
113
- if (activeCount < concurrency && queue.size > 0) {
114
- queue.dequeue()();
122
+ if (activeCount < concurrency) {
123
+ resumeNext();
115
124
  }
116
125
  })();
117
126
  };
@@ -129,10 +138,27 @@ function pLimit(concurrency) {
129
138
  value() {
130
139
  queue.clear();
131
140
  }
141
+ },
142
+ concurrency: {
143
+ get: () => concurrency,
144
+ set(newConcurrency) {
145
+ validateConcurrency(newConcurrency);
146
+ concurrency = newConcurrency;
147
+ queueMicrotask(() => {
148
+ while (activeCount < concurrency && queue.size > 0) {
149
+ resumeNext();
150
+ }
151
+ });
152
+ }
132
153
  }
133
154
  });
134
155
  return generator;
135
156
  }
157
+ function validateConcurrency(concurrency) {
158
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
159
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
160
+ }
161
+ }
136
162
 
137
163
  // src/build/content/prerendered.ts
138
164
  var import_semver = __toESM(require_semver(), 1);
@@ -5,24 +5,20 @@
5
5
  })();
6
6
 
7
7
  import {
8
+ trace,
8
9
  wrapTracer
9
- } from "../../esm-chunks/chunk-5QSXBV7L.js";
10
- import {
11
- init_esm,
12
- trace
13
- } from "../../esm-chunks/chunk-GNGHTHMQ.js";
10
+ } from "../../esm-chunks/chunk-FKDTZJRV.js";
14
11
  import {
15
12
  require_out
16
- } from "../../esm-chunks/chunk-NFOLXH6F.js";
13
+ } from "../../esm-chunks/chunk-YUXQHOYO.js";
17
14
  import {
18
15
  require_semver
19
- } from "../../esm-chunks/chunk-APO262HE.js";
16
+ } from "../../esm-chunks/chunk-F7NTXMLE.js";
20
17
  import {
21
18
  __toESM
22
- } from "../../esm-chunks/chunk-OEQOKJGE.js";
19
+ } from "../../esm-chunks/chunk-6BT4RYQJ.js";
23
20
 
24
21
  // src/build/content/server.ts
25
- init_esm();
26
22
  import { existsSync } from "node:fs";
27
23
  import {
28
24
  access,
@@ -39,7 +35,7 @@ import { dirname, join, resolve, sep } from "node:path";
39
35
  import { join as posixJoin, sep as posixSep } from "node:path/posix";
40
36
  var import_fast_glob = __toESM(require_out(), 1);
41
37
  var import_semver = __toESM(require_semver(), 1);
42
- import { RUN_CONFIG } from "../../run/constants.js";
38
+ import { RUN_CONFIG_FILE } from "../../run/constants.js";
43
39
  var tracer = wrapTracer(trace.getTracer("Next runtime"));
44
40
  var toPosixPath = (path) => path.split(sep).join(posixSep);
45
41
  function isError(error) {
@@ -64,15 +60,24 @@ var copyNextServerCode = async (ctx) => {
64
60
  throw error;
65
61
  }
66
62
  }
67
- const reqServerFiles = JSON.parse(await readFile(reqServerFilesPath, "utf-8"));
63
+ const reqServerFiles = JSON.parse(
64
+ await readFile(reqServerFilesPath, "utf-8")
65
+ );
68
66
  if (toPosixPath(ctx.distDir).replace(new RegExp(`^${ctx.relativeAppDir}/?`), "") !== reqServerFiles.config.distDir) {
69
67
  reqServerFiles.config.distDir = ctx.nextDistDir;
70
68
  await writeFile(reqServerFilesPath, JSON.stringify(reqServerFiles));
71
69
  }
72
70
  await mkdir(ctx.serverHandlerDir, { recursive: true });
73
71
  await writeFile(
74
- join(ctx.serverHandlerDir, RUN_CONFIG),
75
- JSON.stringify(reqServerFiles.config),
72
+ join(ctx.serverHandlerDir, RUN_CONFIG_FILE),
73
+ JSON.stringify({
74
+ nextConfig: reqServerFiles.config,
75
+ // only enable setting up 'use cache' handler when Next.js supports CacheHandlerV2 as we don't have V1 compatible implementation
76
+ // see https://github.com/vercel/next.js/pull/76687 first released in v15.3.0-canary.13
77
+ enableUseCacheHandler: ctx.nextVersion ? (0, import_semver.satisfies)(ctx.nextVersion, ">=15.3.0-canary.13", {
78
+ includePrerelease: true
79
+ }) : false
80
+ }),
76
81
  "utf-8"
77
82
  );
78
83
  const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
@@ -216,8 +221,10 @@ var replaceMiddlewareManifest = async (sourcePath, destPath) => {
216
221
  await writeFile(destPath, newData);
217
222
  };
218
223
  var verifyHandlerDirStructure = async (ctx) => {
219
- const runConfig = JSON.parse(await readFile(join(ctx.serverHandlerDir, RUN_CONFIG), "utf-8"));
220
- const expectedBuildIDPath = join(ctx.serverHandlerDir, runConfig.distDir, "BUILD_ID");
224
+ const { nextConfig } = JSON.parse(
225
+ await readFile(join(ctx.serverHandlerDir, RUN_CONFIG_FILE), "utf-8")
226
+ );
227
+ const expectedBuildIDPath = join(ctx.serverHandlerDir, nextConfig.distDir, "BUILD_ID");
221
228
  if (!existsSync(expectedBuildIDPath)) {
222
229
  ctx.failBuild(
223
230
  `Failed creating server handler. BUILD_ID file not found at expected location "${expectedBuildIDPath}".`
@@ -5,21 +5,17 @@
5
5
  })();
6
6
 
7
7
  import {
8
+ trace,
8
9
  wrapTracer
9
- } from "../../esm-chunks/chunk-5QSXBV7L.js";
10
- import {
11
- init_esm,
12
- trace
13
- } from "../../esm-chunks/chunk-GNGHTHMQ.js";
10
+ } from "../../esm-chunks/chunk-FKDTZJRV.js";
14
11
  import {
15
12
  require_out
16
- } from "../../esm-chunks/chunk-NFOLXH6F.js";
13
+ } from "../../esm-chunks/chunk-YUXQHOYO.js";
17
14
  import {
18
15
  __toESM
19
- } from "../../esm-chunks/chunk-OEQOKJGE.js";
16
+ } from "../../esm-chunks/chunk-6BT4RYQJ.js";
20
17
 
21
18
  // src/build/content/static.ts
22
- init_esm();
23
19
  import { existsSync } from "node:fs";
24
20
  import { cp, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
25
21
  import { basename, join } from "node:path";
@@ -6,11 +6,11 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../../esm-chunks/chunk-NFOLXH6F.js";
9
+ } from "../../esm-chunks/chunk-YUXQHOYO.js";
10
10
  import {
11
11
  __commonJS,
12
12
  __toESM
13
- } from "../../esm-chunks/chunk-OEQOKJGE.js";
13
+ } from "../../esm-chunks/chunk-6BT4RYQJ.js";
14
14
 
15
15
  // node_modules/path-to-regexp/dist/index.js
16
16
  var require_dist = __commonJS({
@@ -5,21 +5,17 @@
5
5
  })();
6
6
 
7
7
  import {
8
+ trace,
8
9
  wrapTracer
9
- } from "../../esm-chunks/chunk-5QSXBV7L.js";
10
- import {
11
- init_esm,
12
- trace
13
- } from "../../esm-chunks/chunk-GNGHTHMQ.js";
10
+ } from "../../esm-chunks/chunk-FKDTZJRV.js";
14
11
  import {
15
12
  require_out
16
- } from "../../esm-chunks/chunk-NFOLXH6F.js";
13
+ } from "../../esm-chunks/chunk-YUXQHOYO.js";
17
14
  import {
18
15
  __toESM
19
- } from "../../esm-chunks/chunk-OEQOKJGE.js";
16
+ } from "../../esm-chunks/chunk-6BT4RYQJ.js";
20
17
 
21
18
  // src/build/functions/server.ts
22
- init_esm();
23
19
  import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
24
20
  import { join, relative } from "node:path";
25
21
  import { join as posixJoin } from "node:path/posix";
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  __commonJS,
9
9
  __toESM
10
- } from "../esm-chunks/chunk-OEQOKJGE.js";
10
+ } from "../esm-chunks/chunk-6BT4RYQJ.js";
11
11
 
12
12
  // node_modules/picomatch/lib/constants.js
13
13
  var require_constants = __commonJS({
@@ -6,10 +6,10 @@
6
6
 
7
7
  import {
8
8
  require_semver
9
- } from "../esm-chunks/chunk-APO262HE.js";
9
+ } from "../esm-chunks/chunk-F7NTXMLE.js";
10
10
  import {
11
11
  __toESM
12
- } from "../esm-chunks/chunk-OEQOKJGE.js";
12
+ } from "../esm-chunks/chunk-6BT4RYQJ.js";
13
13
 
14
14
  // src/build/plugin-context.ts
15
15
  var import_semver = __toESM(require_semver(), 1);
@@ -3,7 +3,6 @@ import {
3
3
  runWithRequestContext,
4
4
  } from '{{cwd}}/.netlify/dist/run/handlers/request-context.cjs'
5
5
  import { getTracer } from '{{cwd}}/.netlify/dist/run/handlers/tracer.cjs'
6
- import tracing from '{{cwd}}/.netlify/dist/run/handlers/tracing.js'
7
6
 
8
7
  process.chdir('{{cwd}}')
9
8
 
@@ -12,10 +11,6 @@ process.env.USE_REGIONAL_BLOBS = '{{useRegionalBlobs}}'
12
11
 
13
12
  let cachedHandler
14
13
  export default async function (req, context) {
15
- if (process.env.NETLIFY_OTLP_TRACE_EXPORTER_URL) {
16
- tracing.start()
17
- }
18
-
19
14
  const requestContext = createRequestContext(req, context)
20
15
  const tracer = getTracer()
21
16
 
@@ -4,15 +4,11 @@ import {
4
4
  } from './.netlify/dist/run/handlers/request-context.cjs'
5
5
  import serverHandler from './.netlify/dist/run/handlers/server.js'
6
6
  import { getTracer } from './.netlify/dist/run/handlers/tracer.cjs'
7
- import tracing from './.netlify/dist/run/handlers/tracing.js'
8
7
 
9
8
  // Set feature flag for regional blobs
10
9
  process.env.USE_REGIONAL_BLOBS = '{{useRegionalBlobs}}'
11
10
 
12
11
  export default async function handler(req, context) {
13
- if (process.env.NETLIFY_OTLP_TRACE_EXPORTER_URL) {
14
- tracing.start()
15
- }
16
12
  const requestContext = createRequestContext(req, context)
17
13
  const tracer = getTracer()
18
14
 
@@ -6,13 +6,13 @@
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "../esm-chunks/chunk-NFOLXH6F.js";
9
+ } from "../esm-chunks/chunk-YUXQHOYO.js";
10
10
  import {
11
11
  require_semver
12
- } from "../esm-chunks/chunk-APO262HE.js";
12
+ } from "../esm-chunks/chunk-F7NTXMLE.js";
13
13
  import {
14
14
  __toESM
15
- } from "../esm-chunks/chunk-OEQOKJGE.js";
15
+ } from "../esm-chunks/chunk-6BT4RYQJ.js";
16
16
 
17
17
  // src/build/verification.ts
18
18
  var import_fast_glob = __toESM(require_out(), 1);
@@ -16,16 +16,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
16
16
  if (typeof require !== "undefined") return require.apply(this, arguments);
17
17
  throw Error('Dynamic require of "' + x + '" is not supported');
18
18
  });
19
- var __esm = (fn, res) => function __init() {
20
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
21
- };
22
19
  var __commonJS = (cb, mod) => function __require2() {
23
20
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24
21
  };
25
- var __export = (target, all) => {
26
- for (var name in all)
27
- __defProp(target, name, { get: all[name], enumerable: true });
28
- };
29
22
  var __copyProps = (to, from, except, desc) => {
30
23
  if (from && typeof from === "object" || typeof from === "function") {
31
24
  for (let key of __getOwnPropNames(from))
@@ -42,13 +35,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
42
35
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
36
  mod
44
37
  ));
45
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
38
 
47
39
  export {
48
40
  __require,
49
- __esm,
50
41
  __commonJS,
51
- __export,
52
- __toESM,
53
- __toCommonJS
42
+ __toESM
54
43
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  __commonJS
9
- } from "./chunk-OEQOKJGE.js";
9
+ } from "./chunk-6BT4RYQJ.js";
10
10
 
11
11
  // node_modules/semver/internal/constants.js
12
12
  var require_constants = __commonJS({
@@ -61,6 +61,7 @@ var require_re = __commonJS({
61
61
  var re = exports.re = [];
62
62
  var safeRe = exports.safeRe = [];
63
63
  var src = exports.src = [];
64
+ var safeSrc = exports.safeSrc = [];
64
65
  var t = exports.t = {};
65
66
  var R = 0;
66
67
  var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
@@ -81,6 +82,7 @@ var require_re = __commonJS({
81
82
  debug(name, index, value);
82
83
  t[name] = index;
83
84
  src[index] = value;
85
+ safeSrc[index] = safe;
84
86
  re[index] = new RegExp(value, isGlobal ? "g" : void 0);
85
87
  safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
86
88
  };
@@ -177,7 +179,7 @@ var require_semver = __commonJS({
177
179
  "node_modules/semver/classes/semver.js"(exports, module) {
178
180
  var debug = require_debug();
179
181
  var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
180
- var { safeRe: re, t } = require_re();
182
+ var { safeRe: re, safeSrc: src, t } = require_re();
181
183
  var parseOptions = require_parse_options();
182
184
  var { compareIdentifiers } = require_identifiers();
183
185
  var SemVer = class _SemVer {
@@ -317,6 +319,18 @@ var require_semver = __commonJS({
317
319
  // preminor will bump the version up to the next minor release, and immediately
318
320
  // down to pre-release. premajor and prepatch work the same way.
319
321
  inc(release, identifier, identifierBase) {
322
+ if (release.startsWith("pre")) {
323
+ if (!identifier && identifierBase === false) {
324
+ throw new Error("invalid increment argument: identifier is empty");
325
+ }
326
+ if (identifier) {
327
+ const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`);
328
+ const match = `-${identifier}`.match(r);
329
+ if (!match || match[1] !== identifier) {
330
+ throw new Error(`invalid identifier: ${identifier}`);
331
+ }
332
+ }
333
+ }
320
334
  switch (release) {
321
335
  case "premajor":
322
336
  this.prerelease.length = 0;
@@ -344,6 +358,12 @@ var require_semver = __commonJS({
344
358
  }
345
359
  this.inc("pre", identifier, identifierBase);
346
360
  break;
361
+ case "release":
362
+ if (this.prerelease.length === 0) {
363
+ throw new Error(`version ${this.raw} is not a prerelease`);
364
+ }
365
+ this.prerelease.length = 0;
366
+ break;
347
367
  case "major":
348
368
  if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
349
369
  this.major++;
@@ -369,9 +389,6 @@ var require_semver = __commonJS({
369
389
  // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
370
390
  case "pre": {
371
391
  const base = Number(identifierBase) ? 1 : 0;
372
- if (!identifier && identifierBase === false) {
373
- throw new Error("invalid increment argument: identifier is empty");
374
- }
375
392
  if (this.prerelease.length === 0) {
376
393
  this.prerelease = [base];
377
394
  } else {
@@ -506,13 +523,12 @@ var require_diff = __commonJS({
506
523
  if (!lowVersion.patch && !lowVersion.minor) {
507
524
  return "major";
508
525
  }
509
- if (highVersion.patch) {
526
+ if (lowVersion.compareMain(highVersion) === 0) {
527
+ if (lowVersion.minor && !lowVersion.patch) {
528
+ return "minor";
529
+ }
510
530
  return "patch";
511
531
  }
512
- if (highVersion.minor) {
513
- return "minor";
514
- }
515
- return "major";
516
532
  }
517
533
  const prefix = highHasPre ? "pre" : "";
518
534
  if (v1.major !== v2.major) {