@netlify/plugin-nextjs 5.0.0-rc.6 → 5.0.0-rc.8
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/image-cdn.js +1 -1
- package/dist/esm-chunks/{chunk-75UGFPYW.js → chunk-4635LKT6.js} +51 -40
- 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-FMO6SJ5E.js → chunk-MCEOSJH6.js} +21 -9
- package/dist/esm-chunks/chunk-PDPDW32D.js +89 -0
- package/dist/esm-chunks/chunk-Y3K5Q6FP.js +1659 -0
- package/dist/esm-chunks/chunk-YSGPGDIG.js +278 -0
- package/dist/esm-chunks/{package-ZWSB2JUJ.js → package-NFGYFGF2.js} +4 -4
- package/dist/index.js +53 -33
- package/dist/run/handlers/cache.cjs +7 -2
- package/dist/run/handlers/server.js +12 -1
- package/dist/run/handlers/tracing.js +298 -1935
- package/dist/run/next.cjs +3 -4
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-CSTSA3JJ.js +0 -217
- package/dist/esm-chunks/chunk-WFVNEURA.js +0 -94
|
@@ -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.8";
|
|
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",
|
|
@@ -53,14 +53,14 @@ var homepage = "https://github.com/netlify/next-runtime-minimal#readme";
|
|
|
53
53
|
var devDependencies = {
|
|
54
54
|
"@fastly/http-compute-js": "1.1.4",
|
|
55
55
|
"@netlify/blobs": "^7.0.1",
|
|
56
|
-
"@netlify/build": "^29.
|
|
56
|
+
"@netlify/build": "^29.37.2",
|
|
57
57
|
"@netlify/edge-bundler": "^11.3.0",
|
|
58
58
|
"@netlify/edge-functions": "^2.3.1",
|
|
59
59
|
"@netlify/eslint-config-node": "^7.0.1",
|
|
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,
|
|
@@ -28,7 +35,7 @@ import {
|
|
|
28
35
|
} from "./esm-chunks/chunk-72ZI2IVI.js";
|
|
29
36
|
import {
|
|
30
37
|
setImageConfig
|
|
31
|
-
} from "./esm-chunks/chunk-
|
|
38
|
+
} from "./esm-chunks/chunk-MCEOSJH6.js";
|
|
32
39
|
import {
|
|
33
40
|
PluginContext
|
|
34
41
|
} from "./esm-chunks/chunk-3NYX5FXN.js";
|
|
@@ -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,
|
|
@@ -925,12 +925,17 @@ var NetlifyCacheHandler = class {
|
|
|
925
925
|
const lastModified = Date.now();
|
|
926
926
|
span.setAttributes({ key, lastModified, blobKey });
|
|
927
927
|
console.debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
928
|
+
let value = data;
|
|
928
929
|
if (data?.kind === "ROUTE") {
|
|
929
|
-
|
|
930
|
+
value = {
|
|
931
|
+
...data,
|
|
932
|
+
// @ts-expect-error gotta find a better solution for this
|
|
933
|
+
body: data.body.toString("base64")
|
|
934
|
+
};
|
|
930
935
|
}
|
|
931
936
|
await this.blobStore.setJSON(blobKey, {
|
|
932
937
|
lastModified,
|
|
933
|
-
value
|
|
938
|
+
value
|
|
934
939
|
});
|
|
935
940
|
if (data?.kind === "PAGE") {
|
|
936
941
|
const requestContext = (0, import_request_context.getRequestContext)();
|
|
@@ -3259,6 +3259,7 @@ function toComputeResponse(res) {
|
|
|
3259
3259
|
// src/run/handlers/server.ts
|
|
3260
3260
|
import { createRequestContext, getRequestContext } from "./request-context.cjs";
|
|
3261
3261
|
import { getTracer } from "./tracer.cjs";
|
|
3262
|
+
var nextImportPromise = import("../next.cjs");
|
|
3262
3263
|
var nextHandler;
|
|
3263
3264
|
var nextConfig;
|
|
3264
3265
|
var tagsManifest;
|
|
@@ -3292,7 +3293,7 @@ var server_default = async (request) => {
|
|
|
3292
3293
|
{}
|
|
3293
3294
|
)
|
|
3294
3295
|
);
|
|
3295
|
-
const { getMockedRequestHandlers } = await
|
|
3296
|
+
const { getMockedRequestHandlers } = await nextImportPromise;
|
|
3296
3297
|
const url = new URL(request.url);
|
|
3297
3298
|
[nextHandler] = await getMockedRequestHandlers({
|
|
3298
3299
|
port: Number(url.port) || 443,
|
|
@@ -3304,6 +3305,16 @@ var server_default = async (request) => {
|
|
|
3304
3305
|
}
|
|
3305
3306
|
return await tracer.withActiveSpan("generate response", async (span) => {
|
|
3306
3307
|
const { req, res } = toReqRes(request);
|
|
3308
|
+
Object.defineProperty(req, "connection", {
|
|
3309
|
+
get() {
|
|
3310
|
+
return {};
|
|
3311
|
+
}
|
|
3312
|
+
});
|
|
3313
|
+
Object.defineProperty(req, "socket", {
|
|
3314
|
+
get() {
|
|
3315
|
+
return {};
|
|
3316
|
+
}
|
|
3317
|
+
});
|
|
3307
3318
|
disableFaultyTransferEncodingHandling(res);
|
|
3308
3319
|
const requestContext = getRequestContext() ?? createRequestContext();
|
|
3309
3320
|
const resProxy = nextResponseProxy(res, requestContext);
|