From 16ed9bf147fe98aad802b702aeafd47b87f0125e Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Fri, 27 Mar 2026 19:26:30 +0000 Subject: [PATCH] config: fall back to jiti for channel config surfaces --- scripts/load-channel-config-surface.ts | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts/load-channel-config-surface.ts b/scripts/load-channel-config-surface.ts index 30396938008..d658495371f 100644 --- a/scripts/load-channel-config-surface.ts +++ b/scripts/load-channel-config-surface.ts @@ -264,14 +264,25 @@ export async function loadChannelConfigSurfaceModule( }); return jiti(resolvedPath) as Record; }; + const loadFromPath = ( + candidatePath: string, + ): { schema: Record; uiHints?: Record } | null => { + try { + const bunLoaded = loadViaBun(candidatePath); + if (bunLoaded && isBuiltChannelConfigSchema(bunLoaded)) { + return bunLoaded; + } + } catch { + // Bun is the fastest happy path, but some plugin config modules only load + // correctly through the source-aware Jiti alias setup. + } + + const imported = loadViaJiti(candidatePath); + return resolveConfigSchemaExport(imported); + }; try { - const bunLoaded = loadViaBun(modulePath); - if (bunLoaded && isBuiltChannelConfigSchema(bunLoaded)) { - return bunLoaded; - } - const imported = loadViaJiti(modulePath); - return resolveConfigSchemaExport(imported); + return loadFromPath(modulePath); } catch (error) { if (!shouldRetryViaIsolatedCopy(error)) { throw error; @@ -279,12 +290,7 @@ export async function loadChannelConfigSurfaceModule( const isolatedCopy = copyModuleImportGraphWithoutNodeModules({ modulePath, repoRoot }); try { - const bunLoaded = loadViaBun(isolatedCopy.copiedModulePath); - if (bunLoaded && isBuiltChannelConfigSchema(bunLoaded)) { - return bunLoaded; - } - const imported = loadViaJiti(isolatedCopy.copiedModulePath); - return resolveConfigSchemaExport(imported); + return loadFromPath(isolatedCopy.copiedModulePath); } finally { isolatedCopy.cleanup(); }