Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wise-feet-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

feat(medusa): add generated .medusa/types to local plugins
43 changes: 26 additions & 17 deletions packages/medusa/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
dynamicImport,
FileSystem,
generateContainerTypes,
getResolvedPlugins,
gqlSchemaToTypes,
GracefulShutdownServer,
isFileSkipped,
Expand Down Expand Up @@ -234,28 +235,36 @@ async function start(args: {
})

if (generateTypes) {
const typesDirectory = path.join(directory, ".medusa/types")
const configModule = container.resolve(
ContainerRegistrationKeys.CONFIG_MODULE
)
const localPlugins = (await getResolvedPlugins(directory, configModule, true))
.filter((p) => p.admin?.type === "local")

/**
* Cleanup existing types directory before creating new artifacts
*/
await new FileSystem(typesDirectory).cleanup({ recursive: true })
for (const plugin of localPlugins) {
const typesDirectory = path.join(plugin.admin!.resolve, "../../.medusa/types")

await generateContainerTypes(modules, {
outputDir: typesDirectory,
interfaceName: "ModuleImplementations",
})
logger.debug("Generated container types")
/**
* Cleanup existing types directory before creating new artifacts
*/
await new FileSystem(typesDirectory).cleanup({ recursive: true })

if (gqlSchema) {
await gqlSchemaToTypes({
await generateContainerTypes(modules, {
outputDir: typesDirectory,
filename: "query-entry-points",
interfaceName: "RemoteQueryEntryPoints",
schema: gqlSchema,
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
interfaceName: "ModuleImplementations",
})
logger.debug("Generated modules types")
logger.debug("Generated container types")

if (gqlSchema) {
await gqlSchemaToTypes({
outputDir: typesDirectory,
filename: "query-entry-points",
interfaceName: "RemoteQueryEntryPoints",
schema: gqlSchema,
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
})
logger.debug("Generated modules types")
}
}
}

Expand Down
Loading