diff --git a/dbal/development/src/blob/providers/s3-storage.ts b/dbal/development/src/blob/providers/s3-storage.ts index cabc0e7bc..8672dcdfb 100644 --- a/dbal/development/src/blob/providers/s3-storage.ts +++ b/dbal/development/src/blob/providers/s3-storage.ts @@ -31,10 +31,13 @@ export class S3Storage implements BlobStorage { private async initializeS3Client(s3Config: NonNullable) { try { - // Dynamic import to avoid bundling AWS SDK if not needed - const { S3Client } = await import('@aws-sdk/client-s3').catch(() => { - throw new Error('@aws-sdk/client-s3 is not installed. Install it to use S3 storage.') - }) + // Dynamic import to avoid bundling AWS SDK if not installed + // @ts-ignore - Optional dependency + const s3Module = await import('@aws-sdk/client-s3').catch(() => null) + if (!s3Module) { + throw new Error('@aws-sdk/client-s3 is not installed. Install it with: npm install @aws-sdk/client-s3') + } + const { S3Client } = s3Module this.s3Client = new S3Client({ region: s3Config.region, diff --git a/frontends/nextjs/next.config.ts b/frontends/nextjs/next.config.ts index a0f82cbcf..78a59cdd1 100644 --- a/frontends/nextjs/next.config.ts +++ b/frontends/nextjs/next.config.ts @@ -82,17 +82,19 @@ const nextConfig: NextConfig = { NEXT_PUBLIC_DBAL_WS_URL: process.env.DBAL_WS_URL || 'ws://localhost:50051', NEXT_PUBLIC_DBAL_API_KEY: process.env.DBAL_API_KEY || '', }, - webpack(config) { + webpack(config, { isServer }) { config.resolve.alias = { ...config.resolve.alias, '@/dbal': path.resolve(__dirname, '../../dbal/development/src'), '@dbal-ui': path.resolve(__dirname, '../../dbal/shared/ui'), } - // Mark optional dependencies as external to avoid build errors - config.externals = config.externals || [] - if (Array.isArray(config.externals)) { - config.externals.push('@aws-sdk/client-s3') + // Ignore optional AWS SDK on client side + if (!isServer) { + config.resolve.fallback = { + ...config.resolve.fallback, + '@aws-sdk/client-s3': false, + } } return config