mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import fs from "node:fs";
|
|
|
|
export function readAppRouterEntrySource(): string {
|
|
const sourceUrl = new URL("../packages/vinext/src/server/app-router-entry.ts", import.meta.url);
|
|
if (fs.existsSync(sourceUrl)) return fs.readFileSync(sourceUrl, "utf-8");
|
|
return fs.readFileSync(
|
|
new URL("../packages/vinext/src/server/app-router-entry.js", import.meta.url),
|
|
"utf-8",
|
|
);
|
|
}
|
|
|
|
export function readAppRequestStageEntrySource(): string {
|
|
const sourceUrl = new URL(
|
|
"../packages/vinext/src/server/app-request-stage-independent-entry.ts",
|
|
import.meta.url,
|
|
);
|
|
if (fs.existsSync(sourceUrl)) return fs.readFileSync(sourceUrl, "utf-8");
|
|
return fs.readFileSync(
|
|
new URL(
|
|
"../packages/vinext/src/server/app-request-stage-independent-entry.js",
|
|
import.meta.url,
|
|
),
|
|
"utf-8",
|
|
);
|
|
}
|
|
|
|
export function readPagesRouterEntrySource(): string {
|
|
return readPagesRequestStageEntrySource();
|
|
}
|
|
|
|
export function readPagesSingleEntrySource(): string {
|
|
const sourceUrl = new URL("../packages/vinext/src/server/pages-router-entry.ts", import.meta.url);
|
|
if (fs.existsSync(sourceUrl)) return fs.readFileSync(sourceUrl, "utf-8");
|
|
return fs.readFileSync(
|
|
new URL("../packages/vinext/src/server/pages-router-entry.js", import.meta.url),
|
|
"utf-8",
|
|
);
|
|
}
|
|
|
|
export function readPagesRequestStageEntrySource(): string {
|
|
const sourceUrl = new URL(
|
|
"../packages/vinext/src/server/pages-request-stage-entry.ts",
|
|
import.meta.url,
|
|
);
|
|
if (fs.existsSync(sourceUrl)) return fs.readFileSync(sourceUrl, "utf-8");
|
|
return fs.readFileSync(
|
|
new URL("../packages/vinext/src/server/pages-request-stage-entry.js", import.meta.url),
|
|
"utf-8",
|
|
);
|
|
}
|
|
|
|
export function readPagesResponseStageEntrySource(): string {
|
|
const sourceUrl = new URL(
|
|
"../packages/vinext/src/server/pages-response-stage-entry.ts",
|
|
import.meta.url,
|
|
);
|
|
if (fs.existsSync(sourceUrl)) return fs.readFileSync(sourceUrl, "utf-8");
|
|
return fs.readFileSync(
|
|
new URL("../packages/vinext/src/server/pages-response-stage-entry.js", import.meta.url),
|
|
"utf-8",
|
|
);
|
|
}
|