@netlify/plugin-nextjs 5.0.0-rc.5 → 5.0.0-rc.6

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.
@@ -1,125 +0,0 @@
1
-
2
- var require = await (async () => {
3
- var { createRequire } = await import("node:module");
4
- return createRequire(import.meta.url);
5
- })();
6
-
7
- import {
8
- require_out
9
- } from "./chunk-VZNKO4OO.js";
10
- import {
11
- encodeBlobKey
12
- } from "./chunk-TYCYFZ22.js";
13
- import {
14
- __toESM
15
- } from "./chunk-5JVNISGM.js";
16
-
17
- // src/build/content/prerendered.ts
18
- var import_fast_glob = __toESM(require_out(), 1);
19
- import { existsSync } from "node:fs";
20
- import { mkdir, readFile, writeFile } from "node:fs/promises";
21
- import { dirname, join } from "node:path";
22
- var writeCacheEntry = async (route, value, lastModified, ctx) => {
23
- const path = join(ctx.blobDir, await encodeBlobKey(route));
24
- const entry = JSON.stringify({
25
- lastModified,
26
- value
27
- });
28
- await mkdir(dirname(path), { recursive: true });
29
- await writeFile(path, entry, "utf-8");
30
- };
31
- var routeToFilePath = (path) => path === "/" ? "/index" : path;
32
- var buildPagesCacheValue = async (path) => ({
33
- kind: "PAGE",
34
- html: await readFile(`${path}.html`, "utf-8"),
35
- pageData: JSON.parse(await readFile(`${path}.json`, "utf-8")),
36
- postponed: void 0,
37
- headers: void 0,
38
- status: void 0
39
- });
40
- var buildAppCacheValue = async (path) => {
41
- const meta = JSON.parse(await readFile(`${path}.meta`, "utf-8"));
42
- const rsc = await readFile(`${path}.rsc`, "utf-8").catch(
43
- () => readFile(`${path}.prefetch.rsc`, "utf-8")
44
- );
45
- if (!meta.status && rsc.includes("NEXT_NOT_FOUND")) {
46
- meta.status = 404;
47
- }
48
- return {
49
- kind: "PAGE",
50
- html: await readFile(`${path}.html`, "utf-8"),
51
- pageData: rsc,
52
- ...meta
53
- };
54
- };
55
- var buildRouteCacheValue = async (path) => ({
56
- kind: "ROUTE",
57
- body: await readFile(`${path}.body`, "base64"),
58
- ...JSON.parse(await readFile(`${path}.meta`, "utf-8"))
59
- });
60
- var buildFetchCacheValue = async (path) => ({
61
- kind: "FETCH",
62
- ...JSON.parse(await readFile(path, "utf-8"))
63
- });
64
- var copyPrerenderedContent = async (ctx) => {
65
- try {
66
- const manifest = await ctx.getPrerenderManifest();
67
- await Promise.all(
68
- Object.entries(manifest.routes).map(async ([route, meta]) => {
69
- const lastModified = meta.initialRevalidateSeconds ? Date.now() - 31536e6 : Date.now();
70
- const key = routeToFilePath(route);
71
- let value;
72
- switch (true) {
73
- case (meta.dataRoute?.endsWith("/default.rsc") && !existsSync(join(ctx.publishDir, "server/app", `${key}.html`))):
74
- return;
75
- case meta.dataRoute?.endsWith(".json"):
76
- if (manifest.notFoundRoutes.includes(route)) {
77
- return;
78
- }
79
- value = await buildPagesCacheValue(join(ctx.publishDir, "server/pages", key));
80
- break;
81
- case meta.dataRoute?.endsWith(".rsc"):
82
- value = await buildAppCacheValue(join(ctx.publishDir, "server/app", key));
83
- break;
84
- case meta.dataRoute === null:
85
- value = await buildRouteCacheValue(join(ctx.publishDir, "server/app", key));
86
- break;
87
- default:
88
- throw new Error(`Unrecognized content: ${route}`);
89
- }
90
- await writeCacheEntry(key, value, lastModified, ctx);
91
- })
92
- );
93
- if (existsSync(join(ctx.publishDir, `server/app/_not-found.html`))) {
94
- const lastModified = Date.now();
95
- const key = "/404";
96
- const value = await buildAppCacheValue(join(ctx.publishDir, "server/app/_not-found"));
97
- await writeCacheEntry(key, value, lastModified, ctx);
98
- }
99
- } catch (error) {
100
- ctx.failBuild("Failed assembling prerendered content for upload", error);
101
- }
102
- };
103
- var copyFetchContent = async (ctx) => {
104
- try {
105
- const paths = await (0, import_fast_glob.glob)(["!(*.*)"], {
106
- cwd: join(ctx.publishDir, "cache/fetch-cache"),
107
- extglob: true
108
- });
109
- await Promise.all(
110
- paths.map(async (key) => {
111
- const lastModified = Date.now() - 31536e6;
112
- const path = join(ctx.publishDir, "cache/fetch-cache", key);
113
- const value = await buildFetchCacheValue(path);
114
- await writeCacheEntry(key, value, lastModified, ctx);
115
- })
116
- );
117
- } catch (error) {
118
- ctx.failBuild("Failed assembling fetch content for upload", error);
119
- }
120
- };
121
-
122
- export {
123
- copyPrerenderedContent,
124
- copyFetchContent
125
- };