feat(medusa, modules-sdk, types, utils): Re work modules loading and remove legacy functions (#5496)
This commit is contained in:
@@ -12,23 +12,24 @@ import {
|
||||
} from "../services"
|
||||
import getMigrations, { getModuleSharedResources } from "./utils/get-migrations"
|
||||
|
||||
import { ConfigModule } from "../types/global"
|
||||
import { CreateProductCategoryInput } from "../types/product-category"
|
||||
import { CreateProductInput } from "../types/product"
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import express from "express"
|
||||
import fs from "fs"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import { getConfigFile } from "medusa-core-utils"
|
||||
import { track } from "medusa-telemetry"
|
||||
import path from "path"
|
||||
import loaders from "../loaders"
|
||||
import { handleConfigError } from "../loaders/config"
|
||||
import featureFlagLoader from "../loaders/feature-flags"
|
||||
import IsolatePricingDomainFeatureFlag from "../loaders/feature-flags/isolate-pricing-domain"
|
||||
import Logger from "../loaders/logger"
|
||||
import PublishableApiKeyService from "../services/publishable-api-key"
|
||||
import { SalesChannel } from "../models"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import express from "express"
|
||||
import featureFlagLoader from "../loaders/feature-flags"
|
||||
import fs from "fs"
|
||||
import { getConfigFile } from "medusa-core-utils"
|
||||
import { handleConfigError } from "../loaders/config"
|
||||
import loaders from "../loaders"
|
||||
import path from "path"
|
||||
import { track } from "medusa-telemetry"
|
||||
import PublishableApiKeyService from "../services/publishable-api-key"
|
||||
import { ConfigModule } from "../types/global"
|
||||
import { CreateProductInput } from "../types/product"
|
||||
import { CreateProductCategoryInput } from "../types/product-category"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
|
||||
type SeedOptions = {
|
||||
directory: string
|
||||
@@ -122,7 +123,7 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) {
|
||||
"shippingProfileService"
|
||||
)
|
||||
const pricingModuleService: IPricingModuleService = container.resolve(
|
||||
"pricingModuleService"
|
||||
ModuleRegistrationName.PRICING
|
||||
)
|
||||
/* eslint-enable */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MedusaModule, registerModules } from "@medusajs/modules-sdk"
|
||||
import { MedusaModule, registerMedusaModule } from "@medusajs/modules-sdk"
|
||||
import fs from "fs"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import glob from "glob"
|
||||
@@ -96,8 +96,13 @@ function resolvePlugin(pluginName) {
|
||||
|
||||
export function getInternalModules(configModule) {
|
||||
const modules = []
|
||||
const moduleResolutions = {}
|
||||
|
||||
const moduleResolutions = registerModules(configModule.modules)
|
||||
Object.entries(configModule.modules ?? {}).forEach(([moduleKey, module]) => {
|
||||
moduleResolutions[moduleKey] = registerMedusaModule(moduleKey, module)[
|
||||
moduleKey
|
||||
]
|
||||
})
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
@@ -256,7 +261,12 @@ export const getModuleSharedResources = (configModule, featureFlagsRouter) => {
|
||||
}
|
||||
|
||||
export const runIsolatedModulesMigration = async (configModule) => {
|
||||
const moduleResolutions = registerModules(configModule.modules)
|
||||
const moduleResolutions = {}
|
||||
Object.entries(configModule.modules ?? {}).forEach(([moduleKey, module]) => {
|
||||
moduleResolutions[moduleKey] = registerMedusaModule(moduleKey, module)[
|
||||
moduleKey
|
||||
]
|
||||
})
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
@@ -276,7 +286,12 @@ export const runIsolatedModulesMigration = async (configModule) => {
|
||||
}
|
||||
|
||||
export const revertIsolatedModulesMigration = async (configModule) => {
|
||||
const moduleResolutions = registerModules(configModule.modules)
|
||||
const moduleResolutions = {}
|
||||
Object.entries(configModule.modules ?? {}).forEach(([moduleKey, module]) => {
|
||||
moduleResolutions[moduleKey] = registerMedusaModule(moduleKey, module)[
|
||||
moduleKey
|
||||
]
|
||||
})
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user