Skip to content

Commit 1256946

Browse files
leobenzoladrien2p
andauthored
add generated .medusa/types to local plugins (medusajs#13777)
Co-authored-by: Adrien de Peretti <[email protected]>
1 parent fb11f0f commit 1256946

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

.changeset/wise-feet-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/medusa": patch
3+
---
4+
5+
feat(medusa): add generated .medusa/types to local plugins

packages/medusa/src/commands/start.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)