@netlify/plugin-nextjs 5.0.0-rc.2 → 5.0.0-rc.3
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/content/prerendered.js +1 -1
- package/dist/build/content/server.js +3 -1
- package/dist/build/functions/edge.js +1 -1
- package/dist/build/functions/server.js +2 -2
- package/dist/esm-chunks/{chunk-E3NFUTWC.js → chunk-A6CMEU53.js} +4 -2
- package/dist/esm-chunks/{chunk-ZZOGIP2V.js → chunk-ATFMKC2X.js} +26 -33
- package/dist/esm-chunks/{chunk-52WMBYKL.js → chunk-GFISNHVP.js} +46 -2
- package/dist/esm-chunks/chunk-GQ6KIYPX.js +1658 -0
- package/dist/esm-chunks/{chunk-67EWAGDQ.js → chunk-LWQKZVSS.js} +16 -6
- package/dist/esm-chunks/{package-V53S3A76.js → package-N25EXX4H.js} +6 -3
- package/dist/index.js +4 -4
- package/dist/run/handlers/cache.cjs +774 -1652
- package/dist/run/handlers/server.js +7 -5
- package/dist/run/handlers/tracing.js +4537 -3699
- package/dist/run/next.cjs +762 -1650
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-VDDK7MXY.js +0 -1661
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {
|
|
8
8
|
copyFetchContent,
|
|
9
9
|
copyPrerenderedContent
|
|
10
|
-
} from "../../esm-chunks/chunk-
|
|
10
|
+
} from "../../esm-chunks/chunk-LWQKZVSS.js";
|
|
11
11
|
import "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
12
12
|
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
13
13
|
import "../../esm-chunks/chunk-5JVNISGM.js";
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
import {
|
|
8
8
|
copyNextDependencies,
|
|
9
9
|
copyNextServerCode,
|
|
10
|
+
verifyHandlerDirStructure,
|
|
10
11
|
writeTagsManifest
|
|
11
|
-
} from "../../esm-chunks/chunk-
|
|
12
|
+
} from "../../esm-chunks/chunk-GFISNHVP.js";
|
|
12
13
|
import "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
13
14
|
import "../../esm-chunks/chunk-UYKENJEU.js";
|
|
14
15
|
import "../../esm-chunks/chunk-5JVNISGM.js";
|
|
15
16
|
export {
|
|
16
17
|
copyNextDependencies,
|
|
17
18
|
copyNextServerCode,
|
|
19
|
+
verifyHandlerDirStructure,
|
|
18
20
|
writeTagsManifest
|
|
19
21
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
createEdgeHandlers
|
|
9
|
-
} from "../../esm-chunks/chunk-
|
|
9
|
+
} from "../../esm-chunks/chunk-ATFMKC2X.js";
|
|
10
10
|
import "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
11
11
|
import "../../esm-chunks/chunk-655Y7ISI.js";
|
|
12
12
|
import "../../esm-chunks/chunk-5JVNISGM.js";
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
createServerHandler
|
|
9
|
-
} from "../../esm-chunks/chunk-
|
|
10
|
-
import "../../esm-chunks/chunk-
|
|
9
|
+
} from "../../esm-chunks/chunk-A6CMEU53.js";
|
|
10
|
+
import "../../esm-chunks/chunk-GFISNHVP.js";
|
|
11
11
|
import "../../esm-chunks/chunk-VZNKO4OO.js";
|
|
12
12
|
import "../../esm-chunks/chunk-655Y7ISI.js";
|
|
13
13
|
import "../../esm-chunks/chunk-UYKENJEU.js";
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
import {
|
|
8
8
|
copyNextDependencies,
|
|
9
9
|
copyNextServerCode,
|
|
10
|
+
verifyHandlerDirStructure,
|
|
10
11
|
writeTagsManifest
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GFISNHVP.js";
|
|
12
13
|
import {
|
|
13
14
|
require_out
|
|
14
15
|
} from "./chunk-VZNKO4OO.js";
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
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) => {
|
|
@@ -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 {
|
|
@@ -393,7 +393,7 @@ var require_dist = __commonJS({
|
|
|
393
393
|
var import_fast_glob = __toESM(require_out(), 1);
|
|
394
394
|
var import_path_to_regexp = __toESM(require_dist(), 1);
|
|
395
395
|
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
396
|
-
import { dirname, join
|
|
396
|
+
import { dirname, join } from "node:path";
|
|
397
397
|
var writeEdgeManifest = async (ctx, manifest) => {
|
|
398
398
|
await mkdir(ctx.edgeFunctionsDir, { recursive: true });
|
|
399
399
|
await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
@@ -459,38 +459,31 @@ var writeHandlerFile = async (ctx, { matchers, name }) => {
|
|
|
459
459
|
var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
|
|
460
460
|
const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
|
|
461
461
|
const destDir = join(ctx.edgeFunctionsDir, getHandlerName({ name }));
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
await mkdir(dirname(join(destDir, file)), { recursive: true });
|
|
488
|
-
await writeFile(join(destDir, file), [...parts, entrypoint, exports].join("\n;"));
|
|
489
|
-
} else {
|
|
490
|
-
await cp(join(srcDir, file), join(destDir, file));
|
|
491
|
-
}
|
|
492
|
-
})
|
|
493
|
-
);
|
|
462
|
+
const edgeRuntimeDir = join(ctx.pluginDir, "edge-runtime");
|
|
463
|
+
const shimPath = join(edgeRuntimeDir, "shim/index.js");
|
|
464
|
+
const shim = await readFile(shimPath, "utf8");
|
|
465
|
+
const parts = [shim];
|
|
466
|
+
if (wasm?.length) {
|
|
467
|
+
parts.push(
|
|
468
|
+
`import { decode as _base64Decode } from "../edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts";`
|
|
469
|
+
);
|
|
470
|
+
for (const wasmChunk of wasm ?? []) {
|
|
471
|
+
const data = await readFile(join(srcDir, wasmChunk.filePath));
|
|
472
|
+
parts.push(
|
|
473
|
+
`const ${wasmChunk.name} = _base64Decode(${JSON.stringify(
|
|
474
|
+
data.toString("base64")
|
|
475
|
+
)}).buffer`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
for (const file of files) {
|
|
480
|
+
const entrypoint = await readFile(join(srcDir, file), "utf8");
|
|
481
|
+
parts.push(`;// Concatenated file: ${file}
|
|
482
|
+
`, entrypoint);
|
|
483
|
+
}
|
|
484
|
+
const exports = `export default _ENTRIES["middleware_${name}"].default;`;
|
|
485
|
+
await mkdir(dirname(join(destDir, `server/${name}.js`)), { recursive: true });
|
|
486
|
+
await writeFile(join(destDir, `server/${name}.js`), [...parts, exports].join("\n"));
|
|
494
487
|
};
|
|
495
488
|
var createEdgeHandler = async (ctx, definition) => {
|
|
496
489
|
await copyHandlerDependencies(ctx, definition);
|
|
@@ -20,7 +20,7 @@ import { existsSync } from "node:fs";
|
|
|
20
20
|
import { cp, mkdir, readFile, readdir, readlink, symlink, writeFile } from "node:fs/promises";
|
|
21
21
|
import { createRequire } from "node:module";
|
|
22
22
|
import { dirname, join, resolve, sep } from "node:path";
|
|
23
|
-
import { sep as posixSep } from "node:path/posix";
|
|
23
|
+
import { sep as posixSep, relative as posixRelative } from "node:path/posix";
|
|
24
24
|
var toPosixPath = (path) => path.split(sep).join(posixSep);
|
|
25
25
|
var copyNextServerCode = async (ctx) => {
|
|
26
26
|
const reqServerFilesPath = join(
|
|
@@ -161,9 +161,53 @@ var replaceMiddlewareManifest = async (sourcePath, destPath) => {
|
|
|
161
161
|
const newData = JSON.stringify(newManifest);
|
|
162
162
|
await writeFile(destPath, newData);
|
|
163
163
|
};
|
|
164
|
+
var verifyHandlerDirStructure = async (ctx) => {
|
|
165
|
+
const runConfig = JSON.parse(await readFile(join(ctx.serverHandlerDir, RUN_CONFIG), "utf-8"));
|
|
166
|
+
const expectedBuildIDPath = join(ctx.serverHandlerDir, runConfig.distDir, "BUILD_ID");
|
|
167
|
+
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
|
+
ctx.failBuild(
|
|
203
|
+
`Failed creating server handler. BUILD_ID file not found at expected location "${expectedBuildIDPath}".${additionalGuidance}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
164
207
|
|
|
165
208
|
export {
|
|
166
209
|
copyNextServerCode,
|
|
167
210
|
copyNextDependencies,
|
|
168
|
-
writeTagsManifest
|
|
211
|
+
writeTagsManifest,
|
|
212
|
+
verifyHandlerDirStructure
|
|
169
213
|
};
|