@@ -34,6 +34,7 @@ export const serveCommand = new Command('serve')
3434 . description ( 'Start ObjectStack server with plugins from configuration' )
3535 . argument ( '[config]' , 'Configuration file path' , 'objectstack.config.ts' )
3636 . option ( '-p, --port <port>' , 'Server port' , '3000' )
37+ . option ( '--dev' , 'Run in development mode (load devPlugins)' )
3738 . option ( '--no-server' , 'Skip starting HTTP server plugin' )
3839 . action ( async ( configPath , options ) => {
3940 let port = parseInt ( options . port ) ;
@@ -90,14 +91,35 @@ export const serveCommand = new Command('serve')
9091 } ) ;
9192
9293 // Load plugins from configuration
93- const plugins = config . plugins || [ ] ;
94+ let plugins = config . plugins || [ ] ;
95+
96+ // Merge devPlugins if in dev mode
97+ if ( options . dev && config . devPlugins ) {
98+ console . log ( chalk . blue ( `📦 Loading development plugins...` ) ) ;
99+ plugins = [ ...plugins , ...config . devPlugins ] ;
100+ }
94101
95102 if ( plugins . length > 0 ) {
96103 console . log ( chalk . yellow ( `📦 Loading ${ plugins . length } plugin(s)...` ) ) ;
97104
98105 for ( const plugin of plugins ) {
99106 try {
100- kernel . use ( plugin ) ;
107+ let pluginToLoad = plugin ;
108+
109+ // Resolve string references (package names)
110+ if ( typeof plugin === 'string' ) {
111+ console . log ( chalk . dim ( ` Trying to resolve plugin: ${ plugin } ` ) ) ;
112+ try {
113+ // Try dynamic import for packages
114+ const imported = await import ( plugin ) ;
115+ pluginToLoad = imported . default || imported ;
116+ } catch ( importError : any ) {
117+ // Fallback: try bundleRequire for local paths if needed, otherwise throw
118+ throw new Error ( `Failed to import plugin '${ plugin } ': ${ importError . message } ` ) ;
119+ }
120+ }
121+
122+ kernel . use ( pluginToLoad ) ;
101123 const pluginName = plugin . name || plugin . constructor ?. name || 'unnamed' ;
102124 console . log ( chalk . green ( ` ✓ Registered plugin: ${ pluginName } ` ) ) ;
103125 } catch ( e : any ) {
0 commit comments