@@ -244,7 +244,7 @@ export async function loadPluginModule(provider: string, basePath: string) {
244244 const importAsEsm = async ( spec : string ) => {
245245 try {
246246 const result = ( await import ( spec ) ) . default as CliPlugin ;
247- return result ;
247+ return typeof result ?. generate === 'function' ? result : undefined ;
248248 } catch ( err ) {
249249 throw new CliError ( `Failed to load plugin module from ${ spec } : ${ ( err as Error ) . message } ` ) ;
250250 }
@@ -254,7 +254,7 @@ export async function loadPluginModule(provider: string, basePath: string) {
254254 const importAsTs = async ( spec : string ) => {
255255 try {
256256 const result = ( await jiti . import ( spec , { default : true } ) ) as CliPlugin ;
257- return result ;
257+ return typeof result ?. generate === 'function' ? result : undefined ;
258258 } catch ( err ) {
259259 throw new CliError ( `Failed to load plugin module from ${ spec } : ${ ( err as Error ) . message } ` ) ;
260260 }
@@ -294,7 +294,7 @@ export async function loadPluginModule(provider: string, basePath: string) {
294294 // try jiti import for bare package specifiers (handles workspace packages)
295295 try {
296296 const result = ( await jiti . import ( moduleSpec , { default : true } ) ) as CliPlugin ;
297- return result ;
297+ return typeof result . generate === 'function' ? result : undefined ;
298298 } catch {
299299 // fall through to last resort
300300 }
@@ -303,7 +303,7 @@ export async function loadPluginModule(provider: string, basePath: string) {
303303 try {
304304 const mod = await import ( moduleSpec ) ;
305305 // plugin may not export a generator, return undefined in that case
306- return mod . default as CliPlugin | undefined ;
306+ return typeof mod . default ?. generate === 'function' ? ( mod . default as CliPlugin ) : undefined ;
307307 } catch ( err ) {
308308 const errorCode = ( err as NodeJS . ErrnoException ) ?. code ;
309309 if ( errorCode === 'ERR_MODULE_NOT_FOUND' || errorCode === 'MODULE_NOT_FOUND' ) {
0 commit comments