From 8386804bbd4318cd4a5f8464a47b06cb15b17983 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Wed, 20 Aug 2025 02:29:09 +0000 Subject: [PATCH] feat(build): add comprehensive ESBuild error handling to Vite configurations - Add ESBuild logLevel: 'error' to all Vite configs - Configure logOverride for critical errors: duplicate-export, duplicate-member, syntax-error, invalid-identifier - Ensure builds fail immediately on ESBuild compilation errors - Apply to common, web, and optimized Vite configurations Prevents broken code from being deployed due to build-time errors --- vite.config.common.mts | 17 ++++++++++++++++- vite.config.optimized.mts | 6 +++++- vite.config.utils.mts | 24 ++++++++++++++++++++++++ vite.config.web.mts | 11 +++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/vite.config.common.mts b/vite.config.common.mts index f34e26d8..198f6ba3 100644 --- a/vite.config.common.mts +++ b/vite.config.common.mts @@ -6,7 +6,6 @@ import path from "path"; import { fileURLToPath } from 'url'; // Load environment variables -console.log('NODE_ENV:', process.env.NODE_ENV) dotenv.config({ path: `.env.${process.env.NODE_ENV}` }) @@ -53,6 +52,22 @@ export async function createBuildConfig(platform: string): Promise { format: 'es', plugins: () => [] }, + // ESBuild configuration to fail on errors + esbuild: { + target: 'es2015', + supported: { + 'bigint': true + }, + // Fail on any ESBuild errors + logLevel: 'error', + // Ensure build fails on syntax errors and other critical issues + logOverride: { + 'duplicate-export': 'error', + 'duplicate-member': 'error', + 'syntax-error': 'error', + 'invalid-identifier': 'error' + } + }, define: { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), diff --git a/vite.config.optimized.mts b/vite.config.optimized.mts index 5005ac5a..e9b4ee1d 100644 --- a/vite.config.optimized.mts +++ b/vite.config.optimized.mts @@ -135,7 +135,11 @@ export async function createOptimizedBuildConfig(mode: string): Promise { "dexie-export-import/dist/import/index.js", }, }; +} + +/** + * Shared ESBuild configuration that ensures builds fail on errors + */ +export function getStrictESBuildConfig() { + return { + target: 'es2015', + supported: { + 'bigint': true + }, + // Fail on any ESBuild errors + logLevel: 'error' as const, + // Ensure build fails on syntax errors and other critical issues + logOverride: { + 'duplicate-export': 'error', + 'duplicate-member': 'error', + 'syntax-error': 'error', + 'invalid-identifier': 'error' + }, + // Additional strict settings + keepNames: false, + minifyIdentifiers: false + }; } \ No newline at end of file diff --git a/vite.config.web.mts b/vite.config.web.mts index 79f5ec9c..0bbeb204 100644 --- a/vite.config.web.mts +++ b/vite.config.web.mts @@ -94,6 +94,17 @@ export default defineConfig(async ({ mode }) => { 'absurd-sql/dist/indexeddb-main-thread', 'absurd-sql/dist/indexeddb-backend' ] + }, + // ESBuild configuration to fail on errors + esbuild: { + target: 'es2015', + supported: { + 'bigint': true + }, + // Fail on any ESBuild errors + logLevel: 'error', + // Ensure build fails on syntax errors + logOverride: { 'duplicate-export': 'error' } } }); });