diff --git a/packages/core/utils/src/common/__tests__/define-config.spec.ts b/packages/core/utils/src/common/__tests__/define-config.spec.ts index 7a6b4b6ac6..c57e54a9ce 100644 --- a/packages/core/utils/src/common/__tests__/define-config.spec.ts +++ b/packages/core/utils/src/common/__tests__/define-config.spec.ts @@ -1,3 +1,4 @@ +import { Modules } from "../../modules-sdk" import { defineConfig } from "../define-config" describe("defineConfig", function () { @@ -256,4 +257,93 @@ describe("defineConfig", function () { } `) }) + + it("should not include disabled modules", function () { + expect( + defineConfig({ + projectConfig: { + http: { + adminCors: "http://localhost:3000", + } as any, + }, + modules: { + [Modules.CART]: false, + }, + }) + ).toMatchInlineSnapshot(` + { + "admin": { + "backendUrl": "http://localhost:9000", + }, + "featureFlags": {}, + "modules": { + "apiKey": true, + "auth": true, + "cacheService": true, + "currency": true, + "customer": true, + "eventBus": true, + "file": { + "options": { + "providers": [ + { + "options": { + "config": { + "local": {}, + }, + }, + "resolve": "@medusajs/file-local-next", + }, + ], + }, + "resolve": "@medusajs/file", + }, + "fulfillment": { + "options": { + "providers": [ + { + "options": { + "config": { + "manual": {}, + }, + }, + "resolve": "@medusajs/fulfillment-manual", + }, + ], + }, + "resolve": "@medusajs/fulfillment", + }, + "inventoryService": true, + "order": true, + "payment": true, + "pricingService": true, + "productService": true, + "promotion": true, + "region": true, + "salesChannel": true, + "stockLocationService": true, + "store": true, + "tax": true, + "user": { + "options": { + "jwt_secret": "supersecret", + }, + "resolve": "@medusajs/user", + }, + "workflows": true, + }, + "plugins": [], + "projectConfig": { + "databaseUrl": "postgres://localhost/medusa-starter-default", + "http": { + "adminCors": "http://localhost:3000", + "authCors": "http://localhost:7000,http://localhost:7001,http://localhost:5173", + "cookieSecret": "supersecret", + "jwtSecret": "supersecret", + "storeCors": "http://localhost:8000", + }, + }, + } + `) + }) }) diff --git a/packages/core/utils/src/common/define-config.ts b/packages/core/utils/src/common/define-config.ts index ca6e875898..54f7d851af 100644 --- a/packages/core/utils/src/common/define-config.ts +++ b/packages/core/utils/src/common/define-config.ts @@ -117,6 +117,13 @@ export function defineConfig(config: Partial = {}): ConfigModule { ...config.modules, } + // Remove any modules set to false + Object.keys(modules).forEach((key) => { + if (modules[key] === false) { + delete modules[key] + } + }) + return { projectConfig, featureFlags,