forked from jsnbuchanan/crowd-funder-for-time-pwa
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
This commit is contained in:
@@ -6,7 +6,6 @@ import path from "path";
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
// Load environment variables
|
// Load environment variables
|
||||||
console.log('NODE_ENV:', process.env.NODE_ENV)
|
|
||||||
dotenv.config({ path: `.env.${process.env.NODE_ENV}` })
|
dotenv.config({ path: `.env.${process.env.NODE_ENV}` })
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +52,22 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
|||||||
format: 'es',
|
format: 'es',
|
||||||
plugins: () => []
|
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: {
|
define: {
|
||||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||||
|
|||||||
@@ -135,7 +135,11 @@ export async function createOptimizedBuildConfig(mode: string): Promise<UserConf
|
|||||||
target: 'es2015',
|
target: 'es2015',
|
||||||
supported: {
|
supported: {
|
||||||
'bigint': true
|
'bigint': true
|
||||||
}
|
},
|
||||||
|
// Fail on any ESBuild errors
|
||||||
|
logLevel: 'error',
|
||||||
|
// Ensure build fails on syntax errors
|
||||||
|
logOverride: { 'duplicate-export': 'error' }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,4 +112,28 @@ export async function loadAppConfig(): Promise<AppConfig> {
|
|||||||
"dexie-export-import/dist/import/index.js",
|
"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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -94,6 +94,17 @@ export default defineConfig(async ({ mode }) => {
|
|||||||
'absurd-sql/dist/indexeddb-main-thread',
|
'absurd-sql/dist/indexeddb-main-thread',
|
||||||
'absurd-sql/dist/indexeddb-backend'
|
'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' }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user