@netlify/plugin-nextjs 5.0.0-rc.3 → 5.0.0-rc.5
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 +3 -1
- package/dist/build/content/static.js +3 -1
- package/dist/build/functions/edge.js +2 -2
- package/dist/build/functions/server.js +5 -3
- package/dist/build/image-cdn.js +1 -3
- package/dist/build/plugin-context.js +1 -1
- package/dist/build/verification.js +18 -0
- 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-GFISNHVP.js → chunk-CSTSA3JJ.js} +46 -42
- package/dist/esm-chunks/chunk-FMO6SJ5E.js +1625 -0
- package/dist/esm-chunks/chunk-MGPEWDDD.js +68 -0
- package/dist/esm-chunks/{chunk-ATFMKC2X.js → chunk-OBKVBMAL.js} +1 -1
- package/dist/esm-chunks/chunk-PJG75HGC.js +2454 -0
- package/dist/esm-chunks/{chunk-LWQKZVSS.js → chunk-VSH4JS2L.js} +3 -1
- package/dist/esm-chunks/{chunk-A6CMEU53.js → chunk-W7XTKMHH.js} +4 -4
- package/dist/esm-chunks/{chunk-MPZEWLBG.js → chunk-WFVNEURA.js} +13 -2
- package/dist/esm-chunks/{package-N25EXX4H.js → package-67C5TREY.js} +5 -4
- package/dist/index.js +27 -9
- package/dist/run/handlers/cache.cjs +103 -69
- package/dist/run/handlers/server.js +18 -4
- package/dist/run/handlers/tracing.js +42 -2471
- package/dist/run/headers.js +1 -1
- package/dist/run/next.cjs +97 -63
- package/package.json +2 -10
- package/dist/esm-chunks/chunk-XXBTIYSL.js +0 -7199
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
import {
|
|
8
8
|
require_out
|
|
9
9
|
} from "./chunk-VZNKO4OO.js";
|
|
10
|
+
import {
|
|
11
|
+
verifyNextVersion
|
|
12
|
+
} from "./chunk-MGPEWDDD.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,
|
|
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 {
|
|
@@ -165,42 +203,8 @@ var verifyHandlerDirStructure = async (ctx) => {
|
|
|
165
203
|
const runConfig = JSON.parse(await readFile(join(ctx.serverHandlerDir, RUN_CONFIG), "utf-8"));
|
|
166
204
|
const expectedBuildIDPath = join(ctx.serverHandlerDir, runConfig.distDir, "BUILD_ID");
|
|
167
205
|
if (!existsSync(expectedBuildIDPath)) {
|
|
168
|
-
let additionalGuidance = "";
|
|
169
|
-
try {
|
|
170
|
-
const paths = await (0, import_fast_glob.default)("**/BUILD_ID", {
|
|
171
|
-
cwd: ctx.serverHandlerRootDir,
|
|
172
|
-
dot: true,
|
|
173
|
-
absolute: true,
|
|
174
|
-
ignore: ["**/node_modules/**"]
|
|
175
|
-
});
|
|
176
|
-
const potentiallyNeededPackagePaths = paths.map((path) => {
|
|
177
|
-
const relativePathToBuildID = posixRelative(
|
|
178
|
-
toPosixPath(ctx.serverHandlerDir),
|
|
179
|
-
toPosixPath(path)
|
|
180
|
-
);
|
|
181
|
-
const removedDistDirBuildId = relativePathToBuildID.replace(
|
|
182
|
-
new RegExp(`/?${toPosixPath(runConfig.distDir)}/BUILD_ID$`),
|
|
183
|
-
""
|
|
184
|
-
);
|
|
185
|
-
return removedDistDirBuildId === relativePathToBuildID ? "" : removedDistDirBuildId;
|
|
186
|
-
}).filter(Boolean);
|
|
187
|
-
if (potentiallyNeededPackagePaths.length !== 0) {
|
|
188
|
-
additionalGuidance = `
|
|
189
|
-
|
|
190
|
-
It looks like your site is part of monorepo and Netlify is currently not configured correctly for this case.
|
|
191
|
-
|
|
192
|
-
Current package path: ${ctx.packagePath ? `"${ctx.packagePath}"` : "<not set>"}
|
|
193
|
-
Package path candidates:
|
|
194
|
-
${potentiallyNeededPackagePaths.map((path) => ` - "${path}"`).join(
|
|
195
|
-
"\n"
|
|
196
|
-
)}
|
|
197
|
-
|
|
198
|
-
Refer to https://docs.netlify.com/configure-builds/monorepos/ for more information about monorepo configuration.`;
|
|
199
|
-
}
|
|
200
|
-
} catch {
|
|
201
|
-
}
|
|
202
206
|
ctx.failBuild(
|
|
203
|
-
`Failed creating server handler. BUILD_ID file not found at expected location "${expectedBuildIDPath}"
|
|
207
|
+
`Failed creating server handler. BUILD_ID file not found at expected location "${expectedBuildIDPath}".`
|
|
204
208
|
);
|
|
205
209
|
}
|
|
206
210
|
};
|