Config: stabilize bundled channel metadata loading

This commit is contained in:
Onur Solmaz
2026-04-13 00:26:44 +02:00
parent b2f94d9bb8
commit 4503a43b90
3 changed files with 401 additions and 284 deletions

View File

@@ -281,17 +281,23 @@ export async function loadChannelConfigSurfaceModule(
candidatePath: string,
): { schema: Record<string, unknown>; uiHints?: Record<string, unknown> } | null => {
try {
const bunLoaded = loadViaBun(candidatePath);
if (bunLoaded && isBuiltChannelConfigSchema(bunLoaded)) {
return bunLoaded;
// Prefer the source-aware Jiti path so generated config metadata stays
// stable before and after build output exists in the repo.
const imported = loadViaJiti(candidatePath);
const resolved = resolveConfigSchemaExport(imported);
if (resolved) {
return resolved;
}
} catch {
// Bun is the fastest happy path, but some plugin config modules only load
// correctly through the source-aware Jiti alias setup.
// Fall back to Bun below when the source-aware loader cannot resolve the
// module graph in the current environment.
}
const imported = loadViaJiti(candidatePath);
return resolveConfigSchemaExport(imported);
const bunLoaded = loadViaBun(candidatePath);
if (bunLoaded && isBuiltChannelConfigSchema(bunLoaded)) {
return bunLoaded;
}
return null;
};
try {