Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(medusa, modules-sdk, modules): Module loading missing dependencies + remote query reference issue #5468

Merged
merged 8 commits into from
Oct 26, 2023
15 changes: 15 additions & 0 deletions .changeset/good-mails-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@medusajs/medusa": patch
"@medusajs/cache-inmemory": patch
"@medusajs/cache-redis": patch
"@medusajs/event-bus-local": patch
"@medusajs/event-bus-redis": patch
"@medusajs/inventory": patch
"@medusajs/link-modules": patch
"@medusajs/modules-sdk": patch
"@medusajs/pricing": patch
"@medusajs/product": patch
"@medusajs/stock-location": patch
---

fix(medusa, modules-sdk, modules): Module loading was missing the expected dependencies and remote query reference fix
13 changes: 7 additions & 6 deletions packages/cache-inmemory/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ export const initialize = async (
options?: InMemoryCacheModuleOptions | ExternalModuleDeclaration
): Promise<ICacheService> => {
const serviceKey = Modules.CACHE
const loaded = await MedusaModule.bootstrap<ICacheService>(
serviceKey,
"@medusajs/cache-inmemory",
options as InternalModuleDeclaration | ExternalModuleDeclaration,
undefined
)
const loaded = await MedusaModule.bootstrap<ICacheService>({
moduleKey: serviceKey,
defaultPath: "@medusajs/cache-inmemory",
declaration: options as
| InternalModuleDeclaration
| ExternalModuleDeclaration,
})

return loaded[serviceKey]
}
13 changes: 7 additions & 6 deletions packages/cache-redis/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ export const initialize = async (
options?: RedisCacheModuleOptions | ExternalModuleDeclaration
): Promise<ICacheService> => {
const serviceKey = Modules.CACHE
const loaded = await MedusaModule.bootstrap<ICacheService>(
serviceKey,
"@medusajs/cache-redis",
options as InternalModuleDeclaration | ExternalModuleDeclaration,
undefined
)
const loaded = await MedusaModule.bootstrap<ICacheService>({
moduleKey: serviceKey,
defaultPath: "@medusajs/cache-redis",
declaration: options as
| InternalModuleDeclaration
| ExternalModuleDeclaration,
})

return loaded[serviceKey]
}
8 changes: 4 additions & 4 deletions packages/event-bus-local/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { IEventBusService } from "@medusajs/types"

export const initialize = async (): Promise<IEventBusService> => {
const serviceKey = Modules.EVENT_BUS
const loaded = await MedusaModule.bootstrap<IEventBusService>(
serviceKey,
"@medusajs/event-bus-local"
)
const loaded = await MedusaModule.bootstrap<IEventBusService>({
moduleKey: serviceKey,
defaultPath: "@medusajs/event-bus-local",
})

return loaded[serviceKey]
}
13 changes: 7 additions & 6 deletions packages/event-bus-redis/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ export const initialize = async (
options?: EventBusRedisModuleOptions | ExternalModuleDeclaration
): Promise<IEventBusService> => {
const serviceKey = Modules.EVENT_BUS
const loaded = await MedusaModule.bootstrap<IEventBusService>(
serviceKey,
"@medusajs/event-bus-redis",
options as InternalModuleDeclaration | ExternalModuleDeclaration,
undefined
)
const loaded = await MedusaModule.bootstrap<IEventBusService>({
moduleKey: serviceKey,
defaultPath: "@medusajs/event-bus-redis",
declaration: options as
| InternalModuleDeclaration
| ExternalModuleDeclaration,
})

return loaded[serviceKey]
}
17 changes: 10 additions & 7 deletions packages/inventory/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ExternalModuleDeclaration,
InternalModuleDeclaration,
MedusaModule,
MODULE_PACKAGE_NAMES,
Modules,
} from "@medusajs/modules-sdk"
import { IEventBusService, IInventoryService } from "@medusajs/types"
Expand All @@ -15,13 +16,15 @@ export const initialize = async (
}
): Promise<IInventoryService> => {
const serviceKey = Modules.INVENTORY
const loaded = await MedusaModule.bootstrap<IInventoryService>(
serviceKey,
"@medusajs/inventory",
options as InternalModuleDeclaration | ExternalModuleDeclaration,
moduleDefinition,
injectedDependencies
)
const loaded = await MedusaModule.bootstrap<IInventoryService>({
moduleKey: serviceKey,
defaultPath: MODULE_PACKAGE_NAMES[Modules.INVENTORY],
declaration: options as
| InternalModuleDeclaration
| ExternalModuleDeclaration,
injectedDependencies,
moduleExports: moduleDefinition,
})

return loaded[serviceKey]
}
12 changes: 6 additions & 6 deletions packages/link-modules/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ export const initialize = async (
},
}

const loaded = await MedusaModule.bootstrapLink(
linkModuleDefinition,
options as InternalModuleDeclaration,
moduleDefinition,
injectedDependencies
)
const loaded = await MedusaModule.bootstrapLink({
definition: linkModuleDefinition,
declaration: options as InternalModuleDeclaration,
moduleExports: moduleDefinition,
injectedDependencies,
})

allLinks[serviceKey as string] = Object.values(loaded)[0]
}
Expand Down
1 change: 1 addition & 0 deletions packages/medusa/src/loaders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export default async ({
modulesConfig,
servicesConfig: joinerConfig,
remoteFetchData: remoteQueryFetchData(container),
sharedContainer: container,
injectedDependencies: {
[ContainerRegistrationKeys.PG_CONNECTION]: container.resolve(
ContainerRegistrationKeys.PG_CONNECTION
Expand Down
Loading