@@ -90,9 +90,12 @@ async function bootstrapSingle(): Promise<BootstrapResult> {
9090 // apps/plugins it references. A schema drift in one of the examples
9191 // shouldn't crash multi-project boots (or the E2E test harness) when
9292 // they don't need those bundles at all.
93- const dyn = ( spec : string ) =>
94- ( new Function ( 's' , 'return import(s)' ) as ( s : string ) => Promise < any > ) ( spec ) ;
95- const stackConfig = ( await dyn ( '../objectstack.config.ts' ) ) . default ;
93+ //
94+ // Use a proper dynamic import (not Function constructor) so esbuild can
95+ // bundle the config into the Vercel handler. The Function constructor
96+ // bypasses static analysis and prevents bundling, causing runtime errors
97+ // when the source .ts file isn't deployed.
98+ const stackConfig = ( await import ( '../objectstack.config.js' ) ) . default ;
9699
97100 if ( ! stackConfig . plugins || stackConfig . plugins . length === 0 ) {
98101 throw new Error ( '[Bootstrap] No plugins found in stackConfig' ) ;
@@ -214,17 +217,15 @@ async function bootstrapMultiProject(
214217 if ( process . env . OBJECTSTACK_BUNDLE_EXAMPLES !== 'true' ) {
215218 return [ ] ;
216219 }
217- // Dynamic `new Function('return import(...)')(…)` sidesteps
218- // TypeScript's static rootDir analysis — the example configs
219- // live outside apps/server's tsconfig rootDir but are still
220- // resolvable at runtime. Kept here intentionally so the tsc
221- // typecheck doesn't need a dedicated include for examples.
222- const dyn = ( spec : string ) =>
223- ( new Function ( 's' , 'return import(s)' ) as ( s : string ) => Promise < any > ) ( spec ) ;
220+ // Use proper dynamic imports so esbuild can bundle the example configs.
221+ // The Function constructor would bypass static analysis and prevent
222+ // bundling, causing runtime errors when source .ts files aren't
223+ // deployed. esbuild will inline these imports even though they're
224+ // outside the apps/server directory.
224225 const [ crm , todo , bi ] = await Promise . all ( [
225- dyn ( '../../../examples/app-crm/objectstack.config.ts ' ) ,
226- dyn ( '../../../examples/app-todo/objectstack.config.ts ' ) ,
227- dyn ( '../../../examples/plugin-bi/objectstack.config.ts ' ) ,
226+ import ( '../../../examples/app-crm/objectstack.config.js ' ) ,
227+ import ( '../../../examples/app-todo/objectstack.config.js ' ) ,
228+ import ( '../../../examples/plugin-bi/objectstack.config.js ' ) ,
228229 ] ) ;
229230 return [ crm . default , todo . default , bi . default ] ;
230231 } ,
0 commit comments