Skip to content

Commit 9e3eff2

Browse files
committed
add esbuild debug logging
1 parent dd97a5c commit 9e3eff2

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

esbuild.mjs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@ import {
55
nodeBaseConfig,
66
} from './build-scripts/esbuild-configs.mjs';
77

8+
console.log('=== esbuild.mjs starting ===');
9+
console.log('NODE_ENV:', process.env.NODE_ENV);
10+
console.log('Current directory:', process.cwd());
11+
console.log('Script file:', import.meta.url);
12+
813
async function buildAll() {
14+
console.log('buildAll() function called');
15+
console.log('Checking for dist directory...');
916
// Clean dist directory
10-
if (fs.existsSync('dist')) {
17+
console.log('Checking if dist exists...');
18+
const distExists = fs.existsSync('dist');
19+
console.log('dist exists:', distExists);
20+
if (distExists) {
21+
console.log('Removing dist directory...');
1122
fs.rmSync('dist', { recursive: true });
23+
console.log('dist removed successfully');
1224
}
1325

1426
const builds = [];
@@ -55,8 +67,26 @@ async function buildAll() {
5567
}
5668

5769
// Run build if called directly
58-
if (import.meta.url === `file://${process.argv[1]}`) {
59-
buildAll().catch(console.error);
70+
console.log('=== Checking if script should run ===');
71+
console.log('import.meta.url:', import.meta.url);
72+
console.log('process.argv[1]:', process.argv[1]);
73+
74+
// Convert process.argv[1] to a proper file URL for cross-platform compatibility
75+
import { pathToFileURL } from 'url';
76+
const scriptPath = pathToFileURL(process.argv[1]).href;
77+
console.log('Converted scriptPath:', scriptPath);
78+
console.log('Comparison:', import.meta.url === scriptPath);
79+
80+
if (import.meta.url === scriptPath) {
81+
console.log('Running buildAll()...');
82+
buildAll().catch((err) => {
83+
console.error('❌ Build failed with error:');
84+
console.error(err);
85+
process.exit(1);
86+
});
87+
} else {
88+
console.log('Script not run directly - skipping build');
89+
console.log('This should not happen when running: node esbuild.mjs');
6090
}
6191

6292
// Export configs for use by other scripts

0 commit comments

Comments
 (0)