33 *
44 * Bundles the Express app into a single Bun-native file.
55 * All JS/TS dependencies (including @compass/core) are inlined.
6- * Only native C/Rust modules are kept external and installed separately .
6+ * All dependencies are inlined .
77 *
88 * Usage:
99 * bun run build:backend
@@ -33,17 +33,13 @@ await $`rm -rf ${BACKEND_BUILD}`.quiet();
3333log . success ( "Removed old backend build" ) ;
3434
3535// 2. Bundle — full bundle so @compass/core and all JS/TS deps are inlined.
36- // Native modules (C/Rust binaries) must stay external and be installed below.
3736log . info ( "Bundling backend ..." ) ;
3837const result = await Bun . build ( {
3938 entrypoints : [ path . join ( COMPASS_ROOT_DEV , "packages/backend/src/app.ts" ) ] ,
4039 outdir : BACKEND_BUILD ,
4140 target : "bun" ,
4241 sourcemap : "inline" ,
4342 minify : false ,
44- external : [
45- "saslprep" , // MongoDB optional C binding
46- ] ,
4743} ) ;
4844
4945if ( ! result . success ) {
@@ -65,27 +61,14 @@ if (await Bun.file(configPath).exists()) {
6561 log . warning ( `Compass config file not found: ${ configPath } ` ) ;
6662}
6763
68- // 4. Write a minimal package.json for the external native modules only.
69- // Everything else is inlined in app.js — no full workspace needed.
70- const backendPkg = JSON . parse (
71- await Bun . file (
72- path . join ( COMPASS_ROOT_DEV , "packages/backend/package.json" ) ,
73- ) . text ( ) ,
74- ) as { dependencies ?: Record < string , string > } ;
75-
76- const externalVersions : Record < string , string > = { } ;
77- for ( const name of [ "saslprep" ] ) {
78- const version = backendPkg . dependencies ?. [ name ] ;
79- if ( version ) externalVersions [ name ] = version ;
80- }
81-
64+ // 4. Write a minimal package.json. Everything is inlined in app.js.
8265await Bun . write (
8366 path . join ( BACKEND_BUILD , "package.json" ) ,
84- JSON . stringify ( { dependencies : externalVersions } , null , 2 ) ,
67+ JSON . stringify ( { dependencies : { } } , null , 2 ) ,
8568) ;
8669
87- // 5. Install only the external native modules
88- log . info ( "Installing native module dependencies ..." ) ;
70+ // 5. Install an empty production dependency tree so Bun writes its runtime files.
71+ log . info ( "Installing production dependency metadata ..." ) ;
8972const install = Bun . spawnSync ( {
9073 cmd : [ "bun" , "install" , "--production" , "--ignore-scripts" , "--no-progress" ] ,
9174 cwd : BACKEND_BUILD ,
0 commit comments