@netlify/plugin-nextjs 5.1.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/advanced-api-routes.js +121 -4
- package/dist/build/cache.js +25 -4
- package/dist/build/content/prerendered.js +234 -8
- package/dist/build/content/server.js +259 -14
- package/dist/build/content/static.js +96 -11
- package/dist/build/functions/edge.js +511 -5
- package/dist/build/functions/server.js +131 -12
- package/dist/build/image-cdn.js +1626 -3
- package/dist/build/plugin-context.js +236 -5
- package/dist/build/templates/handler-monorepo.tmpl.js +3 -0
- package/dist/build/templates/handler.tmpl.js +3 -0
- package/dist/build/verification.js +81 -8
- package/dist/esm-chunks/{package-RVJOBSMH.js → package-ZBRSUKN7.js} +5 -5
- package/dist/index.js +25 -36
- package/dist/run/config.js +25 -6
- package/dist/run/constants.js +7 -5
- package/dist/run/handlers/cache.cjs +6 -567
- package/dist/run/handlers/request-context.cjs +8 -1
- package/dist/run/handlers/server.js +20 -22
- package/dist/run/handlers/tracing.js +1 -1
- package/dist/run/headers.js +198 -8
- package/dist/run/next.cjs +49 -567
- package/dist/{esm-chunks/chunk-PMRBBOBY.js → run/regional-blob-store.cjs} +117 -263
- package/dist/run/revalidate.js +17 -3
- package/dist/run/systemlog.js +94 -3
- package/dist/shared/blobkey.js +15 -3
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-3SUDZQ7L.js +0 -40
- package/dist/esm-chunks/chunk-4BNHE6TP.js +0 -278
- package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
- package/dist/esm-chunks/chunk-BG455SFE.js +0 -133
- package/dist/esm-chunks/chunk-HESS57SH.js +0 -127
- package/dist/esm-chunks/chunk-HYBEXB2Z.js +0 -105
- package/dist/esm-chunks/chunk-K7BTUM7O.js +0 -97
- package/dist/esm-chunks/chunk-L6OM53B6.js +0 -238
- package/dist/esm-chunks/chunk-MCEOSJH6.js +0 -1637
- package/dist/esm-chunks/chunk-MRD3XSKD.js +0 -248
- package/dist/esm-chunks/chunk-RL4K4CVH.js +0 -27
- package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
- package/dist/esm-chunks/chunk-UTQSBE5O.js +0 -524
- package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
- package/dist/esm-chunks/chunk-V2T6NUOM.js +0 -113
|
@@ -5,18 +5,137 @@
|
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "../../esm-chunks/chunk-
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
require_out
|
|
9
|
+
} from "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
10
|
+
import {
|
|
11
|
+
wrapTracer
|
|
12
|
+
} from "../../esm-chunks/chunk-PDPDW32D.js";
|
|
13
|
+
import {
|
|
14
|
+
init_esm,
|
|
15
|
+
trace
|
|
16
|
+
} from "../../esm-chunks/chunk-Y3K5Q6FP.js";
|
|
17
|
+
import {
|
|
18
|
+
__toESM
|
|
19
|
+
} from "../../esm-chunks/chunk-5JVNISGM.js";
|
|
20
|
+
|
|
21
|
+
// src/build/functions/server.ts
|
|
22
|
+
init_esm();
|
|
23
|
+
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
24
|
+
import { join, relative } from "node:path";
|
|
25
|
+
import { join as posixJoin } from "node:path/posix";
|
|
26
|
+
var import_fast_glob = __toESM(require_out(), 1);
|
|
27
|
+
import {
|
|
28
|
+
copyNextDependencies,
|
|
29
|
+
copyNextServerCode,
|
|
30
|
+
verifyHandlerDirStructure,
|
|
31
|
+
writeTagsManifest
|
|
32
|
+
} from "../content/server.js";
|
|
33
|
+
import { SERVER_HANDLER_NAME } from "../plugin-context.js";
|
|
34
|
+
var tracer = wrapTracer(trace.getTracer("Next runtime"));
|
|
35
|
+
var copyHandlerDependencies = async (ctx) => {
|
|
36
|
+
await tracer.withActiveSpan("copyHandlerDependencies", async (span) => {
|
|
37
|
+
const promises = [];
|
|
38
|
+
const { included_files: includedFiles = [] } = ctx.netlifyConfig.functions?.["*"] || {};
|
|
39
|
+
includedFiles.push(
|
|
40
|
+
posixJoin(ctx.relativeAppDir, ".env"),
|
|
41
|
+
posixJoin(ctx.relativeAppDir, ".env.production"),
|
|
42
|
+
posixJoin(ctx.relativeAppDir, ".env.local"),
|
|
43
|
+
posixJoin(ctx.relativeAppDir, ".env.production.local")
|
|
44
|
+
);
|
|
45
|
+
span.setAttribute("next.includedFiles", includedFiles.join(","));
|
|
46
|
+
const resolvedFiles = await Promise.all(
|
|
47
|
+
includedFiles.map((globPattern) => (0, import_fast_glob.glob)(globPattern, { cwd: process.cwd() }))
|
|
48
|
+
);
|
|
49
|
+
for (const filePath of resolvedFiles.flat()) {
|
|
50
|
+
promises.push(
|
|
51
|
+
cp(
|
|
52
|
+
join(process.cwd(), filePath),
|
|
53
|
+
// the serverHandlerDir is aware of the dist dir.
|
|
54
|
+
// The distDir must not be the package path therefore we need to rely on the
|
|
55
|
+
// serverHandlerDir instead of the serverHandlerRootDir
|
|
56
|
+
// therefore we need to remove the package path from the filePath
|
|
57
|
+
join(ctx.serverHandlerDir, relative(ctx.relativeAppDir, filePath)),
|
|
58
|
+
{
|
|
59
|
+
recursive: true,
|
|
60
|
+
force: true
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const fileList = await (0, import_fast_glob.glob)("dist/**/*", { cwd: ctx.pluginDir });
|
|
66
|
+
for (const filePath of fileList) {
|
|
67
|
+
promises.push(
|
|
68
|
+
cp(join(ctx.pluginDir, filePath), join(ctx.serverHandlerDir, ".netlify", filePath), {
|
|
69
|
+
recursive: true,
|
|
70
|
+
force: true
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
await Promise.all(promises);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var writeHandlerManifest = async (ctx) => {
|
|
78
|
+
await writeFile(
|
|
79
|
+
join(ctx.serverHandlerRootDir, `${SERVER_HANDLER_NAME}.json`),
|
|
80
|
+
JSON.stringify({
|
|
81
|
+
config: {
|
|
82
|
+
name: "Next.js Server Handler",
|
|
83
|
+
generator: `${ctx.pluginName}@${ctx.pluginVersion}`,
|
|
84
|
+
nodeBundler: "none",
|
|
85
|
+
// the folders can vary in monorepos based on the folder structure of the user so we have to glob all
|
|
86
|
+
includedFiles: ["**"],
|
|
87
|
+
includedFilesBasePath: ctx.serverHandlerRootDir
|
|
88
|
+
},
|
|
89
|
+
version: 1
|
|
90
|
+
}),
|
|
91
|
+
"utf-8"
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
var writePackageMetadata = async (ctx) => {
|
|
95
|
+
await writeFile(
|
|
96
|
+
join(ctx.serverHandlerRootDir, "package.json"),
|
|
97
|
+
JSON.stringify({ type: "module" })
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
var applyTemplateVariables = (template, variables) => {
|
|
101
|
+
return Object.entries(variables).reduce((acc, [key, value]) => {
|
|
102
|
+
return acc.replaceAll(key, value);
|
|
103
|
+
}, template);
|
|
104
|
+
};
|
|
105
|
+
var getHandlerFile = async (ctx) => {
|
|
106
|
+
const templatesDir = join(ctx.pluginDir, "dist/build/templates");
|
|
107
|
+
const templateVariables = {
|
|
108
|
+
"{{useRegionalBlobs}}": ctx.useRegionalBlobs.toString()
|
|
109
|
+
};
|
|
110
|
+
if (ctx.relativeAppDir.length !== 0) {
|
|
111
|
+
const template = await readFile(join(templatesDir, "handler-monorepo.tmpl.js"), "utf-8");
|
|
112
|
+
templateVariables["{{cwd}}"] = posixJoin(ctx.lambdaWorkingDirectory);
|
|
113
|
+
templateVariables["{{nextServerHandler}}"] = posixJoin(ctx.nextServerHandler);
|
|
114
|
+
return applyTemplateVariables(template, templateVariables);
|
|
115
|
+
}
|
|
116
|
+
return applyTemplateVariables(
|
|
117
|
+
await readFile(join(templatesDir, "handler.tmpl.js"), "utf-8"),
|
|
118
|
+
templateVariables
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
var writeHandlerFile = async (ctx) => {
|
|
122
|
+
const handler = await getHandlerFile(ctx);
|
|
123
|
+
await writeFile(join(ctx.serverHandlerRootDir, `${SERVER_HANDLER_NAME}.mjs`), handler);
|
|
124
|
+
};
|
|
125
|
+
var createServerHandler = async (ctx) => {
|
|
126
|
+
await tracer.withActiveSpan("createServerHandler", async () => {
|
|
127
|
+
await rm(ctx.serverFunctionsDir, { recursive: true, force: true });
|
|
128
|
+
await mkdir(join(ctx.serverHandlerDir, ".netlify"), { recursive: true });
|
|
129
|
+
await copyNextServerCode(ctx);
|
|
130
|
+
await copyNextDependencies(ctx);
|
|
131
|
+
await writeTagsManifest(ctx);
|
|
132
|
+
await copyHandlerDependencies(ctx);
|
|
133
|
+
await writeHandlerManifest(ctx);
|
|
134
|
+
await writePackageMetadata(ctx);
|
|
135
|
+
await writeHandlerFile(ctx);
|
|
136
|
+
await verifyHandlerDirStructure(ctx);
|
|
137
|
+
});
|
|
138
|
+
};
|
|
20
139
|
export {
|
|
21
140
|
createServerHandler
|
|
22
141
|
};
|