@netlify/plugin-nextjs 5.0.0-rc.5 → 5.0.0-rc.7
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/README.md +2 -0
- package/dist/build/content/next-shims/telemetry-storage.cjs +55 -0
- package/dist/build/content/prerendered.js +3 -1
- package/dist/build/content/server.js +5 -1
- package/dist/build/content/static.js +3 -1
- package/dist/build/functions/server.js +4 -2
- package/dist/build/templates/handler-monorepo.tmpl.js +20 -14
- package/dist/build/templates/handler.tmpl.js +19 -14
- package/dist/esm-chunks/chunk-4635LKT6.js +244 -0
- package/dist/esm-chunks/{chunk-W7XTKMHH.js → chunk-757FQQND.js} +56 -44
- package/dist/esm-chunks/chunk-GV3YIJ33.js +110 -0
- package/dist/esm-chunks/{chunk-637Y3P2U.js → chunk-M2ZKGJAI.js} +1 -2
- package/dist/esm-chunks/chunk-PDPDW32D.js +89 -0
- package/dist/esm-chunks/{chunk-GQ6KIYPX.js → chunk-Y3K5Q6FP.js} +13 -12
- package/dist/esm-chunks/chunk-YSGPGDIG.js +278 -0
- package/dist/esm-chunks/{package-67C5TREY.js → package-NR7AMHPP.js} +3 -3
- package/dist/index.js +52 -32
- package/dist/run/handlers/cache.cjs +48 -842
- package/dist/run/handlers/request-context.cjs +4 -2
- package/dist/run/handlers/server.js +31 -35
- package/dist/run/handlers/tracer.cjs +927 -0
- package/dist/run/handlers/tracing.js +75 -78
- package/dist/run/headers.js +1 -1
- package/dist/run/next.cjs +6 -767
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-CSTSA3JJ.js +0 -217
- package/dist/esm-chunks/chunk-VSH4JS2L.js +0 -125
- package/dist/esm-chunks/chunk-WFVNEURA.js +0 -94
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
var require = await (async () => {
|
|
3
|
+
var { createRequire } = await import("node:module");
|
|
4
|
+
return createRequire(import.meta.url);
|
|
5
|
+
})();
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
wrapTracer
|
|
9
|
+
} from "./chunk-PDPDW32D.js";
|
|
10
|
+
import {
|
|
11
|
+
init_esm,
|
|
12
|
+
trace
|
|
13
|
+
} from "./chunk-Y3K5Q6FP.js";
|
|
14
|
+
import {
|
|
15
|
+
require_out
|
|
16
|
+
} from "./chunk-VZNKO4OO.js";
|
|
17
|
+
import {
|
|
18
|
+
encodeBlobKey
|
|
19
|
+
} from "./chunk-TYCYFZ22.js";
|
|
20
|
+
import {
|
|
21
|
+
__toESM
|
|
22
|
+
} from "./chunk-5JVNISGM.js";
|
|
23
|
+
|
|
24
|
+
// src/build/content/static.ts
|
|
25
|
+
init_esm();
|
|
26
|
+
import { existsSync } from "node:fs";
|
|
27
|
+
import { cp, mkdir, rename, rm } from "node:fs/promises";
|
|
28
|
+
import { basename, join } from "node:path";
|
|
29
|
+
var import_fast_glob = __toESM(require_out(), 1);
|
|
30
|
+
var tracer = wrapTracer(trace.getTracer("Next runtime"));
|
|
31
|
+
var copyStaticContent = async (ctx) => {
|
|
32
|
+
return tracer.withActiveSpan("copyStaticContent", async () => {
|
|
33
|
+
const srcDir = join(ctx.publishDir, "server/pages");
|
|
34
|
+
const destDir = ctx.blobDir;
|
|
35
|
+
const paths = await (0, import_fast_glob.default)("**/*.+(html|json)", {
|
|
36
|
+
cwd: srcDir,
|
|
37
|
+
extglob: true
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
await Promise.all(
|
|
41
|
+
paths.filter((path) => !paths.includes(`${path.slice(0, -5)}.json`)).map(async (path) => {
|
|
42
|
+
await cp(join(srcDir, path), join(destDir, await encodeBlobKey(path)), {
|
|
43
|
+
recursive: true,
|
|
44
|
+
force: true
|
|
45
|
+
});
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
ctx.failBuild("Failed assembling static pages for upload", error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var copyStaticAssets = async (ctx) => {
|
|
54
|
+
return tracer.withActiveSpan("copyStaticAssets", async (span) => {
|
|
55
|
+
try {
|
|
56
|
+
await rm(ctx.staticDir, { recursive: true, force: true });
|
|
57
|
+
const { basePath } = await ctx.getRoutesManifest();
|
|
58
|
+
if (existsSync(ctx.resolveFromSiteDir("public"))) {
|
|
59
|
+
await cp(ctx.resolveFromSiteDir("public"), join(ctx.staticDir, basePath), {
|
|
60
|
+
recursive: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (existsSync(join(ctx.publishDir, "static"))) {
|
|
64
|
+
await cp(join(ctx.publishDir, "static"), join(ctx.staticDir, basePath, "_next/static"), {
|
|
65
|
+
recursive: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
span.end();
|
|
70
|
+
ctx.failBuild("Failed copying static assets", error);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
var copyStaticExport = async (ctx) => {
|
|
75
|
+
await tracer.withActiveSpan("copyStaticExport", async () => {
|
|
76
|
+
try {
|
|
77
|
+
await rm(ctx.staticDir, { recursive: true, force: true });
|
|
78
|
+
await cp(ctx.resolveFromSiteDir("out"), ctx.staticDir, { recursive: true });
|
|
79
|
+
} catch (error) {
|
|
80
|
+
ctx.failBuild("Failed copying static export", error);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
var publishStaticDir = async (ctx) => {
|
|
85
|
+
try {
|
|
86
|
+
await rm(ctx.tempPublishDir, { recursive: true, force: true });
|
|
87
|
+
await mkdir(basename(ctx.tempPublishDir), { recursive: true });
|
|
88
|
+
await rename(ctx.publishDir, ctx.tempPublishDir);
|
|
89
|
+
await rename(ctx.staticDir, ctx.publishDir);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
ctx.failBuild("Failed publishing static content", error instanceof Error ? { error } : {});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var unpublishStaticDir = async (ctx) => {
|
|
95
|
+
try {
|
|
96
|
+
if (existsSync(ctx.tempPublishDir)) {
|
|
97
|
+
await rename(ctx.publishDir, ctx.staticDir);
|
|
98
|
+
await rename(ctx.tempPublishDir, ctx.publishDir);
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
copyStaticContent,
|
|
106
|
+
copyStaticAssets,
|
|
107
|
+
copyStaticExport,
|
|
108
|
+
publishStaticDir,
|
|
109
|
+
unpublishStaticDir
|
|
110
|
+
};
|
|
@@ -617,7 +617,7 @@ var adjustDateHeader = async ({
|
|
|
617
617
|
});
|
|
618
618
|
const blobKey = await encodeBlobKey(key);
|
|
619
619
|
const blobStore = getDeployStore({ fetch: fetchBeforeNextPatchedIt, consistency: "strong" });
|
|
620
|
-
lastModified = await tracer.
|
|
620
|
+
lastModified = await tracer.withActiveSpan(
|
|
621
621
|
"get cache to calculate date header",
|
|
622
622
|
async (getBlobForDateSpan) => {
|
|
623
623
|
getBlobForDateSpan.setAttributes({
|
|
@@ -626,7 +626,6 @@ var adjustDateHeader = async ({
|
|
|
626
626
|
});
|
|
627
627
|
const blob = await blobStore.get(blobKey, { type: "json" }) ?? {};
|
|
628
628
|
getBlobForDateSpan.addEvent(blob ? "Cache hit" : "Cache miss");
|
|
629
|
-
getBlobForDateSpan.end();
|
|
630
629
|
return blob.lastModified;
|
|
631
630
|
}
|
|
632
631
|
);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
|
|
2
|
+
var require = await (async () => {
|
|
3
|
+
var { createRequire } = await import("node:module");
|
|
4
|
+
return createRequire(import.meta.url);
|
|
5
|
+
})();
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
SpanStatusCode,
|
|
9
|
+
context,
|
|
10
|
+
init_esm
|
|
11
|
+
} from "./chunk-Y3K5Q6FP.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js
|
|
14
|
+
init_esm();
|
|
15
|
+
var defaultOnException = function(e, span) {
|
|
16
|
+
span.recordException(e);
|
|
17
|
+
span.setStatus({
|
|
18
|
+
code: SpanStatusCode.ERROR
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
function wrapTracer(tracer) {
|
|
22
|
+
return new SugaredTracer(tracer);
|
|
23
|
+
}
|
|
24
|
+
var SugaredTracer = (
|
|
25
|
+
/** @class */
|
|
26
|
+
function() {
|
|
27
|
+
function SugaredTracer2(tracer) {
|
|
28
|
+
this._tracer = tracer;
|
|
29
|
+
this.startSpan = tracer.startSpan.bind(this._tracer);
|
|
30
|
+
this.startActiveSpan = tracer.startActiveSpan.bind(this._tracer);
|
|
31
|
+
}
|
|
32
|
+
SugaredTracer2.prototype.withActiveSpan = function(name, arg2, arg3, arg4) {
|
|
33
|
+
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
34
|
+
return this._tracer.startActiveSpan(name, opts, ctx, function(span) {
|
|
35
|
+
return handleFn(span, opts, fn);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
SugaredTracer2.prototype.withSpan = function(name, arg2, arg3, arg4) {
|
|
39
|
+
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
40
|
+
var span = this._tracer.startSpan(name, opts, ctx);
|
|
41
|
+
return handleFn(span, opts, fn);
|
|
42
|
+
};
|
|
43
|
+
return SugaredTracer2;
|
|
44
|
+
}()
|
|
45
|
+
);
|
|
46
|
+
function massageParams(arg, arg2, arg3) {
|
|
47
|
+
var opts;
|
|
48
|
+
var ctx;
|
|
49
|
+
var fn;
|
|
50
|
+
if (!arg2 && !arg3) {
|
|
51
|
+
fn = arg;
|
|
52
|
+
} else if (!arg3) {
|
|
53
|
+
opts = arg;
|
|
54
|
+
fn = arg2;
|
|
55
|
+
} else {
|
|
56
|
+
opts = arg;
|
|
57
|
+
ctx = arg2;
|
|
58
|
+
fn = arg3;
|
|
59
|
+
}
|
|
60
|
+
opts = opts !== null && opts !== void 0 ? opts : {};
|
|
61
|
+
ctx = ctx !== null && ctx !== void 0 ? ctx : context.active();
|
|
62
|
+
return { opts, ctx, fn };
|
|
63
|
+
}
|
|
64
|
+
function handleFn(span, opts, fn) {
|
|
65
|
+
var _a;
|
|
66
|
+
var onException = (_a = opts.onException) !== null && _a !== void 0 ? _a : defaultOnException;
|
|
67
|
+
var errorHandler = function(e) {
|
|
68
|
+
onException(e, span);
|
|
69
|
+
span.end();
|
|
70
|
+
throw e;
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
var ret = fn(span);
|
|
74
|
+
if (typeof (ret === null || ret === void 0 ? void 0 : ret.then) === "function") {
|
|
75
|
+
return ret.then(function(val) {
|
|
76
|
+
span.end();
|
|
77
|
+
return val;
|
|
78
|
+
}, errorHandler);
|
|
79
|
+
}
|
|
80
|
+
span.end();
|
|
81
|
+
return ret;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
throw errorHandler(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
wrapTracer
|
|
89
|
+
};
|
|
@@ -9,18 +9,6 @@ import {
|
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-5JVNISGM.js";
|
|
11
11
|
|
|
12
|
-
// node_modules/@opentelemetry/api/build/esm/trace/status.js
|
|
13
|
-
var SpanStatusCode;
|
|
14
|
-
var init_status = __esm({
|
|
15
|
-
"node_modules/@opentelemetry/api/build/esm/trace/status.js"() {
|
|
16
|
-
(function(SpanStatusCode2) {
|
|
17
|
-
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
18
|
-
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
19
|
-
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
20
|
-
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
12
|
// node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
|
|
25
13
|
var _globalThis;
|
|
26
14
|
var init_globalThis = __esm({
|
|
@@ -1295,6 +1283,18 @@ var init_span_kind = __esm({
|
|
|
1295
1283
|
}
|
|
1296
1284
|
});
|
|
1297
1285
|
|
|
1286
|
+
// node_modules/@opentelemetry/api/build/esm/trace/status.js
|
|
1287
|
+
var SpanStatusCode;
|
|
1288
|
+
var init_status = __esm({
|
|
1289
|
+
"node_modules/@opentelemetry/api/build/esm/trace/status.js"() {
|
|
1290
|
+
(function(SpanStatusCode2) {
|
|
1291
|
+
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
1292
|
+
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
1293
|
+
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
1294
|
+
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
1298
|
// node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-validators.js
|
|
1299
1299
|
function validateKey(key) {
|
|
1300
1300
|
return VALID_KEY_REGEX.test(key);
|
|
@@ -1652,6 +1652,7 @@ var init_esm = __esm({
|
|
|
1652
1652
|
|
|
1653
1653
|
export {
|
|
1654
1654
|
SpanStatusCode,
|
|
1655
|
+
context,
|
|
1655
1656
|
trace,
|
|
1656
1657
|
esm_exports,
|
|
1657
1658
|
init_esm
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
|
|
2
|
+
var require = await (async () => {
|
|
3
|
+
var { createRequire } = await import("node:module");
|
|
4
|
+
return createRequire(import.meta.url);
|
|
5
|
+
})();
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
wrapTracer
|
|
9
|
+
} from "./chunk-PDPDW32D.js";
|
|
10
|
+
import {
|
|
11
|
+
init_esm,
|
|
12
|
+
trace
|
|
13
|
+
} from "./chunk-Y3K5Q6FP.js";
|
|
14
|
+
import {
|
|
15
|
+
require_out
|
|
16
|
+
} from "./chunk-VZNKO4OO.js";
|
|
17
|
+
import {
|
|
18
|
+
verifyNextVersion
|
|
19
|
+
} from "./chunk-MGPEWDDD.js";
|
|
20
|
+
import {
|
|
21
|
+
require_semver
|
|
22
|
+
} from "./chunk-PJG75HGC.js";
|
|
23
|
+
import {
|
|
24
|
+
RUN_CONFIG
|
|
25
|
+
} from "./chunk-UYKENJEU.js";
|
|
26
|
+
import {
|
|
27
|
+
__toESM
|
|
28
|
+
} from "./chunk-5JVNISGM.js";
|
|
29
|
+
|
|
30
|
+
// src/build/content/server.ts
|
|
31
|
+
init_esm();
|
|
32
|
+
import { existsSync } from "node:fs";
|
|
33
|
+
import {
|
|
34
|
+
cp,
|
|
35
|
+
mkdir,
|
|
36
|
+
readFile,
|
|
37
|
+
readdir,
|
|
38
|
+
readlink,
|
|
39
|
+
symlink,
|
|
40
|
+
writeFile,
|
|
41
|
+
access
|
|
42
|
+
} from "node:fs/promises";
|
|
43
|
+
import { createRequire } from "node:module";
|
|
44
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
45
|
+
import { sep as posixSep, join as posixJoin } from "node:path/posix";
|
|
46
|
+
var import_fast_glob = __toESM(require_out(), 1);
|
|
47
|
+
var import_semver = __toESM(require_semver(), 1);
|
|
48
|
+
var tracer = wrapTracer(trace.getTracer("Next runtime"));
|
|
49
|
+
var toPosixPath = (path) => path.split(sep).join(posixSep);
|
|
50
|
+
function isError(error) {
|
|
51
|
+
return error instanceof Error;
|
|
52
|
+
}
|
|
53
|
+
var copyNextServerCode = async (ctx) => {
|
|
54
|
+
await tracer.withActiveSpan("copyNextServerCode", async () => {
|
|
55
|
+
const reqServerFilesPath = join(
|
|
56
|
+
ctx.standaloneRootDir,
|
|
57
|
+
ctx.relativeAppDir,
|
|
58
|
+
ctx.requiredServerFiles.config.distDir,
|
|
59
|
+
"required-server-files.json"
|
|
60
|
+
);
|
|
61
|
+
try {
|
|
62
|
+
await access(reqServerFilesPath);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (isError(error) && error.code === "ENOENT") {
|
|
65
|
+
ctx.failBuild(
|
|
66
|
+
`Failed creating server handler. required-server-files.json file not found at expected location "${reqServerFilesPath}". Your repository setup is currently not yet supported.`
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const reqServerFiles = JSON.parse(await readFile(reqServerFilesPath, "utf-8"));
|
|
73
|
+
if (toPosixPath(ctx.distDir).replace(new RegExp(`^${ctx.relativeAppDir}/?`), "") !== reqServerFiles.config.distDir) {
|
|
74
|
+
reqServerFiles.config.distDir = ctx.nextDistDir;
|
|
75
|
+
await writeFile(reqServerFilesPath, JSON.stringify(reqServerFiles));
|
|
76
|
+
}
|
|
77
|
+
await mkdir(ctx.serverHandlerDir, { recursive: true });
|
|
78
|
+
await writeFile(
|
|
79
|
+
join(ctx.serverHandlerDir, RUN_CONFIG),
|
|
80
|
+
JSON.stringify(reqServerFiles.config),
|
|
81
|
+
"utf-8"
|
|
82
|
+
);
|
|
83
|
+
const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
|
|
84
|
+
const nextFolder = toPosixPath(ctx.distDir) === toPosixPath(ctx.buildConfig.distDir) ? ctx.distDir : ctx.nextDistDir;
|
|
85
|
+
const destDir = join(ctx.serverHandlerDir, nextFolder);
|
|
86
|
+
const paths = await (0, import_fast_glob.default)(
|
|
87
|
+
[`*`, `server/*`, `server/chunks/*`, `server/edge-chunks/*`, `server/+(app|pages)/**/*.js`],
|
|
88
|
+
{
|
|
89
|
+
cwd: srcDir,
|
|
90
|
+
extglob: true
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
await Promise.all(
|
|
94
|
+
paths.map(async (path) => {
|
|
95
|
+
const srcPath = join(srcDir, path);
|
|
96
|
+
const destPath = join(destDir, path);
|
|
97
|
+
if (path === "server/middleware-manifest.json") {
|
|
98
|
+
try {
|
|
99
|
+
await replaceMiddlewareManifest(srcPath, destPath);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
throw new Error("Could not patch middleware manifest file", { cause: error });
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
await cp(srcPath, destPath, { recursive: true, force: true });
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
async function recreateNodeModuleSymlinks(src, dest, org) {
|
|
111
|
+
const dirents = await readdir(join(src, org || ""), { withFileTypes: true });
|
|
112
|
+
await Promise.all(
|
|
113
|
+
dirents.map(async (dirent) => {
|
|
114
|
+
if (dirent.name.startsWith("@")) {
|
|
115
|
+
return recreateNodeModuleSymlinks(src, dest, dirent.name);
|
|
116
|
+
}
|
|
117
|
+
if (dirent.isSymbolicLink()) {
|
|
118
|
+
const symlinkSrc = join(dest, org || "", dirent.name);
|
|
119
|
+
const symlinkTarget = await readlink(join(src, org || "", dirent.name));
|
|
120
|
+
const symlinkDest = join(dest, org || "", symlinkTarget);
|
|
121
|
+
if (existsSync(symlinkDest) && !existsSync(symlinkSrc)) {
|
|
122
|
+
if (org) {
|
|
123
|
+
await mkdir(join(dest, org), { recursive: true });
|
|
124
|
+
}
|
|
125
|
+
await symlink(symlinkTarget, symlinkSrc);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
var nextInternalModuleReplacements = [
|
|
132
|
+
{
|
|
133
|
+
// standalone is loading expensive Telemetry module that is not actually used
|
|
134
|
+
// so this replace that module with lightweight no-op shim that doesn't load additional modules
|
|
135
|
+
// see https://github.com/vercel/next.js/pull/63574 that removed need for this shim
|
|
136
|
+
ongoing: false,
|
|
137
|
+
minVersion: "13.5.0-canary.0",
|
|
138
|
+
// perf released in https://github.com/vercel/next.js/releases/tag/v14.2.0-canary.43
|
|
139
|
+
maxVersion: "14.2.0-canary.42",
|
|
140
|
+
nextModule: "next/dist/telemetry/storage.js",
|
|
141
|
+
shimModule: "./next-shims/telemetry-storage.cjs"
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
function getPatchesToApply(nextVersion, patches = nextInternalModuleReplacements) {
|
|
145
|
+
return patches.filter((patch) => {
|
|
146
|
+
if ((0, import_semver.lt)(nextVersion, patch.minVersion)) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (patch.ongoing) {
|
|
150
|
+
if ((0, import_semver.prerelease)(nextVersion) || process.env.NETLIFY_NEXT_FORCE_APPLY_ONGOING_PATCHES) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
return (0, import_semver.lte)(nextVersion, patch.maxStableVersion);
|
|
154
|
+
}
|
|
155
|
+
return (0, import_semver.lte)(nextVersion, patch.maxVersion);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
async function patchNextModules(ctx, nextVersion, serverHandlerRequireResolve) {
|
|
159
|
+
const moduleReplacementsToApply = getPatchesToApply(nextVersion);
|
|
160
|
+
if (moduleReplacementsToApply.length !== 0) {
|
|
161
|
+
await Promise.all(
|
|
162
|
+
moduleReplacementsToApply.map(async ({ nextModule, shimModule }) => {
|
|
163
|
+
try {
|
|
164
|
+
const nextModulePath = serverHandlerRequireResolve(nextModule);
|
|
165
|
+
const shimModulePath = posixJoin(ctx.pluginDir, "dist", "build", "content", shimModule);
|
|
166
|
+
await cp(shimModulePath, nextModulePath, { force: true });
|
|
167
|
+
} catch {
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
var copyNextDependencies = async (ctx) => {
|
|
174
|
+
await tracer.withActiveSpan("copyNextDependencies", async () => {
|
|
175
|
+
const entries = await readdir(ctx.standaloneDir);
|
|
176
|
+
const promises = entries.map(async (entry) => {
|
|
177
|
+
if (entry === "package.json" || entry === ctx.nextDistDir) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const src = join(ctx.standaloneDir, entry);
|
|
181
|
+
const dest = join(ctx.serverHandlerDir, entry);
|
|
182
|
+
await cp(src, dest, { recursive: true, verbatimSymlinks: true, force: true });
|
|
183
|
+
if (entry === "node_modules") {
|
|
184
|
+
await recreateNodeModuleSymlinks(ctx.resolveFromSiteDir("node_modules"), dest);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const rootSrcDir = join(ctx.standaloneRootDir, "node_modules");
|
|
188
|
+
const rootDestDir = join(ctx.serverHandlerRootDir, "node_modules");
|
|
189
|
+
if (existsSync(rootSrcDir) && ctx.standaloneRootDir !== ctx.standaloneDir) {
|
|
190
|
+
promises.push(
|
|
191
|
+
cp(rootSrcDir, rootDestDir, { recursive: true, verbatimSymlinks: true }).then(
|
|
192
|
+
() => recreateNodeModuleSymlinks(resolve("node_modules"), rootDestDir)
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
await Promise.all(promises);
|
|
197
|
+
const serverHandlerRequire = createRequire(posixJoin(ctx.serverHandlerDir, ":internal:"));
|
|
198
|
+
let nextVersion;
|
|
199
|
+
try {
|
|
200
|
+
const { version } = serverHandlerRequire("next/package.json");
|
|
201
|
+
if (version) {
|
|
202
|
+
nextVersion = version;
|
|
203
|
+
}
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
if (nextVersion) {
|
|
207
|
+
verifyNextVersion(ctx, nextVersion);
|
|
208
|
+
await patchNextModules(ctx, nextVersion, serverHandlerRequire.resolve);
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
const nextEntryAbsolutePath = serverHandlerRequire.resolve("next");
|
|
212
|
+
const nextRequire = createRequire(nextEntryAbsolutePath);
|
|
213
|
+
nextRequire.resolve("styled-jsx");
|
|
214
|
+
} catch {
|
|
215
|
+
throw new Error(
|
|
216
|
+
"node_modules are not installed correctly, if you are using pnpm please set the public hoist pattern to: `public-hoist-pattern[]=*`.\nRefer to your docs for more details: https://docs.netlify.com/integrations/frameworks/next-js/overview/#pnpm-support"
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
var writeTagsManifest = async (ctx) => {
|
|
222
|
+
const manifest = await ctx.getPrerenderManifest();
|
|
223
|
+
const routes = Object.entries(manifest.routes).map(async ([route, definition]) => {
|
|
224
|
+
let tags;
|
|
225
|
+
if (definition.dataRoute?.endsWith(".rsc")) {
|
|
226
|
+
const path = join(ctx.publishDir, `server/app/${route === "/" ? "/index" : route}.meta`);
|
|
227
|
+
try {
|
|
228
|
+
const file = await readFile(path, "utf-8");
|
|
229
|
+
const meta = JSON.parse(file);
|
|
230
|
+
tags = meta.headers["x-next-cache-tags"];
|
|
231
|
+
} catch {
|
|
232
|
+
if (!definition.dataRoute?.endsWith("/default.rsc")) {
|
|
233
|
+
console.log(`Unable to read cache tags for: ${path}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (definition.dataRoute?.endsWith(".json")) {
|
|
238
|
+
tags = `_N_T_${route}`;
|
|
239
|
+
}
|
|
240
|
+
if (definition.dataRoute === null) {
|
|
241
|
+
tags = definition.initialHeaders?.["x-next-cache-tags"];
|
|
242
|
+
}
|
|
243
|
+
return [route, tags];
|
|
244
|
+
});
|
|
245
|
+
await writeFile(
|
|
246
|
+
join(ctx.serverHandlerDir, ".netlify/tags-manifest.json"),
|
|
247
|
+
JSON.stringify(Object.fromEntries(await Promise.all(routes))),
|
|
248
|
+
"utf-8"
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
var replaceMiddlewareManifest = async (sourcePath, destPath) => {
|
|
252
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
253
|
+
const data = await readFile(sourcePath, "utf8");
|
|
254
|
+
const manifest = JSON.parse(data);
|
|
255
|
+
const newManifest = {
|
|
256
|
+
...manifest,
|
|
257
|
+
middleware: {}
|
|
258
|
+
};
|
|
259
|
+
const newData = JSON.stringify(newManifest);
|
|
260
|
+
await writeFile(destPath, newData);
|
|
261
|
+
};
|
|
262
|
+
var verifyHandlerDirStructure = async (ctx) => {
|
|
263
|
+
const runConfig = JSON.parse(await readFile(join(ctx.serverHandlerDir, RUN_CONFIG), "utf-8"));
|
|
264
|
+
const expectedBuildIDPath = join(ctx.serverHandlerDir, runConfig.distDir, "BUILD_ID");
|
|
265
|
+
if (!existsSync(expectedBuildIDPath)) {
|
|
266
|
+
ctx.failBuild(
|
|
267
|
+
`Failed creating server handler. BUILD_ID file not found at expected location "${expectedBuildIDPath}".`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export {
|
|
273
|
+
copyNextServerCode,
|
|
274
|
+
getPatchesToApply,
|
|
275
|
+
copyNextDependencies,
|
|
276
|
+
writeTagsManifest,
|
|
277
|
+
verifyHandlerDirStructure
|
|
278
|
+
};
|
|
@@ -8,7 +8,7 @@ import "./chunk-5JVNISGM.js";
|
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var name = "@netlify/plugin-nextjs";
|
|
11
|
-
var version = "5.0.0-rc.
|
|
11
|
+
var version = "5.0.0-rc.7";
|
|
12
12
|
var description = "Run Next.js seamlessly on Netlify";
|
|
13
13
|
var main = "./dist/index.js";
|
|
14
14
|
var type = "module";
|
|
@@ -23,7 +23,7 @@ var engines = {
|
|
|
23
23
|
var scripts = {
|
|
24
24
|
prepack: "clean-package",
|
|
25
25
|
postpack: "clean-package restore",
|
|
26
|
-
pretest: "node tests/prepare.mjs",
|
|
26
|
+
pretest: "npm run build && node tests/prepare.mjs",
|
|
27
27
|
build: "node ./tools/build.js",
|
|
28
28
|
"build:watch": "node ./tools/build.js --watch",
|
|
29
29
|
lint: "eslint --cache --format=codeframe --max-warnings=0 --ext .ts,.cts,.js src",
|
|
@@ -60,7 +60,7 @@ var devDependencies = {
|
|
|
60
60
|
"@netlify/functions": "^2.5.1",
|
|
61
61
|
"@netlify/serverless-functions-api": "^1.10.1",
|
|
62
62
|
"@netlify/zip-it-and-ship-it": "^9.30.0",
|
|
63
|
-
"@opentelemetry/api": "^1.
|
|
63
|
+
"@opentelemetry/api": "^1.8.0",
|
|
64
64
|
"@opentelemetry/exporter-trace-otlp-http": "^0.49.0",
|
|
65
65
|
"@opentelemetry/resources": "^1.21.0",
|
|
66
66
|
"@opentelemetry/sdk-node": "^0.49.0",
|
package/dist/index.js
CHANGED
|
@@ -6,21 +6,28 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
copyPrerenderedContent
|
|
9
|
-
} from "./esm-chunks/chunk-
|
|
9
|
+
} from "./esm-chunks/chunk-4635LKT6.js";
|
|
10
10
|
import {
|
|
11
11
|
copyStaticAssets,
|
|
12
12
|
copyStaticContent,
|
|
13
13
|
copyStaticExport,
|
|
14
14
|
publishStaticDir,
|
|
15
15
|
unpublishStaticDir
|
|
16
|
-
} from "./esm-chunks/chunk-
|
|
16
|
+
} from "./esm-chunks/chunk-GV3YIJ33.js";
|
|
17
17
|
import {
|
|
18
18
|
createEdgeHandlers
|
|
19
19
|
} from "./esm-chunks/chunk-OBKVBMAL.js";
|
|
20
20
|
import {
|
|
21
21
|
createServerHandler
|
|
22
|
-
} from "./esm-chunks/chunk-
|
|
23
|
-
import "./esm-chunks/chunk-
|
|
22
|
+
} from "./esm-chunks/chunk-757FQQND.js";
|
|
23
|
+
import "./esm-chunks/chunk-YSGPGDIG.js";
|
|
24
|
+
import {
|
|
25
|
+
wrapTracer
|
|
26
|
+
} from "./esm-chunks/chunk-PDPDW32D.js";
|
|
27
|
+
import {
|
|
28
|
+
init_esm,
|
|
29
|
+
trace
|
|
30
|
+
} from "./esm-chunks/chunk-Y3K5Q6FP.js";
|
|
24
31
|
import "./esm-chunks/chunk-VZNKO4OO.js";
|
|
25
32
|
import {
|
|
26
33
|
restoreBuildCache,
|
|
@@ -42,43 +49,56 @@ import "./esm-chunks/chunk-TYCYFZ22.js";
|
|
|
42
49
|
import "./esm-chunks/chunk-5JVNISGM.js";
|
|
43
50
|
|
|
44
51
|
// src/index.ts
|
|
52
|
+
init_esm();
|
|
53
|
+
var tracer = wrapTracer(trace.getTracer("Next.js runtime"));
|
|
45
54
|
var onPreBuild = async (options) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
await tracer.withActiveSpan("onPreBuild", async () => {
|
|
56
|
+
process.env.NEXT_PRIVATE_STANDALONE = "true";
|
|
57
|
+
if (!options.constants.IS_LOCAL) {
|
|
58
|
+
await restoreBuildCache(new PluginContext(options));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
50
61
|
};
|
|
51
62
|
var onBuild = async (options) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
await tracer.withActiveSpan("onBuild", async (span) => {
|
|
64
|
+
const ctx = new PluginContext(options);
|
|
65
|
+
verifyPublishDir(ctx);
|
|
66
|
+
verifyBuildConfig(ctx);
|
|
67
|
+
span.setAttribute("next.buildConfig", JSON.stringify(ctx.buildConfig));
|
|
68
|
+
if (!options.constants.IS_LOCAL) {
|
|
69
|
+
await saveBuildCache(ctx);
|
|
70
|
+
}
|
|
71
|
+
if (ctx.buildConfig.output === "export") {
|
|
72
|
+
return copyStaticExport(ctx);
|
|
73
|
+
}
|
|
74
|
+
await Promise.all([
|
|
75
|
+
copyStaticAssets(ctx),
|
|
76
|
+
copyStaticContent(ctx),
|
|
77
|
+
copyPrerenderedContent(ctx),
|
|
78
|
+
createServerHandler(ctx),
|
|
79
|
+
createEdgeHandlers(ctx),
|
|
80
|
+
setImageConfig(ctx)
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
69
83
|
};
|
|
70
84
|
var onPostBuild = async (options) => {
|
|
71
|
-
await
|
|
85
|
+
await tracer.withActiveSpan("onPostBuild", async () => {
|
|
86
|
+
await publishStaticDir(new PluginContext(options));
|
|
87
|
+
});
|
|
72
88
|
};
|
|
73
89
|
var onSuccess = async () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
await tracer.withActiveSpan("onSuccess", async () => {
|
|
91
|
+
const prewarm = [process.env.DEPLOY_URL, process.env.DEPLOY_PRIME_URL, process.env.URL].filter(
|
|
92
|
+
// If running locally then the deploy ID is a placeholder value. Filtering for `https://0--` removes it.
|
|
93
|
+
(url) => Boolean(url && !url.startsWith("https://0--"))
|
|
94
|
+
);
|
|
95
|
+
await Promise.allSettled(prewarm.map((url) => fetch(url)));
|
|
96
|
+
});
|
|
79
97
|
};
|
|
80
98
|
var onEnd = async (options) => {
|
|
81
|
-
await
|
|
99
|
+
await tracer.withActiveSpan("onEnd", async () => {
|
|
100
|
+
await unpublishStaticDir(new PluginContext(options));
|
|
101
|
+
});
|
|
82
102
|
};
|
|
83
103
|
export {
|
|
84
104
|
onBuild,
|