compassmock/next.config.ts
Nicholai d5a28ee709
fix: extract useConversations hook to dedicated context file (#82)
* fix: extract useConversations hook to dedicated context file

Move the conversations context and hook from the layout file to
src/contexts/conversations-context.tsx. Next.js layouts cannot export
hooks or types - only the default component export is allowed.

* fix(build): prevent esbuild from bundling memory-provider

The memory-provider module imports better-sqlite3, a native Node.js
module that cannot run in Cloudflare Workers. This causes OpenNext
build failures when esbuild tries to resolve the module.

Changes:
- Use dynamically constructed import path to prevent static analysis
- Remove memory provider from getServerDb (never used on Cloudflare)
- Add memory-provider to serverExternalPackages in next.config.ts

* fix(lint): rename module variable to loadedModule

The variable name 'module' is reserved in Next.js and causes ESLint
error @next/next/no-assign-module-variable.

---------

Co-authored-by: Nicholai <nicholaivogelfilms@gmail.com>
2026-02-14 20:56:58 -07:00

34 lines
1.0 KiB
TypeScript
Executable File

import type { NextConfig } from "next";
const nextConfig: NextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
experimental: {
optimizePackageImports: [
"@tabler/icons-react",
"lucide-react",
"@radix-ui/react-icons",
"recharts",
"@workos-inc/node",
"date-fns",
"remeda",
"framer-motion",
],
},
// Node.js native modules that should not be bundled for edge/browser
// memory-provider imports better-sqlite3 which cannot run in Cloudflare Workers
serverExternalPackages: ["better-sqlite3", "./src/db/provider/memory-provider"],
};
export default nextConfig;
// Enable calling `getCloudflareContext()` in `next dev`.
// See https://opennext.js.org/cloudflare/bindings#local-access-to-bindings.
// Only init in dev -- build and lint don't need the wrangler proxy.
if (process.env.NODE_ENV === "development") {
import("@opennextjs/cloudflare").then((mod) =>
mod.initOpenNextCloudflareForDev()
);
}