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

feature: bundle all modules #9324

Merged
merged 33 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e81be03
feat: bundle all modules
thetutlage Sep 26, 2024
9222e08
chore: add temporary import for debugging
thetutlage Sep 26, 2024
0acb431
chore: move test-utils to the top level of packages
thetutlage Sep 26, 2024
6d2e800
fix: ignore build errors when @medusajs/medusa hasn't been built
thetutlage Sep 26, 2024
ba26edf
refactor: use require over import
thetutlage Sep 26, 2024
2401132
fix: do not import files from dist directory
thetutlage Sep 26, 2024
cc30b97
Merge branch 'develop' into feat/bundle-modules
thetutlage Sep 26, 2024
a359c44
fix: import
thetutlage Sep 26, 2024
d7c2e6d
fix: more peer dependencies issues
thetutlage Sep 27, 2024
7c10aa9
chore: make ioredis and vite optional
thetutlage Sep 27, 2024
08341b7
chore: install express as part of framework,medusa and test-utils
thetutlage Sep 27, 2024
f3ba74a
Merge branch 'develop' into feat/bundle-modules
thetutlage Sep 27, 2024
1c37307
chore: update express version
thetutlage Sep 27, 2024
cff6ef0
chore: forward utils peer dependencies
thetutlage Sep 27, 2024
6fc0dbb
chore: add back ioredis to core-flows
thetutlage Sep 27, 2024
0c3bcac
fix: update modules path to match new modules
thetutlage Sep 27, 2024
eed8309
fix: modules default resolve path
thetutlage Sep 27, 2024
7b05d17
rewrite module loading resource resolving the discovery path
adrien2p Sep 27, 2024
4279dea
Merge branch 'develop' into feat/bundle-modules
adrien2p Sep 27, 2024
b89390f
Fix link modules resolution
adrien2p Sep 27, 2024
887088d
fix resolution
adrien2p Sep 27, 2024
1d80b4d
revert
adrien2p Sep 27, 2024
f31e0b0
fix import tests
adrien2p Sep 27, 2024
bdbd915
Merge branch 'develop' into feat/bundle-modules
adrien2p Sep 27, 2024
bf417de
Merge branch 'develop' into feat/bundle-modules
adrien2p Sep 27, 2024
241a976
Merge branch 'develop' into feat/bundle-modules
thetutlage Sep 27, 2024
e350d95
fix: install bignumber.js in utils and remove it as a peer
thetutlage Sep 27, 2024
76c4c57
chore: remove bignumber.js from integration tests
thetutlage Sep 27, 2024
cb3bc8c
feat: export coreflows from medusajs/medusa package
thetutlage Sep 27, 2024
a123b0c
fix: load internal to ignore import for links
thetutlage Sep 27, 2024
7452751
Merge branch 'develop' into feat/bundle-modules
thetutlage Sep 30, 2024
cad582a
refactor: give public import names to default exports
thetutlage Sep 30, 2024
4b39606
Merge branch 'develop' into feat/bundle-modules
adrien2p Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubscriberConfig } from "@medusajs/medusa/src"
import { SubscriberConfig } from "@medusajs/medusa"

const testEventPayloadHandlerMock = jest.fn()

Expand Down
1 change: 0 additions & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.1",
"bignumber.js": "^9.1.2",
"ioredis": "^5.4.1",
"pg": "^8.13.0",
"pg-god": "^1.0.12",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"workspaces": {
"packages": [
"packages/medusa",
"packages/medusa-test-utils",
"packages/modules/*",
"packages/modules/providers/*",
"packages/core/*",
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/admin-bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@medusajs/types": "^1.11.16",
"@types/compression": "^1.7.5",
"copyfiles": "^2.4.1",
"express": "^4.18.2",
"express": "^4.21.0",
"tsup": "^8.0.1",
"typescript": "^5.3.3"
},
Expand All @@ -37,7 +37,7 @@
"vite": "^5.2.11"
},
"peerDependencies": {
"express": "^4.18.2",
"express": "^4.21.0",
"react-dom": "^18.0.0"
},
"packageManager": "[email protected]"
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/medusa-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@
"author": "Sebastian Rindom",
"license": "MIT",
"devDependencies": {
"@mikro-orm/core": "5.9.7",
"@mikro-orm/knex": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"@swc/core": "^1.7.28",
"@swc/jest": "^0.2.36",
"@types/yargs": "^15.0.15",
"awilix": "^8.0.1",
"jest": "^29.7.0",
"pg": "^8.13.0",
"rimraf": "^5.0.1",
"typescript": "^5.6.2"
},
Expand All @@ -45,6 +51,7 @@
"configstore": "5.0.1",
"dotenv": "^16.4.5",
"execa": "^5.1.1",
"express": "^4.21.0",
"fs-exists-cached": "^1.0.0",
"fs-extra": "^10.0.0",
"glob": "^7.1.6",
Expand All @@ -63,5 +70,13 @@
"winston": "^3.8.2",
"yargs": "^15.3.1"
},
"peerDependencies": {
"@mikro-orm/core": "5.9.7",
"@mikro-orm/knex": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.1",
"pg": "^8.13.0"
},
"gitHead": "81a7ff73d012fda722f6e9ef0bd9ba0232d37808"
}
4 changes: 1 addition & 3 deletions packages/cli/medusa-cli/src/create-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ function buildLocalCommands(cli, isLocalProject) {
}

