@@ -17,20 +17,47 @@ async function buildPackage(pkg: string): Promise<BuildResult> {
1717 const startTime = performance . now ( ) ;
1818 console . log ( `📦 Building @cortex/${ pkg } ...` ) ;
1919
20- const proc = Bun . spawn ( [ 'bun' , 'run' , 'build' ] , {
21- cwd : `./packages/${ pkg } ` ,
22- stdout : 'inherit' ,
23- stderr : 'inherit' ,
24- } ) ;
25-
26- const exitCode = await proc . exited ;
27- const duration = Math . round ( performance . now ( ) - startTime ) ;
28-
29- if ( exitCode !== 0 ) {
30- console . error ( `❌ Failed to build ${ pkg } (${ duration } ms)` ) ;
31- return { package : pkg , success : false , duration } ;
20+ // Special handling for VS Code extension bundling
21+ if ( pkg === 'vscode-extension' ) {
22+ try {
23+ // 1. Compile with tsc for type checking (optional but good)
24+ // 2. Bundle with Bun
25+ const result = await Bun . build ( {
26+ entrypoints : [ './packages/vscode-extension/src/extension.ts' ] ,
27+ outdir : './packages/vscode-extension/dist' ,
28+ target : 'node' ,
29+ external : [ 'vscode' , 'sql.js' ] , // vscode is provided by host, sql.js needs wasm handling
30+ minify : true ,
31+ sourcemap : 'external' ,
32+ } ) ;
33+
34+ if ( ! result . success ) {
35+ console . error ( result . logs ) ;
36+ return { package : pkg , success : false , duration : 0 } ;
37+ }
38+
39+ // Copy resources if needed (sql.js wasm?) - keeping simple for now
40+ } catch ( e ) {
41+ console . error ( e ) ;
42+ return { package : pkg , success : false , duration : 0 } ;
43+ }
44+ } else {
45+ // Standard build for other packages
46+ const proc = Bun . spawn ( [ 'bun' , 'run' , 'build' ] , {
47+ cwd : `./packages/${ pkg } ` ,
48+ stdout : 'inherit' ,
49+ stderr : 'inherit' ,
50+ } ) ;
51+
52+ const exitCode = await proc . exited ;
53+ if ( exitCode !== 0 ) {
54+ const duration = Math . round ( performance . now ( ) - startTime ) ;
55+ console . error ( `❌ Failed to build ${ pkg } (${ duration } ms)` ) ;
56+ return { package : pkg , success : false , duration } ;
57+ }
3258 }
3359
60+ const duration = Math . round ( performance . now ( ) - startTime ) ;
3461 console . log ( `✅ ${ pkg } built in ${ duration } ms\n` ) ;
3562 return { package : pkg , success : true , duration } ;
3663}
0 commit comments