test: prove TechLog UI migration parity
This commit is contained in:
@@ -21,13 +21,12 @@ import {
|
||||
} from "./lib/build-environment.ts";
|
||||
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
|
||||
import { CANONICAL_VITE_MANIFEST_PATH } from "./lib/build-manifest-outputs.ts";
|
||||
import {
|
||||
findViteDynamicRouteChunk,
|
||||
type ViteManifestRouteEntry,
|
||||
} from "./lib/vite-route-chunks.ts";
|
||||
|
||||
assertCiBuildEnvironment(process.env);
|
||||
type ViteManifestEntry = Readonly<{
|
||||
file: string;
|
||||
name?: string;
|
||||
isDynamicEntry?: boolean;
|
||||
}>;
|
||||
|
||||
const packageJson = parsePackageMetadata(
|
||||
JSON.parse(await readFile("package.json", "utf8")),
|
||||
@@ -63,9 +62,9 @@ const runtimeContracts: Readonly<Record<string, { moduleId: string }>> =
|
||||
ROUTE_RUNTIME_CONTRACT;
|
||||
for (const definition of Object.values(ROUTE_REGISTRY)) {
|
||||
const runtime = runtimeContracts[definition.routeId];
|
||||
const asset = Object.values(viteManifestObject).find(
|
||||
(entry) => entry.name === runtime?.moduleId && entry.isDynamicEntry,
|
||||
);
|
||||
const asset = runtime
|
||||
? findViteDynamicRouteChunk(viteManifestObject, runtime.moduleId)
|
||||
: undefined;
|
||||
if (!runtime || !asset?.file) {
|
||||
throw new Error(`Missing built route chunk: ${definition.routeId}`);
|
||||
}
|
||||
@@ -163,9 +162,9 @@ function parsePackageMetadata(value: unknown): Readonly<{
|
||||
|
||||
function parseViteManifest(
|
||||
value: unknown,
|
||||
): Readonly<Record<string, ViteManifestEntry>> {
|
||||
): Readonly<Record<string, ViteManifestRouteEntry>> {
|
||||
if (!isRecord(value)) throw new TypeError("Vite manifest must be an object");
|
||||
const entries: Record<string, ViteManifestEntry> = {};
|
||||
const entries: Record<string, ViteManifestRouteEntry> = {};
|
||||
for (const [key, candidate] of Object.entries(value)) {
|
||||
if (!isRecord(candidate) || typeof candidate.file !== "string") {
|
||||
throw new TypeError(`Invalid Vite manifest entry: ${key}`);
|
||||
@@ -176,6 +175,10 @@ function parseViteManifest(
|
||||
...(typeof candidate.isDynamicEntry === "boolean"
|
||||
? { isDynamicEntry: candidate.isDynamicEntry }
|
||||
: {}),
|
||||
...(Array.isArray(candidate.dynamicImports) &&
|
||||
candidate.dynamicImports.every((item) => typeof item === "string")
|
||||
? { dynamicImports: candidate.dynamicImports as string[] }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
return entries;
|
||||
|
||||
Reference in New Issue
Block a user