mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
d5392666ab
* feat(build): select adapter-owned worker stages * refactor(build): defer prerender entry resolver * fix(build): keep staged activation self-contained * fix(build): isolate every staged output member * fix(build): exclude custom client environments from stages * feat(build): publish selected worker stages * test(build): assert staged exports when published * fix(dev): keep multi-stage output build-only
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",
|
|
);
|
|
}
|