import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  output: "standalone",
  serverExternalPackages: [
    "@anthropic-ai/claude-agent-sdk",
    "@optage/sdk",
    "tree-sitter",
    "tree-sitter-java",
    "@msgpack/msgpack",
    "pg",
  ],
  webpack: (config, { isServer }) => {
    if (isServer) {
      // Server: externalize the SDK so Node.js requires it at runtime
      // (avoids webpack trying to parse tree-sitter native modules)
      config.externals = config.externals || [];
      if (Array.isArray(config.externals)) {
        config.externals.push("@optage/sdk");
      }
    }
    return config;
  },
};

export default nextConfig;
