@@ -11,6 +11,7 @@ import {
1111 dynamicImport ,
1212 FileSystem ,
1313 generateContainerTypes ,
14+ getResolvedPlugins ,
1415 gqlSchemaToTypes ,
1516 GracefulShutdownServer ,
1617 isFileSkipped ,
@@ -272,28 +273,36 @@ async function start(args: {
272273 } )
273274
274275 if ( generateTypes ) {
275- const typesDirectory = path . join ( directory , ".medusa/types" )
276+ const configModule = container . resolve (
277+ ContainerRegistrationKeys . CONFIG_MODULE
278+ )
279+ const localPlugins = ( await getResolvedPlugins ( directory , configModule , true ) )
280+ . filter ( ( p ) => p . admin ?. type === "local" )
276281
277- /**
278- * Cleanup existing types directory before creating new artifacts
279- */
280- await new FileSystem ( typesDirectory ) . cleanup ( { recursive : true } )
282+ for ( const plugin of localPlugins ) {
283+ const typesDirectory = path . join ( plugin . admin ! . resolve , "../../.medusa/types" )
281284
282- await generateContainerTypes ( modules , {
283- outputDir : typesDirectory ,
284- interfaceName : "ModuleImplementations" ,
285- } )
286- logger . debug ( "Generated container types" )
285+ /**
286+ * Cleanup existing types directory before creating new artifacts
287+ */
288+ await new FileSystem ( typesDirectory ) . cleanup ( { recursive : true } )
287289
288- if ( gqlSchema ) {
289- await gqlSchemaToTypes ( {
290+ await generateContainerTypes ( modules , {
290291 outputDir : typesDirectory ,
291- filename : "query-entry-points" ,
292- interfaceName : "RemoteQueryEntryPoints" ,
293- schema : gqlSchema ,
294- joinerConfigs : MedusaModule . getAllJoinerConfigs ( ) ,
292+ interfaceName : "ModuleImplementations" ,
295293 } )
296- logger . debug ( "Generated modules types" )
294+ logger . debug ( "Generated container types" )
295+
296+ if ( gqlSchema ) {
297+ await gqlSchemaToTypes ( {
298+ outputDir : typesDirectory ,
299+ filename : "query-entry-points" ,
300+ interfaceName : "RemoteQueryEntryPoints" ,
301+ schema : gqlSchema ,
302+ joinerConfigs : MedusaModule . getAllJoinerConfigs ( ) ,
303+ } )
304+ logger . debug ( "Generated modules types" )
305+ }
297306 }
298307 }
299308
0 commit comments