@netlify/plugin-nextjs 5.0.0-rc.5 → 5.0.0-rc.7
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 +2 -0
- package/dist/build/content/next-shims/telemetry-storage.cjs +55 -0
- package/dist/build/content/prerendered.js +3 -1
- package/dist/build/content/server.js +5 -1
- package/dist/build/content/static.js +3 -1
- package/dist/build/functions/server.js +4 -2
- package/dist/build/templates/handler-monorepo.tmpl.js +20 -14
- package/dist/build/templates/handler.tmpl.js +19 -14
- package/dist/esm-chunks/chunk-4635LKT6.js +244 -0
- package/dist/esm-chunks/{chunk-W7XTKMHH.js → chunk-757FQQND.js} +56 -44
- package/dist/esm-chunks/chunk-GV3YIJ33.js +110 -0
- package/dist/esm-chunks/{chunk-637Y3P2U.js → chunk-M2ZKGJAI.js} +1 -2
- package/dist/esm-chunks/chunk-PDPDW32D.js +89 -0
- package/dist/esm-chunks/{chunk-GQ6KIYPX.js → chunk-Y3K5Q6FP.js} +13 -12
- package/dist/esm-chunks/chunk-YSGPGDIG.js +278 -0
- package/dist/esm-chunks/{package-67C5TREY.js → package-NR7AMHPP.js} +3 -3
- package/dist/index.js +52 -32
- package/dist/run/handlers/cache.cjs +48 -842
- package/dist/run/handlers/request-context.cjs +4 -2
- package/dist/run/handlers/server.js +31 -35
- package/dist/run/handlers/tracer.cjs +927 -0
- package/dist/run/handlers/tracing.js +75 -78
- package/dist/run/headers.js +1 -1
- package/dist/run/next.cjs +6 -767
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-CSTSA3JJ.js +0 -217
- package/dist/esm-chunks/chunk-VSH4JS2L.js +0 -125
- package/dist/esm-chunks/chunk-WFVNEURA.js +0 -94
package/package.json
CHANGED
|
@@ -1,217 +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
|
-
verifyNextVersion
|
|
12
|
-
} from "./chunk-MGPEWDDD.js";
|
|
13
|
-
import {
|
|
14
|
-
RUN_CONFIG
|
|
15
|
-
} from "./chunk-UYKENJEU.js";
|
|
16
|
-
import {
|
|
17
|
-
__toESM
|
|
18
|
-
} from "./chunk-5JVNISGM.js";
|
|
19
|
-
|
|
20
|
-
// src/build/content/server.ts
|
|
21
|
-
var import_fast_glob = __toESM(require_out(), 1);
|
|
22
|
-
import { existsSync } from "node:fs";
|
|
23
|
-
import {
|
|
24
|
-
cp,
|
|
25
|
-
mkdir,
|
|
26
|
-
readFile,
|
|
27
|
-
readdir,
|
|
28
|
-
readlink,
|
|
29
|
-
symlink,
|
|
30
|
-
writeFile,
|
|
31
|
-
access
|
|
32
|
-
} from "node:fs/promises";
|
|
33
|
-
import { createRequire } from "node:module";
|
|
34
|
-
import { dirname, join, resolve, sep } from "node:path";
|
|
35
|
-
import { sep as posixSep, join as posixJoin } from "node:path/posix";
|
|
36
|
-
var toPosixPath = (path) => path.split(sep).join(posixSep);
|
|
37
|
-
function isError(error) {
|
|
38
|
-
return error instanceof Error;
|
|
39
|
-
}
|
|
40
|
-
var copyNextServerCode = async (ctx) => {
|
|
41
|
-
const reqServerFilesPath = join(
|
|
42
|
-
ctx.standaloneRootDir,
|
|
43
|
-
ctx.relativeAppDir,
|
|
44
|
-
ctx.requiredServerFiles.config.distDir,
|
|
45
|
-
"required-server-files.json"
|
|
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
|
-
}
|
|
58
|
-
const reqServerFiles = JSON.parse(await readFile(reqServerFilesPath, "utf-8"));
|
|
59
|
-
if (toPosixPath(ctx.distDir).replace(new RegExp(`^${ctx.relativeAppDir}/?`), "") !== reqServerFiles.config.distDir) {
|
|
60
|
-
reqServerFiles.config.distDir = ctx.nextDistDir;
|
|
61
|
-
await writeFile(reqServerFilesPath, JSON.stringify(reqServerFiles));
|
|
62
|
-
}
|
|
63
|
-
await mkdir(ctx.serverHandlerDir, { recursive: true });
|
|
64
|
-
await writeFile(
|
|
65
|
-
join(ctx.serverHandlerDir, RUN_CONFIG),
|
|
66
|
-
JSON.stringify(reqServerFiles.config),
|
|
67
|
-
"utf-8"
|
|
68
|
-
);
|
|
69
|
-
const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
|
|
70
|
-
const nextFolder = toPosixPath(ctx.distDir) === toPosixPath(ctx.buildConfig.distDir) ? ctx.distDir : ctx.nextDistDir;
|
|
71
|
-
const destDir = join(ctx.serverHandlerDir, nextFolder);
|
|
72
|
-
const paths = await (0, import_fast_glob.default)(
|
|
73
|
-
[`*`, `server/*`, `server/chunks/*`, `server/edge-chunks/*`, `server/+(app|pages)/**/*.js`],
|
|
74
|
-
{
|
|
75
|
-
cwd: srcDir,
|
|
76
|
-
extglob: true
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
await Promise.all(
|
|
80
|
-
paths.map(async (path) => {
|
|
81
|
-
const srcPath = join(srcDir, path);
|
|
82
|
-
const destPath = join(destDir, path);
|
|
83
|
-
if (path === "server/middleware-manifest.json") {
|
|
84
|
-
try {
|
|
85
|
-
await replaceMiddlewareManifest(srcPath, destPath);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
throw new Error("Could not patch middleware manifest file", { cause: error });
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
await cp(srcPath, destPath, { recursive: true, force: true });
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
async function recreateNodeModuleSymlinks(src, dest, org) {
|
|
96
|
-
const dirents = await readdir(join(src, org || ""), { withFileTypes: true });
|
|
97
|
-
await Promise.all(
|
|
98
|
-
dirents.map(async (dirent) => {
|
|
99
|
-
if (dirent.name.startsWith("@")) {
|
|
100
|
-
return recreateNodeModuleSymlinks(src, dest, dirent.name);
|
|
101
|
-
}
|
|
102
|
-
if (dirent.isSymbolicLink()) {
|
|
103
|
-
const symlinkSrc = join(dest, org || "", dirent.name);
|
|
104
|
-
const symlinkTarget = await readlink(join(src, org || "", dirent.name));
|
|
105
|
-
const symlinkDest = join(dest, org || "", symlinkTarget);
|
|
106
|
-
if (existsSync(symlinkDest) && !existsSync(symlinkSrc)) {
|
|
107
|
-
if (org) {
|
|
108
|
-
await mkdir(join(dest, org), { recursive: true });
|
|
109
|
-
}
|
|
110
|
-
await symlink(symlinkTarget, symlinkSrc);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
var copyNextDependencies = async (ctx) => {
|
|
117
|
-
const entries = await readdir(ctx.standaloneDir);
|
|
118
|
-
const promises = entries.map(async (entry) => {
|
|
119
|
-
if (entry === "package.json" || entry === ctx.nextDistDir) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const src = join(ctx.standaloneDir, entry);
|
|
123
|
-
const dest = join(ctx.serverHandlerDir, entry);
|
|
124
|
-
await cp(src, dest, { recursive: true, verbatimSymlinks: true, force: true });
|
|
125
|
-
if (entry === "node_modules") {
|
|
126
|
-
await recreateNodeModuleSymlinks(ctx.resolveFromSiteDir("node_modules"), dest);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
const rootSrcDir = join(ctx.standaloneRootDir, "node_modules");
|
|
130
|
-
const rootDestDir = join(ctx.serverHandlerRootDir, "node_modules");
|
|
131
|
-
if (existsSync(rootSrcDir) && ctx.standaloneRootDir !== ctx.standaloneDir) {
|
|
132
|
-
promises.push(
|
|
133
|
-
cp(rootSrcDir, rootDestDir, { recursive: true, verbatimSymlinks: true }).then(
|
|
134
|
-
() => recreateNodeModuleSymlinks(resolve("node_modules"), rootDestDir)
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
await Promise.all(promises);
|
|
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
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const nextEntryAbsolutePath = serverHandlerRequire.resolve("next");
|
|
153
|
-
const nextRequire = createRequire(nextEntryAbsolutePath);
|
|
154
|
-
nextRequire.resolve("styled-jsx");
|
|
155
|
-
} catch {
|
|
156
|
-
throw new Error(
|
|
157
|
-
"node_modules are not installed correctly, if you are using pnpm please set the public hoist pattern to: `public-hoist-pattern[]=*`.\nRefer to your docs for more details: https://docs.netlify.com/integrations/frameworks/next-js/overview/#pnpm-support"
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
var writeTagsManifest = async (ctx) => {
|
|
162
|
-
const manifest = await ctx.getPrerenderManifest();
|
|
163
|
-
const routes = Object.entries(manifest.routes).map(async ([route, definition]) => {
|
|
164
|
-
let tags;
|
|
165
|
-
if (definition.dataRoute?.endsWith(".rsc")) {
|
|
166
|
-
const path = join(ctx.publishDir, `server/app/${route === "/" ? "/index" : route}.meta`);
|
|
167
|
-
try {
|
|
168
|
-
const file = await readFile(path, "utf-8");
|
|
169
|
-
const meta = JSON.parse(file);
|
|
170
|
-
tags = meta.headers["x-next-cache-tags"];
|
|
171
|
-
} catch {
|
|
172
|
-
if (!definition.dataRoute?.endsWith("/default.rsc")) {
|
|
173
|
-
console.log(`Unable to read cache tags for: ${path}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (definition.dataRoute?.endsWith(".json")) {
|
|
178
|
-
tags = `_N_T_${route}`;
|
|
179
|
-
}
|
|
180
|
-
if (definition.dataRoute === null) {
|
|
181
|
-
tags = definition.initialHeaders?.["x-next-cache-tags"];
|
|
182
|
-
}
|
|
183
|
-
return [route, tags];
|
|
184
|
-
});
|
|
185
|
-
await writeFile(
|
|
186
|
-
join(ctx.serverHandlerDir, ".netlify/tags-manifest.json"),
|
|
187
|
-
JSON.stringify(Object.fromEntries(await Promise.all(routes))),
|
|
188
|
-
"utf-8"
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
var replaceMiddlewareManifest = async (sourcePath, destPath) => {
|
|
192
|
-
await mkdir(dirname(destPath), { recursive: true });
|
|
193
|
-
const data = await readFile(sourcePath, "utf8");
|
|
194
|
-
const manifest = JSON.parse(data);
|
|
195
|
-
const newManifest = {
|
|
196
|
-
...manifest,
|
|
197
|
-
middleware: {}
|
|
198
|
-
};
|
|
199
|
-
const newData = JSON.stringify(newManifest);
|
|
200
|
-
await writeFile(destPath, newData);
|
|
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
|
-
};
|
|
211
|
-
|
|
212
|
-
export {
|
|
213
|
-
copyNextServerCode,
|
|
214
|
-
copyNextDependencies,
|
|
215
|
-
writeTagsManifest,
|
|
216
|
-
verifyHandlerDirStructure
|
|
217
|
-
};
|
|
@@ -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
|
-
};
|
|
@@ -1,94 +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/static.ts
|
|
18
|
-
var import_fast_glob = __toESM(require_out(), 1);
|
|
19
|
-
import { existsSync } from "node:fs";
|
|
20
|
-
import { cp, mkdir, rename, rm } from "node:fs/promises";
|
|
21
|
-
import { basename, join } from "node:path";
|
|
22
|
-
var copyStaticContent = async (ctx) => {
|
|
23
|
-
const srcDir = join(ctx.publishDir, "server/pages");
|
|
24
|
-
const destDir = ctx.blobDir;
|
|
25
|
-
const paths = await (0, import_fast_glob.default)("**/*.+(html|json)", {
|
|
26
|
-
cwd: srcDir,
|
|
27
|
-
extglob: true
|
|
28
|
-
});
|
|
29
|
-
try {
|
|
30
|
-
await Promise.all(
|
|
31
|
-
paths.filter((path) => !paths.includes(`${path.slice(0, -5)}.json`)).map(async (path) => {
|
|
32
|
-
await cp(join(srcDir, path), join(destDir, await encodeBlobKey(path)), {
|
|
33
|
-
recursive: true,
|
|
34
|
-
force: true
|
|
35
|
-
});
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
ctx.failBuild("Failed assembling static pages for upload", error);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var copyStaticAssets = async (ctx) => {
|
|
43
|
-
try {
|
|
44
|
-
await rm(ctx.staticDir, { recursive: true, force: true });
|
|
45
|
-
const { basePath } = await ctx.getRoutesManifest();
|
|
46
|
-
if (existsSync(ctx.resolveFromSiteDir("public"))) {
|
|
47
|
-
await cp(ctx.resolveFromSiteDir("public"), join(ctx.staticDir, basePath), {
|
|
48
|
-
recursive: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (existsSync(join(ctx.publishDir, "static"))) {
|
|
52
|
-
await cp(join(ctx.publishDir, "static"), join(ctx.staticDir, basePath, "_next/static"), {
|
|
53
|
-
recursive: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
} catch (error) {
|
|
57
|
-
ctx.failBuild("Failed copying static assets", error);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var copyStaticExport = async (ctx) => {
|
|
61
|
-
try {
|
|
62
|
-
await rm(ctx.staticDir, { recursive: true, force: true });
|
|
63
|
-
await cp(ctx.resolveFromSiteDir("out"), ctx.staticDir, { recursive: true });
|
|
64
|
-
} catch (error) {
|
|
65
|
-
ctx.failBuild("Failed copying static export", error);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var publishStaticDir = async (ctx) => {
|
|
69
|
-
try {
|
|
70
|
-
await rm(ctx.tempPublishDir, { recursive: true, force: true });
|
|
71
|
-
await mkdir(basename(ctx.tempPublishDir), { recursive: true });
|
|
72
|
-
await rename(ctx.publishDir, ctx.tempPublishDir);
|
|
73
|
-
await rename(ctx.staticDir, ctx.publishDir);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
ctx.failBuild("Failed publishing static content", error instanceof Error ? { error } : {});
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
var unpublishStaticDir = async (ctx) => {
|
|
79
|
-
try {
|
|
80
|
-
if (existsSync(ctx.tempPublishDir)) {
|
|
81
|
-
await rename(ctx.publishDir, ctx.staticDir);
|
|
82
|
-
await rename(ctx.tempPublishDir, ctx.publishDir);
|
|
83
|
-
}
|
|
84
|
-
} catch {
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
copyStaticContent,
|
|
90
|
-
copyStaticAssets,
|
|
91
|
-
copyStaticExport,
|
|
92
|
-
publishStaticDir,
|
|
93
|
-
unpublishStaticDir
|
|
94
|
-
};
|