try {
const cmdPath = resolveCwd.silent(
`@medusajs/medusa/dist/commands/${command}`
)!
const cmdPath = resolveCwd.silent(`@medusajs/medusa/commands/${command}`)!
return require(cmdPath).default
} catch (err) {
console.error(err)
Expand Down
3 changes: 0 additions & 3 deletions packages/core/core-flows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
"@swc/core": "^1.7.28",
"@swc/jest": "^0.2.36",
"awilix": "^8.0.1",
"bignumber.js": "^9.1.2",
"cross-env": "^5.2.1",
"ioredis": "^5.4.1",
"jest": "^29.7.0",
"pg": "^8.13.0",
"rimraf": "^5.0.1",
Expand Down
16 changes: 11 additions & 5 deletions packages/core/framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"test": "jest --runInBand --bail --passWithNoTests --forceExit"
},
"devDependencies": {
"@medusajs/medusa-cli": "^1.3.22",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/knex": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
Expand All @@ -58,7 +59,6 @@
"@types/express": "^4.17.17",
"@types/jsonwebtoken": "^8.5.9",
"awilix": "^8.0.1",
"bignumber.js": "^9.1.2",
"ioredis": "^5.4.1",
"jest": "^29.7.0",
"pg": "^8.13.0",
Expand All @@ -68,7 +68,6 @@
"vite": "^5.2.11"
},
"dependencies": {
"@medusajs/medusa-cli": "^1.3.22",
"@medusajs/modules-sdk": "^1.12.11",
"@medusajs/orchestration": "^0.5.7",
"@medusajs/types": "^1.11.16",
Expand All @@ -78,23 +77,30 @@
"connect-redis": "5.2.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^4.18.2",
"express": "^4.21.0",
"express-session": "^1.17.3",
"ioredis": "^5.4.1",
"jsonwebtoken": "^9.0.2",
"medusa-telemetry": "^0.0.17",
"morgan": "^1.9.1",
"zod": "3.22.4"
},
"peerDependencies": {
"@medusajs/medusa-cli": "^1.3.22",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/knex": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.1",
"bignumber.js": "^9.1.2",
"ioredis": "^5.4.1",
"pg": "^8.13.0",
"vite": "^5.2.11"
},
"peerDependenciesMeta": {
"ioredis": {
"optional": true
},
"vite": {
"optional": true
}
}
}
3 changes: 0 additions & 3 deletions packages/core/medusa-test-utils/tsconfig.json

This file was deleted.

