@netlify/plugin-nextjs 5.0.0-rc.2 → 5.0.0-rc.4
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 +16 -0
- package/dist/build/content/prerendered.js +1 -1
- package/dist/build/content/server.js +5 -1
- package/dist/build/content/static.js +1 -1
- package/dist/build/functions/edge.js +2 -2
- package/dist/build/functions/server.js +5 -3
- package/dist/build/plugin-context.js +1 -1
- package/dist/build/verification.js +18 -0
- package/dist/esm-chunks/{chunk-MPZEWLBG.js → chunk-3IGTKVSS.js} +4 -2
- package/dist/esm-chunks/{chunk-655Y7ISI.js → chunk-3NYX5FXN.js} +30 -33
- package/dist/esm-chunks/{chunk-UTCWWUFW.js → chunk-637Y3P2U.js} +99 -65
- package/dist/esm-chunks/chunk-7CY6B4WT.js +61 -0
- package/dist/esm-chunks/{chunk-E3NFUTWC.js → chunk-7HI65MAI.js} +7 -5
- package/dist/esm-chunks/{chunk-52WMBYKL.js → chunk-BKDCZVBK.js} +56 -8
- package/dist/esm-chunks/chunk-GQ6KIYPX.js +1658 -0
- package/dist/esm-chunks/{chunk-ZZOGIP2V.js → chunk-OBKVBMAL.js} +27 -34
- package/dist/esm-chunks/chunk-PJG75HGC.js +2454 -0
- package/dist/esm-chunks/{chunk-67EWAGDQ.js → chunk-VSH4JS2L.js} +18 -6
- package/dist/esm-chunks/{package-V53S3A76.js → package-K6MJITES.js} +10 -5
- package/dist/index.js +13 -7
- package/dist/run/handlers/cache.cjs +878 -1722
- package/dist/run/handlers/server.js +25 -9
- package/dist/run/handlers/tracing.js +5249 -6840
- package/dist/run/headers.js +1 -1
- package/dist/run/next.cjs +863 -1717
- package/package.json +2 -10
- package/dist/esm-chunks/chunk-VDDK7MXY.js +0 -1661
|
@@ -7,21 +7,22 @@
|
|
|
7
7
|
import {
|
|
8
8
|
copyNextDependencies,
|
|
9
9
|
copyNextServerCode,
|
|
10
|
+
verifyHandlerDirStructure,
|
|
10
11
|
writeTagsManifest
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BKDCZVBK.js";
|
|
12
13
|
import {
|
|
13
14
|
require_out
|
|
14
15
|
} from "./chunk-VZNKO4OO.js";
|
|
15
16
|
import {
|
|
16
17
|
SERVER_HANDLER_NAME
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-3NYX5FXN.js";
|
|
18
19
|
import {
|
|
19
20
|
__toESM
|
|
20
21
|
} from "./chunk-5JVNISGM.js";
|
|
21
22
|
|
|
22
23
|
// src/build/functions/server.ts
|
|
23
24
|
var import_fast_glob = __toESM(require_out(), 1);
|
|
24
|
-
import { cp, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
25
|
+
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
25
26
|
import { join, relative } from "node:path";
|
|
26
27
|
import { join as posixJoin } from "node:path/posix";
|
|
27
28
|
var copyHandlerDependencies = async (ctx) => {
|
|
@@ -39,7 +40,7 @@ var copyHandlerDependencies = async (ctx) => {
|
|
|
39
40
|
// The distDir must not be the package path therefore we need to rely on the
|
|
40
41
|
// serverHandlerDir instead of the serverHandlerRootDir
|
|
41
42
|
// therefore we need to remove the package path from the filePath
|
|
42
|
-
join(ctx.serverHandlerDir, relative(ctx.
|
|
43
|
+
join(ctx.serverHandlerDir, relative(ctx.relativeAppDir, filePath)),
|
|
43
44
|
{
|
|
44
45
|
recursive: true,
|
|
45
46
|
force: true
|
|
@@ -84,7 +85,7 @@ var writePackageMetadata = async (ctx) => {
|
|
|
84
85
|
};
|
|
85
86
|
var getHandlerFile = async (ctx) => {
|
|
86
87
|
const templatesDir = join(ctx.pluginDir, "dist/build/templates");
|
|
87
|
-
if (ctx.
|
|
88
|
+
if (ctx.relativeAppDir.length !== 0) {
|
|
88
89
|
const template = await readFile(join(templatesDir, "handler-monorepo.tmpl.js"), "utf-8");
|
|
89
90
|
return template.replaceAll("{{cwd}}", posixJoin(ctx.lambdaWorkingDirectory)).replace("{{nextServerHandler}}", posixJoin(ctx.nextServerHandler));
|
|
90
91
|
}
|
|
@@ -106,6 +107,7 @@ var createServerHandler = async (ctx) => {
|
|
|
106
107
|
writePackageMetadata(ctx),
|
|
107
108
|
writeHandlerFile(ctx)
|
|
108
109
|
]);
|
|
110
|
+
await verifyHandlerDirStructure(ctx);
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
export {
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
import {
|
|
8
8
|
require_out
|
|
9
9
|
} from "./chunk-VZNKO4OO.js";
|
|
10
|
+
import {
|
|
11
|
+
verifyNextVersion
|
|
12
|
+
} from "./chunk-7CY6B4WT.js";
|
|
10
13
|
import {
|
|
11
14
|
RUN_CONFIG
|
|
12
15
|
} from "./chunk-UYKENJEU.js";
|
|
@@ -17,19 +20,43 @@ import {
|
|
|
17
20
|
// src/build/content/server.ts
|
|
18
21
|
var import_fast_glob = __toESM(require_out(), 1);
|
|
19
22
|
import { existsSync } from "node:fs";
|
|
20
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
cp,
|
|
25
|
+
mkdir,
|
|
26
|
+
readFile,
|
|
27
|
+
readdir,
|
|
28
|
+
readlink,
|
|
29
|
+
symlink,
|
|
30
|
+
writeFile,
|
|
31
|
+
access
|
|
32
|
+
} from "node:fs/promises";
|
|
21
33
|
import { createRequire } from "node:module";
|
|
22
34
|
import { dirname, join, resolve, sep } from "node:path";
|
|
23
|
-
import { sep as posixSep } from "node:path/posix";
|
|
35
|
+
import { sep as posixSep, join as posixJoin } from "node:path/posix";
|
|
24
36
|
var toPosixPath = (path) => path.split(sep).join(posixSep);
|
|
37
|
+
function isError(error) {
|
|
38
|
+
return error instanceof Error;
|
|
39
|
+
}
|
|
25
40
|
var copyNextServerCode = async (ctx) => {
|
|
26
41
|
const reqServerFilesPath = join(
|
|
27
42
|
ctx.standaloneRootDir,
|
|
28
|
-
ctx.
|
|
43
|
+
ctx.relativeAppDir,
|
|
44
|
+
ctx.requiredServerFiles.config.distDir,
|
|
29
45
|
"required-server-files.json"
|
|
30
46
|
);
|
|
47
|
+
try {
|
|
48
|
+
await access(reqServerFilesPath);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (isError(error) && error.code === "ENOENT") {
|
|
51
|
+
ctx.failBuild(
|
|
52
|
+
`Failed creating server handler. required-server-files.json file not found at expected location "${reqServerFilesPath}". Your repository setup is currently not yet supported.`
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
31
58
|
const reqServerFiles = JSON.parse(await readFile(reqServerFilesPath, "utf-8"));
|
|
32
|
-
if (toPosixPath(ctx.distDir).replace(new RegExp(`^${ctx.
|
|
59
|
+
if (toPosixPath(ctx.distDir).replace(new RegExp(`^${ctx.relativeAppDir}/?`), "") !== reqServerFiles.config.distDir) {
|
|
33
60
|
reqServerFiles.config.distDir = ctx.nextDistDir;
|
|
34
61
|
await writeFile(reqServerFilesPath, JSON.stringify(reqServerFiles));
|
|
35
62
|
}
|
|
@@ -96,7 +123,7 @@ var copyNextDependencies = async (ctx) => {
|
|
|
96
123
|
const dest = join(ctx.serverHandlerDir, entry);
|
|
97
124
|
await cp(src, dest, { recursive: true, verbatimSymlinks: true, force: true });
|
|
98
125
|
if (entry === "node_modules") {
|
|
99
|
-
await recreateNodeModuleSymlinks(ctx.
|
|
126
|
+
await recreateNodeModuleSymlinks(ctx.resolveFromSiteDir("node_modules"), dest);
|
|
100
127
|
}
|
|
101
128
|
});
|
|
102
129
|
const rootSrcDir = join(ctx.standaloneRootDir, "node_modules");
|
|
@@ -109,9 +136,20 @@ var copyNextDependencies = async (ctx) => {
|
|
|
109
136
|
);
|
|
110
137
|
}
|
|
111
138
|
await Promise.all(promises);
|
|
112
|
-
const
|
|
139
|
+
const serverHandlerRequire = createRequire(posixJoin(ctx.serverHandlerDir, ":internal:"));
|
|
140
|
+
let nextVersion;
|
|
141
|
+
try {
|
|
142
|
+
const { version } = serverHandlerRequire("next/package.json");
|
|
143
|
+
if (version) {
|
|
144
|
+
nextVersion = version;
|
|
145
|
+
}
|
|
146
|
+
} catch {
|
|
147
|
+
}
|
|
148
|
+
if (nextVersion) {
|
|
149
|
+
verifyNextVersion(ctx, nextVersion);
|
|
150
|
+
}
|
|
113
151
|
try {
|
|
114
|
-
const nextEntryAbsolutePath =
|
|
152
|
+
const nextEntryAbsolutePath = serverHandlerRequire.resolve("next");
|
|
115
153
|
const nextRequire = createRequire(nextEntryAbsolutePath);
|
|
116
154
|
nextRequire.resolve("styled-jsx");
|
|
117
155
|
} catch {
|
|
@@ -161,9 +199,19 @@ var replaceMiddlewareManifest = async (sourcePath, destPath) => {
|
|
|
161
199
|
const newData = JSON.stringify(newManifest);
|
|
162
200
|
await writeFile(destPath, newData);
|
|
163
201
|
};
|
|
202
|
+
var verifyHandlerDirStructure = async (ctx) => {
|
|
203
|
+
const runConfig = JSON.parse(await readFile(join(ctx.serverHandlerDir, RUN_CONFIG), "utf-8"));
|
|
204
|
+
const expectedBuildIDPath = join(ctx.serverHandlerDir, runConfig.distDir, "BUILD_ID");
|
|
205
|
+
if (!existsSync(expectedBuildIDPath)) {
|
|
206
|
+
ctx.failBuild(
|
|
207
|
+
`Failed creating server handler. BUILD_ID file not found at expected location "${expectedBuildIDPath}".`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
164
211
|
|
|
165
212
|
export {
|
|
166
213
|
copyNextServerCode,
|
|
167
214
|
copyNextDependencies,
|
|
168
|
-
writeTagsManifest
|
|
215
|
+
writeTagsManifest,
|
|
216
|
+
verifyHandlerDirStructure
|
|
169
217
|
};
|