From 0c37afd595454e44932a7d9fcc24c9c297e1e1bf Mon Sep 17 00:00:00 2001 From: Jonas Perusquia Morales Date: Tue, 14 Jul 2026 11:44:55 -0600 Subject: [PATCH] fix: Fix admin UI manifest loading in Cloudflare Workers Use static import so the bundler includes the manifest. Dynamic imports are not resolved by workerd via package.json exports. --- .../cloudflare/cloudflare-workers.adapter.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/adapter/cloudflare/cloudflare-workers.adapter.ts b/app/src/adapter/cloudflare/cloudflare-workers.adapter.ts index 98df2b06..7f54b1b7 100644 --- a/app/src/adapter/cloudflare/cloudflare-workers.adapter.ts +++ b/app/src/adapter/cloudflare/cloudflare-workers.adapter.ts @@ -8,6 +8,12 @@ import { $console } from "bknd/utils"; import { createRuntimeApp } from "bknd/adapter"; import { registerAsyncsExecutionContext, makeConfig, type CloudflareContext } from "./config"; +// Statically import the admin UI build manifest so the bundler (wrangler/esbuild) +// resolves and bundles it at build time, rather than leaving a runtime dynamic +// import that workerd cannot resolve via package.json exports maps. +// @ts-ignore +import adminUiManifest from "bknd/dist/manifest.json"; + declare global { namespace Cloudflare { interface Env {} @@ -38,6 +44,19 @@ export async function createApp( ctx: Partial> = {}, ) { const appConfig = await makeConfig(config, ctx); + + // The AdminController can't dynamically import "bknd/dist/manifest.json" + // at runtime in the Workers runtime (workerd ignores package.json exports + // for runtime imports). Statically import it here so esbuild bundles the + // manifest into the Worker and pass it as the admin controller's manifest + // unless the caller explicitly provides one (or disables the admin). + if (appConfig.adminOptions !== false && !(appConfig.adminOptions as any)?.manifest) { + appConfig.adminOptions = { + ...(appConfig.adminOptions as any), + manifest: adminUiManifest, + }; + } + return await createRuntimeApp( { ...appConfig,