Fix/load medusa proj (#6639)
**What** - Runs loadMedusaV2 when v2 flag is enabled. - V2 loader loads only project-level framework features. E.g., project APIs, subscribers, jobs, and workflows. - No plugin support yet.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
ModuleDefinition,
|
||||
ModuleExports,
|
||||
@@ -25,7 +26,11 @@ export const registerMedusaModule = (
|
||||
const modDefinition = definition ?? ModulesDefinition[moduleKey]
|
||||
|
||||
if (modDefinition === undefined) {
|
||||
throw new Error(`Module: ${moduleKey} is not defined.`)
|
||||
moduleResolutions[moduleKey] = getCustomModuleResolution(
|
||||
moduleKey,
|
||||
moduleDeclaration as InternalModuleDeclaration
|
||||
)
|
||||
return moduleResolutions
|
||||
}
|
||||
|
||||
const modDeclaration =
|
||||
@@ -53,6 +58,38 @@ export const registerMedusaModule = (
|
||||
return moduleResolutions
|
||||
}
|
||||
|
||||
function getCustomModuleResolution(
|
||||
key: string,
|
||||
moduleConfig: InternalModuleDeclaration | string
|
||||
): ModuleResolution {
|
||||
const isString = typeof moduleConfig === "string"
|
||||
const resolutionPath = resolveCwd(
|
||||
isString ? moduleConfig : (moduleConfig.resolve as string)
|
||||
)
|
||||
|
||||
return {
|
||||
resolutionPath,
|
||||
definition: {
|
||||
key,
|
||||
label: `Custom: ${key}`,
|
||||
isRequired: false,
|
||||
defaultPackage: "",
|
||||
dependencies: [],
|
||||
registrationName: key,
|
||||
defaultModuleDeclaration: {
|
||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||
scope: MODULE_SCOPE.INTERNAL,
|
||||
},
|
||||
},
|
||||
moduleDeclaration: {
|
||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||
scope: MODULE_SCOPE.INTERNAL,
|
||||
},
|
||||
dependencies: [],
|
||||
options: {},
|
||||
}
|
||||
}
|
||||
|
||||
export const registerMedusaLinkModule = (
|
||||
definition: ModuleDefinition,
|
||||
moduleDeclaration: Partial<InternalModuleDeclaration>,
|
||||
|
||||
Reference in New Issue
Block a user