const nextConfig = {
  webpack: (config, { isServer }) => {
    config.cache = false; // Disable webpack cache to completely prevent stale chunk errors
    if (isServer) {
      config.externals = config.externals || [];
      config.externals.push('sql.js');
    }
    // sql.js needs to load the WASM file
    config.resolve.fallback = {
      ...config.resolve.fallback,
      fs: false,
      path: false,
      crypto: false,
    };
    return config;
  },
};

module.exports = nextConfig;
