database/context.ts uses AsyncLocalStorage from node:async_hooks which is a Node.js-only API. Vite externalizes it for browser builds but the resulting error "AsyncLocalStorage is not exported by __vite-browser-external" caused npm run build to fail. Fix: add a Vite resolve.alias for the browser (non-SSR) build that maps ~/database/context to a browser-safe stub. The stub is never called at runtime since database() is only invoked in server-side loaders, but it allows the client bundle to build without errors. https://claude.ai/code/session_01Fjf9WFqNnuHmmC5yTedL7G Co-authored-by: Claude <noreply@anthropic.com>
9 lines
353 B
TypeScript
9 lines
353 B
TypeScript
// Browser-safe stub for database/context
|
|
// The real implementation uses Node.js AsyncLocalStorage which is server-only.
|
|
// This stub is used during the client build to avoid bundling server-only code.
|
|
|
|
export const DatabaseContext = null as any;
|
|
|
|
export function database(): never {
|
|
throw new Error("database() can only be called on the server");
|
|
}
|