From 19d2a34f6a6a3fc4d4eb1a85cd4bd7c30a70ca02 Mon Sep 17 00:00:00 2001 From: i-trytoohard Date: Wed, 20 May 2026 18:19:28 +0530 Subject: [PATCH] fix(web): externalize ao-core and better-sqlite3 from Next.js bundle (#1944) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(web): externalize ao-core and better-sqlite3 from Next.js bundle Fixes #1930. Next.js bundles @aoagents/ao-core (via transpilePackages) and bakes import.meta.url as the build machine's absolute path into the output. At runtime on any other machine (especially Windows), createRequire() receives a non-existent file:// URL and fails. Adding @aoagents/ao-core and better-sqlite3 to serverExternalPackages tells Next.js to not bundle these — they're resolved at runtime from node_modules, so import.meta.url resolves to the actual install path. This fixes: - events-db.ts: createRequire(import.meta.url)("better-sqlite3") - update-cache.ts: createRequire(fileURLToPath(import.meta.url)) - The Windows ERR_INVALID_ARG_VALUE error in the user report * fix(web): move ao-core from transpilePackages to serverExternalPackages Next.js errors when a package is in both lists: 'transpilePackages' conflicts with 'serverExternalPackages' Remove @aoagents/ao-core from transpilePackages and keep it only in serverExternalPackages. This prevents webpack from bundling ao-core and baking import.meta.url as the build machine's path. --- packages/web/next.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web/next.config.js b/packages/web/next.config.js index 5923fedff..2639442dc 100644 --- a/packages/web/next.config.js +++ b/packages/web/next.config.js @@ -9,7 +9,6 @@ const homeDir = os.homedir().replace(/\\/g, "/"); const nextConfig = { outputFileTracingRoot: path.join(__dirname, "../.."), transpilePackages: [ - "@aoagents/ao-core", "@aoagents/ao-plugin-agent-claude-code", "@aoagents/ao-plugin-agent-codex", "@aoagents/ao-plugin-agent-opencode", @@ -22,6 +21,8 @@ const nextConfig = { serverExternalPackages: [ "yaml", "zod", + "@aoagents/ao-core", + "better-sqlite3", ], webpack: (config, { isServer }) => { if (process.platform === "win32") {