fix(modules-sdk): Fix dynamic import usage (#9304)
* fix(modules-sdk): Fix dynamic import usage * missing new line
This commit is contained in:
@@ -17,7 +17,6 @@ import {
|
|||||||
dynamicImport,
|
dynamicImport,
|
||||||
MedusaModuleType,
|
MedusaModuleType,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
resolveExports,
|
|
||||||
toMikroOrmEntities,
|
toMikroOrmEntities,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asFunction, asValue } from "awilix"
|
import { asFunction, asValue } from "awilix"
|
||||||
@@ -264,9 +263,9 @@ async function importAllFromDir(path: string) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
await Promise.all(filesToLoad.map((filePath) => import(filePath)))
|
await Promise.all(filesToLoad.map((filePath) => dynamicImport(filePath)))
|
||||||
).flatMap((value) => {
|
).flatMap((value) => {
|
||||||
return Object.values(resolveExports(value))
|
return Object.values(value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,8 +286,8 @@ export async function loadResources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [moduleService, services, models, repositories] = await Promise.all([
|
const [moduleService, services, models, repositories] = await Promise.all([
|
||||||
import(modulePath).then((moduleExports) => {
|
dynamicImport(modulePath).then((moduleExports) => {
|
||||||
return resolveExports(moduleExports).default.service
|
return moduleExports.default.service
|
||||||
}),
|
}),
|
||||||
importAllFromDir(resolve(normalizedPath, "services")).catch(
|
importAllFromDir(resolve(normalizedPath, "services")).catch(
|
||||||
defaultOnFail
|
defaultOnFail
|
||||||
|
|||||||
Reference in New Issue
Block a user