Skip to content

Commit c9b8917

Browse files
committed
added some manifests
1 parent d0fda25 commit c9b8917

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

packages/open-next/src/adapters/config/util.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ export function loadBuildId(nextDir: string) {
2121
return fs.readFileSync(filePath, "utf-8").trim();
2222
}
2323

24-
export function loadHtmlPages(nextDir: string) {
24+
export function loadPagesManifest(nextDir: string) {
2525
const filePath = path.join(nextDir, "server/pages-manifest.json");
2626
const json = fs.readFileSync(filePath, "utf-8");
27-
return Object.entries(JSON.parse(json))
27+
return JSON.parse(json);
28+
}
29+
30+
export function loadHtmlPages(nextDir: string) {
31+
return Object.entries(loadPagesManifest(nextDir))
2832
.filter(([_, value]) => (value as string).endsWith(".html"))
2933
.map(([key]) => key);
3034
}

packages/open-next/src/build/copyTracedFiles.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ import {
1313
} from "node:fs";
1414
import path from "node:path";
1515

16-
import { loadConfig, loadPrerenderManifest } from "config/util.js";
16+
import {
17+
loadAppPathsManifest,
18+
loadBuildId,
19+
loadConfig,
20+
loadFunctionsConfigManifest,
21+
loadMiddlewareManifest,
22+
loadPagesManifest,
23+
loadPrerenderManifest,
24+
} from "config/util.js";
1725
import { getCrossPlatformPathRegex } from "utils/regex.js";
1826
import logger from "../logger.js";
1927
import { MIDDLEWARE_TRACE_FILE } from "./constant.js";
@@ -50,6 +58,19 @@ interface CopyTracedFilesOptions {
5058
skipServerFiles?: boolean;
5159
}
5260

61+
// TODO: add all the necessary manifests here
62+
function getManifests(nextDir: string) {
63+
return {
64+
buildId: loadBuildId(nextDir),
65+
config: loadConfig(nextDir),
66+
prerenderManifest: loadPrerenderManifest(nextDir),
67+
pagesManifest: loadPagesManifest(nextDir),
68+
appPathsManifest: loadAppPathsManifest(nextDir),
69+
middlewareManifest: loadMiddlewareManifest(nextDir),
70+
functionsConfigManifest: loadFunctionsConfigManifest(nextDir),
71+
};
72+
}
73+
5374
// eslint-disable-next-line sonarjs/cognitive-complexity
5475
export async function copyTracedFiles({
5576
buildOutputPath,
@@ -326,7 +347,6 @@ File ${fullFilePath} does not exist
326347

327348
return {
328349
tracedFiles: filesToCopy.values(),
329-
// TODO: actually return this
330-
manifests: {},
350+
manifests: getManifests(standaloneNextDir),
331351
};
332352
}

packages/open-next/src/build/createServerBundle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ async function generateBundle(
183183
{
184184
name: "fakePatchChunks",
185185
pathFilter: /chunks\/\d+\.js/,
186-
patchCode: async ({ code }) => {
186+
patchCode: async ({ code, manifests }) => {
187+
console.log(manifests);
187188
return `console.log("patched chunk");\n${code}`;
188189
},
189190
},

packages/open-next/src/plugins/content-updater.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { BuildOptions } from "../build/helper";
1212
import {
1313
type VersionedField,
1414
extractVersionedField,
15-
} from "../build/patch/codePatcher";
15+
} from "../build/patch/codePatcher.js";
1616

1717
/**
1818
* The callbacks returns either an updated content or undefined if the content is unchanged.
@@ -75,9 +75,11 @@ export class ContentUpdater {
7575
build.onLoad(
7676
{ filter: /\.(js|mjs|cjs|jsx|ts|tsx)$/ },
7777
async (args: OnLoadArgs) => {
78+
const updaters = Array.from(this.updaters.values()).flat();
79+
if (updaters.length === 0) {
80+
return;
81+
}
7882
let contents = await readFile(args.path, "utf-8");
79-
// biome-ignore lint/correctness/noFlatMapIdentity: <explanation>
80-
const updaters = this.updaters.values().flatMap((u) => u);
8183
for (const {
8284
filter,
8385
namespace,

0 commit comments

Comments
 (0)