@netlify/plugin-nextjs 5.11.1 → 5.11.2
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/prerendered.js +1 -1
- package/dist/build/content/server.js +1 -1
- package/dist/build/content/static.js +4 -2
- package/dist/build/functions/edge.js +11 -9
- package/dist/build/plugin-context.js +25 -2
- package/dist/build/verification.js +1 -1
- package/dist/esm-chunks/{chunk-F7NTXMLE.js → chunk-TLQCAGE2.js} +49 -5
- package/dist/run/handlers/tags-handler.cjs +1 -1
- package/dist/run/next.cjs +12 -6
- package/dist/shared/blob-types.cjs +1 -1
- package/edge-runtime/lib/middleware.ts +4 -0
- package/edge-runtime/lib/response.ts +17 -19
- package/package.json +1 -1
|
@@ -32,16 +32,18 @@ var copyStaticContent = async (ctx) => {
|
|
|
32
32
|
extglob: true
|
|
33
33
|
});
|
|
34
34
|
const fallbacks = ctx.getFallbacks(await ctx.getPrerenderManifest());
|
|
35
|
+
const fullyStaticPages = await ctx.getFullyStaticHtmlPages();
|
|
35
36
|
try {
|
|
36
37
|
await mkdir(destDir, { recursive: true });
|
|
37
38
|
await Promise.all(
|
|
38
|
-
paths.filter((path) => !paths.includes(`${path.slice(0, -5)}.json`)).map(async (path) => {
|
|
39
|
+
paths.filter((path) => !path.endsWith(".json") && !paths.includes(`${path.slice(0, -5)}.json`)).map(async (path) => {
|
|
39
40
|
const html = await readFile(join(srcDir, path), "utf-8");
|
|
40
41
|
verifyNetlifyForms(ctx, html);
|
|
41
42
|
const isFallback = fallbacks.includes(path.slice(0, -5));
|
|
43
|
+
const isFullyStaticPage = !isFallback && fullyStaticPages.includes(path);
|
|
42
44
|
await writeFile(
|
|
43
45
|
join(destDir, await encodeBlobKey(path)),
|
|
44
|
-
JSON.stringify({ html,
|
|
46
|
+
JSON.stringify({ html, isFullyStaticPage }),
|
|
45
47
|
"utf-8"
|
|
46
48
|
);
|
|
47
49
|
})
|
|
@@ -487,7 +487,7 @@ var writeHandlerFile = async (ctx, { matchers, name }) => {
|
|
|
487
487
|
`
|
|
488
488
|
);
|
|
489
489
|
};
|
|
490
|
-
var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
|
|
490
|
+
var copyHandlerDependencies = async (ctx, { name, env, files, wasm }) => {
|
|
491
491
|
const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
|
|
492
492
|
const destDir = join(ctx.edgeFunctionsDir, getHandlerName({ name }));
|
|
493
493
|
const edgeRuntimeDir = join(ctx.pluginDir, "edge-runtime");
|
|
@@ -495,6 +495,11 @@ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
|
|
|
495
495
|
const shim = await readFile(shimPath, "utf8");
|
|
496
496
|
const parts = [shim];
|
|
497
497
|
const outputFile = join(destDir, `server/${name}.js`);
|
|
498
|
+
if (env) {
|
|
499
|
+
for (const [key, value] of Object.entries(env)) {
|
|
500
|
+
parts.push(`process.env.${key} = '${value}';`);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
498
503
|
if (wasm?.length) {
|
|
499
504
|
for (const wasmChunk of wasm ?? []) {
|
|
500
505
|
const data = await readFile(join(srcDir, wasmChunk.filePath));
|
|
@@ -516,13 +521,13 @@ var createEdgeHandler = async (ctx, definition) => {
|
|
|
516
521
|
};
|
|
517
522
|
var getHandlerName = ({ name }) => `${EDGE_HANDLER_NAME}-${name.replace(/\W/g, "-")}`;
|
|
518
523
|
var buildHandlerDefinition = (ctx, { name, matchers, page }) => {
|
|
519
|
-
const
|
|
520
|
-
const
|
|
524
|
+
const functionHandlerName = getHandlerName({ name });
|
|
525
|
+
const functionName = name.endsWith("middleware") ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`;
|
|
521
526
|
const cache = name.endsWith("middleware") ? void 0 : "manual";
|
|
522
527
|
const generator = `${ctx.pluginName}@${ctx.pluginVersion}`;
|
|
523
528
|
return augmentMatchers(matchers, ctx).map((matcher) => ({
|
|
524
|
-
function:
|
|
525
|
-
name:
|
|
529
|
+
function: functionHandlerName,
|
|
530
|
+
name: functionName,
|
|
526
531
|
pattern: matcher.regexp,
|
|
527
532
|
cache,
|
|
528
533
|
generator
|
|
@@ -533,10 +538,7 @@ var clearStaleEdgeHandlers = async (ctx) => {
|
|
|
533
538
|
};
|
|
534
539
|
var createEdgeHandlers = async (ctx) => {
|
|
535
540
|
const nextManifest = await ctx.getMiddlewareManifest();
|
|
536
|
-
const nextDefinitions = [
|
|
537
|
-
...Object.values(nextManifest.middleware)
|
|
538
|
-
// ...Object.values(nextManifest.functions)
|
|
539
|
-
];
|
|
541
|
+
const nextDefinitions = [...Object.values(nextManifest.middleware)];
|
|
540
542
|
await Promise.all(nextDefinitions.map((def) => createEdgeHandler(ctx, def)));
|
|
541
543
|
const netlifyDefinitions = nextDefinitions.flatMap((def) => buildHandlerDefinition(ctx, def));
|
|
542
544
|
const netlifyManifest = {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
require_semver
|
|
9
|
-
} from "../esm-chunks/chunk-
|
|
9
|
+
} from "../esm-chunks/chunk-TLQCAGE2.js";
|
|
10
10
|
import {
|
|
11
11
|
__toESM
|
|
12
12
|
} from "../esm-chunks/chunk-6BT4RYQJ.js";
|
|
@@ -17,7 +17,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
17
17
|
import { readFile } from "node:fs/promises";
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { join, relative, resolve } from "node:path";
|
|
20
|
-
import { join as posixJoin } from "node:path/posix";
|
|
20
|
+
import { join as posixJoin, relative as posixRelative } from "node:path/posix";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
23
23
|
var PLUGIN_DIR = join(MODULE_DIR, "../..");
|
|
@@ -292,6 +292,29 @@ var PluginContext = class {
|
|
|
292
292
|
}
|
|
293
293
|
return this.#fallbacks;
|
|
294
294
|
}
|
|
295
|
+
#fullyStaticHtmlPages = null;
|
|
296
|
+
/**
|
|
297
|
+
* Get an array of fully static pages router pages (no `getServerSideProps` or `getStaticProps`).
|
|
298
|
+
* Those are being served as-is without involving CacheHandler, so we need to keep track of them
|
|
299
|
+
* to make sure we apply permanent caching headers for responses that use them.
|
|
300
|
+
*/
|
|
301
|
+
async getFullyStaticHtmlPages() {
|
|
302
|
+
if (!this.#fullyStaticHtmlPages) {
|
|
303
|
+
const pagesManifest = JSON.parse(
|
|
304
|
+
await readFile(join(this.publishDir, "server/pages-manifest.json"), "utf-8")
|
|
305
|
+
);
|
|
306
|
+
this.#fullyStaticHtmlPages = Object.values(pagesManifest).filter(
|
|
307
|
+
(filePath) => (
|
|
308
|
+
// Limit handling to pages router files (App Router pages should not be included in pages-manifest.json
|
|
309
|
+
// as they have their own app-paths-manifest.json)
|
|
310
|
+
filePath.startsWith("pages/") && // Fully static pages will have entries in the pages-manifest.json pointing to .html files.
|
|
311
|
+
// Pages with data fetching exports will point to .js files.
|
|
312
|
+
filePath.endsWith(".html")
|
|
313
|
+
)
|
|
314
|
+
).map((filePath) => posixRelative("pages", filePath));
|
|
315
|
+
}
|
|
316
|
+
return this.#fullyStaticHtmlPages;
|
|
317
|
+
}
|
|
295
318
|
/** Fails a build with a message and an optional error */
|
|
296
319
|
failBuild(message, error) {
|
|
297
320
|
return this.utils.build.failBuild(message, error instanceof Error ? { error } : void 0);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
// node_modules/semver/internal/constants.js
|
|
12
12
|
var require_constants = __commonJS({
|
|
13
13
|
"node_modules/semver/internal/constants.js"(exports, module) {
|
|
14
|
+
"use strict";
|
|
14
15
|
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
15
16
|
var MAX_LENGTH = 256;
|
|
16
17
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
@@ -42,6 +43,7 @@ var require_constants = __commonJS({
|
|
|
42
43
|
// node_modules/semver/internal/debug.js
|
|
43
44
|
var require_debug = __commonJS({
|
|
44
45
|
"node_modules/semver/internal/debug.js"(exports, module) {
|
|
46
|
+
"use strict";
|
|
45
47
|
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
46
48
|
};
|
|
47
49
|
module.exports = debug;
|
|
@@ -51,6 +53,7 @@ var require_debug = __commonJS({
|
|
|
51
53
|
// node_modules/semver/internal/re.js
|
|
52
54
|
var require_re = __commonJS({
|
|
53
55
|
"node_modules/semver/internal/re.js"(exports, module) {
|
|
56
|
+
"use strict";
|
|
54
57
|
var {
|
|
55
58
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
56
59
|
MAX_SAFE_BUILD_LENGTH,
|
|
@@ -91,8 +94,8 @@ var require_re = __commonJS({
|
|
|
91
94
|
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
92
95
|
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
93
96
|
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
94
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.
|
|
95
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.
|
|
97
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
98
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
96
99
|
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
97
100
|
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
98
101
|
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
@@ -138,6 +141,7 @@ var require_re = __commonJS({
|
|
|
138
141
|
// node_modules/semver/internal/parse-options.js
|
|
139
142
|
var require_parse_options = __commonJS({
|
|
140
143
|
"node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
144
|
+
"use strict";
|
|
141
145
|
var looseOption = Object.freeze({ loose: true });
|
|
142
146
|
var emptyOpts = Object.freeze({});
|
|
143
147
|
var parseOptions = (options) => {
|
|
@@ -156,6 +160,7 @@ var require_parse_options = __commonJS({
|
|
|
156
160
|
// node_modules/semver/internal/identifiers.js
|
|
157
161
|
var require_identifiers = __commonJS({
|
|
158
162
|
"node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
163
|
+
"use strict";
|
|
159
164
|
var numeric = /^[0-9]+$/;
|
|
160
165
|
var compareIdentifiers = (a, b) => {
|
|
161
166
|
const anum = numeric.test(a);
|
|
@@ -177,9 +182,10 @@ var require_identifiers = __commonJS({
|
|
|
177
182
|
// node_modules/semver/classes/semver.js
|
|
178
183
|
var require_semver = __commonJS({
|
|
179
184
|
"node_modules/semver/classes/semver.js"(exports, module) {
|
|
185
|
+
"use strict";
|
|
180
186
|
var debug = require_debug();
|
|
181
187
|
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
182
|
-
var { safeRe: re,
|
|
188
|
+
var { safeRe: re, t } = require_re();
|
|
183
189
|
var parseOptions = require_parse_options();
|
|
184
190
|
var { compareIdentifiers } = require_identifiers();
|
|
185
191
|
var SemVer = class _SemVer {
|
|
@@ -324,8 +330,7 @@ var require_semver = __commonJS({
|
|
|
324
330
|
throw new Error("invalid increment argument: identifier is empty");
|
|
325
331
|
}
|
|
326
332
|
if (identifier) {
|
|
327
|
-
const
|
|
328
|
-
const match = `-${identifier}`.match(r);
|
|
333
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
329
334
|
if (!match || match[1] !== identifier) {
|
|
330
335
|
throw new Error(`invalid identifier: ${identifier}`);
|
|
331
336
|
}
|
|
@@ -438,6 +443,7 @@ var require_semver = __commonJS({
|
|
|
438
443
|
// node_modules/semver/functions/parse.js
|
|
439
444
|
var require_parse = __commonJS({
|
|
440
445
|
"node_modules/semver/functions/parse.js"(exports, module) {
|
|
446
|
+
"use strict";
|
|
441
447
|
var SemVer = require_semver();
|
|
442
448
|
var parse = (version, options, throwErrors = false) => {
|
|
443
449
|
if (version instanceof SemVer) {
|
|
@@ -459,6 +465,7 @@ var require_parse = __commonJS({
|
|
|
459
465
|
// node_modules/semver/functions/valid.js
|
|
460
466
|
var require_valid = __commonJS({
|
|
461
467
|
"node_modules/semver/functions/valid.js"(exports, module) {
|
|
468
|
+
"use strict";
|
|
462
469
|
var parse = require_parse();
|
|
463
470
|
var valid = (version, options) => {
|
|
464
471
|
const v = parse(version, options);
|
|
@@ -471,6 +478,7 @@ var require_valid = __commonJS({
|
|
|
471
478
|
// node_modules/semver/functions/clean.js
|
|
472
479
|
var require_clean = __commonJS({
|
|
473
480
|
"node_modules/semver/functions/clean.js"(exports, module) {
|
|
481
|
+
"use strict";
|
|
474
482
|
var parse = require_parse();
|
|
475
483
|
var clean = (version, options) => {
|
|
476
484
|
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
@@ -483,6 +491,7 @@ var require_clean = __commonJS({
|
|
|
483
491
|
// node_modules/semver/functions/inc.js
|
|
484
492
|
var require_inc = __commonJS({
|
|
485
493
|
"node_modules/semver/functions/inc.js"(exports, module) {
|
|
494
|
+
"use strict";
|
|
486
495
|
var SemVer = require_semver();
|
|
487
496
|
var inc = (version, release, options, identifier, identifierBase) => {
|
|
488
497
|
if (typeof options === "string") {
|
|
@@ -506,6 +515,7 @@ var require_inc = __commonJS({
|
|
|
506
515
|
// node_modules/semver/functions/diff.js
|
|
507
516
|
var require_diff = __commonJS({
|
|
508
517
|
"node_modules/semver/functions/diff.js"(exports, module) {
|
|
518
|
+
"use strict";
|
|
509
519
|
var parse = require_parse();
|
|
510
520
|
var diff = (version1, version2) => {
|
|
511
521
|
const v1 = parse(version1, null, true);
|
|
@@ -549,6 +559,7 @@ var require_diff = __commonJS({
|
|
|
549
559
|
// node_modules/semver/functions/major.js
|
|
550
560
|
var require_major = __commonJS({
|
|
551
561
|
"node_modules/semver/functions/major.js"(exports, module) {
|
|
562
|
+
"use strict";
|
|
552
563
|
var SemVer = require_semver();
|
|
553
564
|
var major = (a, loose) => new SemVer(a, loose).major;
|
|
554
565
|
module.exports = major;
|
|
@@ -558,6 +569,7 @@ var require_major = __commonJS({
|
|
|
558
569
|
// node_modules/semver/functions/minor.js
|
|
559
570
|
var require_minor = __commonJS({
|
|
560
571
|
"node_modules/semver/functions/minor.js"(exports, module) {
|
|
572
|
+
"use strict";
|
|
561
573
|
var SemVer = require_semver();
|
|
562
574
|
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
563
575
|
module.exports = minor;
|
|
@@ -567,6 +579,7 @@ var require_minor = __commonJS({
|
|
|
567
579
|
// node_modules/semver/functions/patch.js
|
|
568
580
|
var require_patch = __commonJS({
|
|
569
581
|
"node_modules/semver/functions/patch.js"(exports, module) {
|
|
582
|
+
"use strict";
|
|
570
583
|
var SemVer = require_semver();
|
|
571
584
|
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
572
585
|
module.exports = patch;
|
|
@@ -576,6 +589,7 @@ var require_patch = __commonJS({
|
|
|
576
589
|
// node_modules/semver/functions/prerelease.js
|
|
577
590
|
var require_prerelease = __commonJS({
|
|
578
591
|
"node_modules/semver/functions/prerelease.js"(exports, module) {
|
|
592
|
+
"use strict";
|
|
579
593
|
var parse = require_parse();
|
|
580
594
|
var prerelease = (version, options) => {
|
|
581
595
|
const parsed = parse(version, options);
|
|
@@ -588,6 +602,7 @@ var require_prerelease = __commonJS({
|
|
|
588
602
|
// node_modules/semver/functions/compare.js
|
|
589
603
|
var require_compare = __commonJS({
|
|
590
604
|
"node_modules/semver/functions/compare.js"(exports, module) {
|
|
605
|
+
"use strict";
|
|
591
606
|
var SemVer = require_semver();
|
|
592
607
|
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
593
608
|
module.exports = compare;
|
|
@@ -597,6 +612,7 @@ var require_compare = __commonJS({
|
|
|
597
612
|
// node_modules/semver/functions/rcompare.js
|
|
598
613
|
var require_rcompare = __commonJS({
|
|
599
614
|
"node_modules/semver/functions/rcompare.js"(exports, module) {
|
|
615
|
+
"use strict";
|
|
600
616
|
var compare = require_compare();
|
|
601
617
|
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
602
618
|
module.exports = rcompare;
|
|
@@ -606,6 +622,7 @@ var require_rcompare = __commonJS({
|
|
|
606
622
|
// node_modules/semver/functions/compare-loose.js
|
|
607
623
|
var require_compare_loose = __commonJS({
|
|
608
624
|
"node_modules/semver/functions/compare-loose.js"(exports, module) {
|
|
625
|
+
"use strict";
|
|
609
626
|
var compare = require_compare();
|
|
610
627
|
var compareLoose = (a, b) => compare(a, b, true);
|
|
611
628
|
module.exports = compareLoose;
|
|
@@ -615,6 +632,7 @@ var require_compare_loose = __commonJS({
|
|
|
615
632
|
// node_modules/semver/functions/compare-build.js
|
|
616
633
|
var require_compare_build = __commonJS({
|
|
617
634
|
"node_modules/semver/functions/compare-build.js"(exports, module) {
|
|
635
|
+
"use strict";
|
|
618
636
|
var SemVer = require_semver();
|
|
619
637
|
var compareBuild = (a, b, loose) => {
|
|
620
638
|
const versionA = new SemVer(a, loose);
|
|
@@ -628,6 +646,7 @@ var require_compare_build = __commonJS({
|
|
|
628
646
|
// node_modules/semver/functions/sort.js
|
|
629
647
|
var require_sort = __commonJS({
|
|
630
648
|
"node_modules/semver/functions/sort.js"(exports, module) {
|
|
649
|
+
"use strict";
|
|
631
650
|
var compareBuild = require_compare_build();
|
|
632
651
|
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
633
652
|
module.exports = sort;
|
|
@@ -637,6 +656,7 @@ var require_sort = __commonJS({
|
|
|
637
656
|
// node_modules/semver/functions/rsort.js
|
|
638
657
|
var require_rsort = __commonJS({
|
|
639
658
|
"node_modules/semver/functions/rsort.js"(exports, module) {
|
|
659
|
+
"use strict";
|
|
640
660
|
var compareBuild = require_compare_build();
|
|
641
661
|
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
642
662
|
module.exports = rsort;
|
|
@@ -646,6 +666,7 @@ var require_rsort = __commonJS({
|
|
|
646
666
|
// node_modules/semver/functions/gt.js
|
|
647
667
|
var require_gt = __commonJS({
|
|
648
668
|
"node_modules/semver/functions/gt.js"(exports, module) {
|
|
669
|
+
"use strict";
|
|
649
670
|
var compare = require_compare();
|
|
650
671
|
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
651
672
|
module.exports = gt;
|
|
@@ -655,6 +676,7 @@ var require_gt = __commonJS({
|
|
|
655
676
|
// node_modules/semver/functions/lt.js
|
|
656
677
|
var require_lt = __commonJS({
|
|
657
678
|
"node_modules/semver/functions/lt.js"(exports, module) {
|
|
679
|
+
"use strict";
|
|
658
680
|
var compare = require_compare();
|
|
659
681
|
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
660
682
|
module.exports = lt;
|
|
@@ -664,6 +686,7 @@ var require_lt = __commonJS({
|
|
|
664
686
|
// node_modules/semver/functions/eq.js
|
|
665
687
|
var require_eq = __commonJS({
|
|
666
688
|
"node_modules/semver/functions/eq.js"(exports, module) {
|
|
689
|
+
"use strict";
|
|
667
690
|
var compare = require_compare();
|
|
668
691
|
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
669
692
|
module.exports = eq;
|
|
@@ -673,6 +696,7 @@ var require_eq = __commonJS({
|
|
|
673
696
|
// node_modules/semver/functions/neq.js
|
|
674
697
|
var require_neq = __commonJS({
|
|
675
698
|
"node_modules/semver/functions/neq.js"(exports, module) {
|
|
699
|
+
"use strict";
|
|
676
700
|
var compare = require_compare();
|
|
677
701
|
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
678
702
|
module.exports = neq;
|
|
@@ -682,6 +706,7 @@ var require_neq = __commonJS({
|
|
|
682
706
|
// node_modules/semver/functions/gte.js
|
|
683
707
|
var require_gte = __commonJS({
|
|
684
708
|
"node_modules/semver/functions/gte.js"(exports, module) {
|
|
709
|
+
"use strict";
|
|
685
710
|
var compare = require_compare();
|
|
686
711
|
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
687
712
|
module.exports = gte;
|
|
@@ -691,6 +716,7 @@ var require_gte = __commonJS({
|
|
|
691
716
|
// node_modules/semver/functions/lte.js
|
|
692
717
|
var require_lte = __commonJS({
|
|
693
718
|
"node_modules/semver/functions/lte.js"(exports, module) {
|
|
719
|
+
"use strict";
|
|
694
720
|
var compare = require_compare();
|
|
695
721
|
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
696
722
|
module.exports = lte;
|
|
@@ -700,6 +726,7 @@ var require_lte = __commonJS({
|
|
|
700
726
|
// node_modules/semver/functions/cmp.js
|
|
701
727
|
var require_cmp = __commonJS({
|
|
702
728
|
"node_modules/semver/functions/cmp.js"(exports, module) {
|
|
729
|
+
"use strict";
|
|
703
730
|
var eq = require_eq();
|
|
704
731
|
var neq = require_neq();
|
|
705
732
|
var gt = require_gt();
|
|
@@ -749,6 +776,7 @@ var require_cmp = __commonJS({
|
|
|
749
776
|
// node_modules/semver/functions/coerce.js
|
|
750
777
|
var require_coerce = __commonJS({
|
|
751
778
|
"node_modules/semver/functions/coerce.js"(exports, module) {
|
|
779
|
+
"use strict";
|
|
752
780
|
var SemVer = require_semver();
|
|
753
781
|
var parse = require_parse();
|
|
754
782
|
var { safeRe: re, t } = require_re();
|
|
@@ -794,6 +822,7 @@ var require_coerce = __commonJS({
|
|
|
794
822
|
// node_modules/semver/internal/lrucache.js
|
|
795
823
|
var require_lrucache = __commonJS({
|
|
796
824
|
"node_modules/semver/internal/lrucache.js"(exports, module) {
|
|
825
|
+
"use strict";
|
|
797
826
|
var LRUCache = class {
|
|
798
827
|
constructor() {
|
|
799
828
|
this.max = 1e3;
|
|
@@ -831,6 +860,7 @@ var require_lrucache = __commonJS({
|
|
|
831
860
|
// node_modules/semver/classes/range.js
|
|
832
861
|
var require_range = __commonJS({
|
|
833
862
|
"node_modules/semver/classes/range.js"(exports, module) {
|
|
863
|
+
"use strict";
|
|
834
864
|
var SPACE_CHARACTERS = /\s+/g;
|
|
835
865
|
var Range = class _Range {
|
|
836
866
|
constructor(range, options) {
|
|
@@ -1206,6 +1236,7 @@ var require_range = __commonJS({
|
|
|
1206
1236
|
// node_modules/semver/classes/comparator.js
|
|
1207
1237
|
var require_comparator = __commonJS({
|
|
1208
1238
|
"node_modules/semver/classes/comparator.js"(exports, module) {
|
|
1239
|
+
"use strict";
|
|
1209
1240
|
var ANY = Symbol("SemVer ANY");
|
|
1210
1241
|
var Comparator = class _Comparator {
|
|
1211
1242
|
static get ANY() {
|
|
@@ -1318,6 +1349,7 @@ var require_comparator = __commonJS({
|
|
|
1318
1349
|
// node_modules/semver/functions/satisfies.js
|
|
1319
1350
|
var require_satisfies = __commonJS({
|
|
1320
1351
|
"node_modules/semver/functions/satisfies.js"(exports, module) {
|
|
1352
|
+
"use strict";
|
|
1321
1353
|
var Range = require_range();
|
|
1322
1354
|
var satisfies = (version, range, options) => {
|
|
1323
1355
|
try {
|
|
@@ -1334,6 +1366,7 @@ var require_satisfies = __commonJS({
|
|
|
1334
1366
|
// node_modules/semver/ranges/to-comparators.js
|
|
1335
1367
|
var require_to_comparators = __commonJS({
|
|
1336
1368
|
"node_modules/semver/ranges/to-comparators.js"(exports, module) {
|
|
1369
|
+
"use strict";
|
|
1337
1370
|
var Range = require_range();
|
|
1338
1371
|
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1339
1372
|
module.exports = toComparators;
|
|
@@ -1343,6 +1376,7 @@ var require_to_comparators = __commonJS({
|
|
|
1343
1376
|
// node_modules/semver/ranges/max-satisfying.js
|
|
1344
1377
|
var require_max_satisfying = __commonJS({
|
|
1345
1378
|
"node_modules/semver/ranges/max-satisfying.js"(exports, module) {
|
|
1379
|
+
"use strict";
|
|
1346
1380
|
var SemVer = require_semver();
|
|
1347
1381
|
var Range = require_range();
|
|
1348
1382
|
var maxSatisfying = (versions, range, options) => {
|
|
@@ -1371,6 +1405,7 @@ var require_max_satisfying = __commonJS({
|
|
|
1371
1405
|
// node_modules/semver/ranges/min-satisfying.js
|
|
1372
1406
|
var require_min_satisfying = __commonJS({
|
|
1373
1407
|
"node_modules/semver/ranges/min-satisfying.js"(exports, module) {
|
|
1408
|
+
"use strict";
|
|
1374
1409
|
var SemVer = require_semver();
|
|
1375
1410
|
var Range = require_range();
|
|
1376
1411
|
var minSatisfying = (versions, range, options) => {
|
|
@@ -1399,6 +1434,7 @@ var require_min_satisfying = __commonJS({
|
|
|
1399
1434
|
// node_modules/semver/ranges/min-version.js
|
|
1400
1435
|
var require_min_version = __commonJS({
|
|
1401
1436
|
"node_modules/semver/ranges/min-version.js"(exports, module) {
|
|
1437
|
+
"use strict";
|
|
1402
1438
|
var SemVer = require_semver();
|
|
1403
1439
|
var Range = require_range();
|
|
1404
1440
|
var gt = require_gt();
|
|
@@ -1457,6 +1493,7 @@ var require_min_version = __commonJS({
|
|
|
1457
1493
|
// node_modules/semver/ranges/valid.js
|
|
1458
1494
|
var require_valid2 = __commonJS({
|
|
1459
1495
|
"node_modules/semver/ranges/valid.js"(exports, module) {
|
|
1496
|
+
"use strict";
|
|
1460
1497
|
var Range = require_range();
|
|
1461
1498
|
var validRange = (range, options) => {
|
|
1462
1499
|
try {
|
|
@@ -1472,6 +1509,7 @@ var require_valid2 = __commonJS({
|
|
|
1472
1509
|
// node_modules/semver/ranges/outside.js
|
|
1473
1510
|
var require_outside = __commonJS({
|
|
1474
1511
|
"node_modules/semver/ranges/outside.js"(exports, module) {
|
|
1512
|
+
"use strict";
|
|
1475
1513
|
var SemVer = require_semver();
|
|
1476
1514
|
var Comparator = require_comparator();
|
|
1477
1515
|
var { ANY } = Comparator;
|
|
@@ -1540,6 +1578,7 @@ var require_outside = __commonJS({
|
|
|
1540
1578
|
// node_modules/semver/ranges/gtr.js
|
|
1541
1579
|
var require_gtr = __commonJS({
|
|
1542
1580
|
"node_modules/semver/ranges/gtr.js"(exports, module) {
|
|
1581
|
+
"use strict";
|
|
1543
1582
|
var outside = require_outside();
|
|
1544
1583
|
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1545
1584
|
module.exports = gtr;
|
|
@@ -1549,6 +1588,7 @@ var require_gtr = __commonJS({
|
|
|
1549
1588
|
// node_modules/semver/ranges/ltr.js
|
|
1550
1589
|
var require_ltr = __commonJS({
|
|
1551
1590
|
"node_modules/semver/ranges/ltr.js"(exports, module) {
|
|
1591
|
+
"use strict";
|
|
1552
1592
|
var outside = require_outside();
|
|
1553
1593
|
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1554
1594
|
module.exports = ltr;
|
|
@@ -1558,6 +1598,7 @@ var require_ltr = __commonJS({
|
|
|
1558
1598
|
// node_modules/semver/ranges/intersects.js
|
|
1559
1599
|
var require_intersects = __commonJS({
|
|
1560
1600
|
"node_modules/semver/ranges/intersects.js"(exports, module) {
|
|
1601
|
+
"use strict";
|
|
1561
1602
|
var Range = require_range();
|
|
1562
1603
|
var intersects = (r1, r2, options) => {
|
|
1563
1604
|
r1 = new Range(r1, options);
|
|
@@ -1571,6 +1612,7 @@ var require_intersects = __commonJS({
|
|
|
1571
1612
|
// node_modules/semver/ranges/simplify.js
|
|
1572
1613
|
var require_simplify = __commonJS({
|
|
1573
1614
|
"node_modules/semver/ranges/simplify.js"(exports, module) {
|
|
1615
|
+
"use strict";
|
|
1574
1616
|
var satisfies = require_satisfies();
|
|
1575
1617
|
var compare = require_compare();
|
|
1576
1618
|
module.exports = (versions, range, options) => {
|
|
@@ -1620,6 +1662,7 @@ var require_simplify = __commonJS({
|
|
|
1620
1662
|
// node_modules/semver/ranges/subset.js
|
|
1621
1663
|
var require_subset = __commonJS({
|
|
1622
1664
|
"node_modules/semver/ranges/subset.js"(exports, module) {
|
|
1665
|
+
"use strict";
|
|
1623
1666
|
var Range = require_range();
|
|
1624
1667
|
var Comparator = require_comparator();
|
|
1625
1668
|
var { ANY } = Comparator;
|
|
@@ -1781,6 +1824,7 @@ var require_subset = __commonJS({
|
|
|
1781
1824
|
// node_modules/semver/index.js
|
|
1782
1825
|
var require_semver2 = __commonJS({
|
|
1783
1826
|
"node_modules/semver/index.js"(exports, module) {
|
|
1827
|
+
"use strict";
|
|
1784
1828
|
var internalRe = require_re();
|
|
1785
1829
|
var constants = require_constants();
|
|
1786
1830
|
var SemVer = require_semver();
|
|
@@ -86,7 +86,7 @@ var pipeline = (0, import_node_util.promisify)(import_node_stream.pipeline);
|
|
|
86
86
|
|
|
87
87
|
// package.json
|
|
88
88
|
var name = "@netlify/plugin-nextjs";
|
|
89
|
-
var version = "5.11.
|
|
89
|
+
var version = "5.11.2";
|
|
90
90
|
|
|
91
91
|
// src/run/handlers/tags-handler.cts
|
|
92
92
|
var import_storage = require("../storage/storage.cjs");
|
package/dist/run/next.cjs
CHANGED
|
@@ -488,8 +488,9 @@ __export(next_exports, {
|
|
|
488
488
|
getMockedRequestHandler: () => getMockedRequestHandler
|
|
489
489
|
});
|
|
490
490
|
module.exports = __toCommonJS(next_exports);
|
|
491
|
-
var
|
|
492
|
-
var
|
|
491
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
492
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
|
493
|
+
var import_node_path = require("node:path");
|
|
493
494
|
var import_fs_monkey = __toESM(require_lib());
|
|
494
495
|
var import_request_context = require("./handlers/request-context.cjs");
|
|
495
496
|
var import_tracer = require("./handlers/tracer.cjs");
|
|
@@ -540,6 +541,8 @@ ResponseCache.prototype.get = function get(...getArgs) {
|
|
|
540
541
|
return originalGet.apply(this, getArgs);
|
|
541
542
|
};
|
|
542
543
|
async function getMockedRequestHandler(...args) {
|
|
544
|
+
const initContext = { initializingServer: true };
|
|
545
|
+
const initAsyncLocalStorage = new import_node_async_hooks.AsyncLocalStorage();
|
|
543
546
|
const tracer = (0, import_tracer.getTracer)();
|
|
544
547
|
return tracer.withActiveSpan("mocked request handler", async () => {
|
|
545
548
|
const ofs = { ...import_promises.default };
|
|
@@ -550,12 +553,13 @@ async function getMockedRequestHandler(...args) {
|
|
|
550
553
|
} catch (error) {
|
|
551
554
|
if (typeof path === "string" && path.endsWith(".html")) {
|
|
552
555
|
const cacheStore = (0, import_storage.getMemoizedKeyValueStoreBackedByRegionalBlobStore)();
|
|
553
|
-
const relPath = (0,
|
|
556
|
+
const relPath = (0, import_node_path.relative)((0, import_node_path.resolve)(".next/server/pages"), path);
|
|
554
557
|
const file = await cacheStore.get(relPath, "staticHtml.get");
|
|
555
558
|
if (file !== null) {
|
|
556
|
-
if (
|
|
559
|
+
if (file.isFullyStaticPage) {
|
|
557
560
|
const requestContext = (0, import_request_context.getRequestContext)();
|
|
558
|
-
|
|
561
|
+
const { initializingServer } = initAsyncLocalStorage.getStore() ?? {};
|
|
562
|
+
if (!initializingServer && requestContext) {
|
|
559
563
|
requestContext.usedFsReadForNonFallback = true;
|
|
560
564
|
}
|
|
561
565
|
}
|
|
@@ -572,7 +576,9 @@ async function getMockedRequestHandler(...args) {
|
|
|
572
576
|
// eslint-disable-next-line n/global-require, @typescript-eslint/no-var-requires
|
|
573
577
|
require("fs").promises
|
|
574
578
|
);
|
|
575
|
-
const requestHandlers = await
|
|
579
|
+
const requestHandlers = await initAsyncLocalStorage.run(initContext, async () => {
|
|
580
|
+
return await getRequestHandlers(...args);
|
|
581
|
+
});
|
|
576
582
|
return Array.isArray(requestHandlers) ? requestHandlers[0] : requestHandlers.requestHandler;
|
|
577
583
|
});
|
|
578
584
|
}
|
|
@@ -28,7 +28,7 @@ var isTagManifest = (value) => {
|
|
|
28
28
|
return typeof value === "object" && value !== null && "revalidatedAt" in value && typeof value.revalidatedAt === "number" && Object.keys(value).length === 1;
|
|
29
29
|
};
|
|
30
30
|
var isHtmlBlob = (value) => {
|
|
31
|
-
return typeof value === "object" && value !== null && "html" in value && "
|
|
31
|
+
return typeof value === "object" && value !== null && "html" in value && "isFullyStaticPage" in value && typeof value.html === "string" && typeof value.isFullyStaticPage === "boolean" && Object.keys(value).length === 2;
|
|
32
32
|
};
|
|
33
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
34
|
0 && (module.exports = {
|
|
@@ -67,6 +67,10 @@ export function mergeMiddlewareCookies(middlewareResponse: Response, lambdaReque
|
|
|
67
67
|
const middlewareCookies = middlewareResponse.headers.get('x-middleware-set-cookie')
|
|
68
68
|
|
|
69
69
|
if (middlewareCookies) {
|
|
70
|
+
// Next expects internal headers to be omitted when cookies are set by the middleware
|
|
71
|
+
// See: https://github.com/vercel/next.js/blob/005db43079c7b59fd8c2594e8362761dc4cb3211/test/e2e/app-dir/app-middleware/app-middleware.test.ts#L197-L207
|
|
72
|
+
middlewareResponse.headers.delete('x-middleware-set-cookie')
|
|
73
|
+
|
|
70
74
|
// Targets commas that are not followed by whitespace
|
|
71
75
|
// See: https://github.com/vercel/next.js/blob/e6145d3a37bb4c7b481fd58e05cdff9046ace8ad/packages/next/src/server/web/spec-extension/response.ts#L58-L66
|
|
72
76
|
const regex = new RegExp(/,(?!\s)/)
|
|
@@ -163,25 +163,13 @@ export const buildResponse = async ({
|
|
|
163
163
|
|
|
164
164
|
if (rewriteUrl.origin !== baseUrl.origin) {
|
|
165
165
|
logger.withFields({ rewrite_url: rewrite }).debug('Rewriting to external url')
|
|
166
|
-
|
|
166
|
+
const proxyRequest = await cloneRequest(rewriteUrl, request)
|
|
167
167
|
|
|
168
168
|
// Remove Netlify internal headers
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// This is not ideal, but streaming to an external URL doesn't work
|
|
174
|
-
const body = await request.arrayBuffer()
|
|
175
|
-
proxyRequest = new Request(rewriteUrl, {
|
|
176
|
-
headers,
|
|
177
|
-
method: request.method,
|
|
178
|
-
body,
|
|
179
|
-
})
|
|
180
|
-
} else {
|
|
181
|
-
proxyRequest = new Request(rewriteUrl, {
|
|
182
|
-
headers,
|
|
183
|
-
method: request.method,
|
|
184
|
-
})
|
|
169
|
+
for (const key of request.headers.keys()) {
|
|
170
|
+
if (key.startsWith('x-nf-')) {
|
|
171
|
+
proxyRequest.headers.delete(key)
|
|
172
|
+
}
|
|
185
173
|
}
|
|
186
174
|
|
|
187
175
|
return addMiddlewareHeaders(fetch(proxyRequest, { redirect: 'manual' }), edgeResponse)
|
|
@@ -207,7 +195,7 @@ export const buildResponse = async ({
|
|
|
207
195
|
request.headers.set('x-middleware-rewrite', target)
|
|
208
196
|
|
|
209
197
|
// coookies set in middleware need to be available during the lambda request
|
|
210
|
-
const newRequest =
|
|
198
|
+
const newRequest = await cloneRequest(target, request)
|
|
211
199
|
const newRequestCookies = mergeMiddlewareCookies(edgeResponse, newRequest)
|
|
212
200
|
if (newRequestCookies) {
|
|
213
201
|
newRequest.headers.set('Cookie', newRequestCookies)
|
|
@@ -241,7 +229,7 @@ export const buildResponse = async ({
|
|
|
241
229
|
edgeResponse.headers.delete('x-middleware-next')
|
|
242
230
|
|
|
243
231
|
// coookies set in middleware need to be available during the lambda request
|
|
244
|
-
const newRequest =
|
|
232
|
+
const newRequest = await cloneRequest(request.url, request)
|
|
245
233
|
const newRequestCookies = mergeMiddlewareCookies(edgeResponse, newRequest)
|
|
246
234
|
if (newRequestCookies) {
|
|
247
235
|
newRequest.headers.set('Cookie', newRequestCookies)
|
|
@@ -284,3 +272,13 @@ function normalizeLocalizedTarget({
|
|
|
284
272
|
}
|
|
285
273
|
return targetUrl.toString()
|
|
286
274
|
}
|
|
275
|
+
|
|
276
|
+
async function cloneRequest(url, request: Request) {
|
|
277
|
+
// This is not ideal, but streaming to an external URL doesn't work
|
|
278
|
+
const body = request.body && !request.bodyUsed ? await request.arrayBuffer() : undefined
|
|
279
|
+
return new Request(url, {
|
|
280
|
+
headers: request.headers,
|
|
281
|
+
method: request.method,
|
|
282
|
+
body,
|
|
283
|
+
})
|
|
284
|
+
}
|