9 changes: 8 additions & 1 deletion packages/core/modules-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@
"devDependencies": {
"@mikro-orm/core": "5.9.7",
"@mikro-orm/knex": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"@swc/core": "^1.7.28",
"@swc/jest": "^0.2.36",
"awilix": "^8.0.1",
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"pg": "^8.13.0",
"rimraf": "^5.0.1",
"typescript": "^5.6.2"
},
Expand All @@ -50,6 +53,10 @@
"peerDependencies": {
"@mikro-orm/core": "5.9.7",
"@mikro-orm/knex": "5.9.7",
"awilix": "^8.0.1"
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.1",
"express": "^4.21.0",
"pg": "^8.13.0"
}
}
51 changes: 26 additions & 25 deletions packages/core/modules-sdk/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@ import {
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"

export const MODULE_PACKAGE_NAMES = {
[Modules.AUTH]: "@medusajs/auth",
[Modules.CACHE]: "@medusajs/cache-inmemory",
[Modules.CART]: "@medusajs/cart",
[Modules.CUSTOMER]: "@medusajs/customer",
[Modules.EVENT_BUS]: "@medusajs/event-bus-local",
[Modules.INVENTORY]: "@medusajs/inventory-next", // TODO: To be replaced when current `@medusajs/inventory` is deprecated
[Modules.LINK]: "@medusajs/link-modules",
[Modules.PAYMENT]: "@medusajs/payment",
[Modules.PRICING]: "@medusajs/pricing",
[Modules.PRODUCT]: "@medusajs/product",
[Modules.PROMOTION]: "@medusajs/promotion",
[Modules.SALES_CHANNEL]: "@medusajs/sales-channel",
[Modules.FULFILLMENT]: "@medusajs/fulfillment",
[Modules.STOCK_LOCATION]: "@medusajs/stock-location-next", // TODO: To be replaced when current `@medusajs/stock-location` is deprecated
[Modules.TAX]: "@medusajs/tax",
[Modules.USER]: "@medusajs/user",
[Modules.WORKFLOW_ENGINE]: "@medusajs/workflow-engine-inmemory",
[Modules.REGION]: "@medusajs/region",
[Modules.ORDER]: "@medusajs/order",
[Modules.API_KEY]: "@medusajs/api-key",
[Modules.STORE]: "@medusajs/store",
[Modules.CURRENCY]: "@medusajs/currency",
[Modules.FILE]: "@medusajs/file",
[Modules.NOTIFICATION]: "@medusajs/notification",
[Modules.INDEX]: "@medusajs/index",
[Modules.AUTH]: "@medusajs/medusa/modules/auth",
[Modules.CACHE]: "@medusajs/medusa/modules/cache-inmemory",
[Modules.CART]: "@medusajs/medusa/modules/cart",
[Modules.CUSTOMER]: "@medusajs/medusa/modules/customer",
[Modules.EVENT_BUS]: "@medusajs/medusa/modules/event-bus-local",
[Modules.INVENTORY]: "@medusajs/medusa/modules/inventory-next", // TODO: To be replaced when current `@medusajs/inventory` is deprecated
[Modules.LINK]: "@medusajs/medusa/modules/link-modules",
[Modules.PAYMENT]: "@medusajs/medusa/modules/payment",
[Modules.PRICING]: "@medusajs/medusa/modules/pricing",
[Modules.PRODUCT]: "@medusajs/medusa/modules/product",
[Modules.PROMOTION]: "@medusajs/medusa/modules/promotion",
[Modules.SALES_CHANNEL]: "@medusajs/medusa/modules/sales-channel",
[Modules.FULFILLMENT]: "@medusajs/medusa/modules/fulfillment",
[Modules.STOCK_LOCATION]: "@medusajs/medusa/modules/stock-location-next", // TODO: To be replaced when current `@medusajs/stock-location` is deprecated
[Modules.TAX]: "@medusajs/medusa/modules/tax",
[Modules.USER]: "@medusajs/medusa/modules/user",
[Modules.WORKFLOW_ENGINE]:
"@medusajs/medusa/modules/workflow-engine-inmemory",
[Modules.REGION]: "@medusajs/medusa/modules/region",
[Modules.ORDER]: "@medusajs/medusa/modules/order",
[Modules.API_KEY]: "@medusajs/medusa/modules/api-key",
[Modules.STORE]: "@medusajs/medusa/modules/store",
[Modules.CURRENCY]: "@medusajs/medusa/modules/currency",
[Modules.FILE]: "@medusajs/medusa/modules/file",
[Modules.NOTIFICATION]: "@medusajs/medusa/modules/notification",
[Modules.INDEX]: "@medusajs/medusa/modules/index-module",
}

export const ModulesDefinition: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ describe("load internal - load resources", () => {
(ModuleService.prototype as IModuleService).__joinerConfig
).toBeUndefined()

const resources = await loadResources(moduleResolution)
const resources = await loadResources({
moduleResolution,
discoveryPath: moduleResolution.resolutionPath as string,
})

expect(resources).toBeDefined()
expect(resources.services).toHaveLength(1)
Expand Down Expand Up @@ -115,7 +118,10 @@ describe("load internal - load resources", () => {
(ModuleService.prototype as IModuleService).__joinerConfig
).toBeUndefined()

const resources = await loadResources(moduleResolution)
const resources = await loadResources({
moduleResolution,
discoveryPath: moduleResolution.resolutionPath as string,
})

expect(resources).toBeDefined()
expect(resources.services).toHaveLength(1)
Expand Down Expand Up @@ -195,7 +201,10 @@ describe("load internal - load resources", () => {
(ModuleService.prototype as IModuleService).__joinerConfig
).toBeUndefined()

const resources = await loadResources(moduleResolution)
const resources = await loadResources({
moduleResolution,
discoveryPath: moduleResolution.resolutionPath as string,
})

expect(resources).toBeDefined()
expect(resources.services).toHaveLength(1)
Expand Down Expand Up @@ -274,7 +283,10 @@ describe("load internal - load resources", () => {
(ModuleService.prototype as IModuleService).__joinerConfig
).toBeDefined()

const resources = await loadResources(moduleResolution)
const resources = await loadResources({
moduleResolution,
discoveryPath: moduleResolution.resolutionPath as string,
})

expect(resources).toBeDefined()
expect(resources.services).toHaveLength(1)
Expand Down
Loading
Loading