feature: Add MikroORM CLI wrapper to bypass hardcoded module system (#9426)

FIXES: FRMW-2727

MikroORM (with version 5.9) has [hardcoded the TypeScript module](https://github.com/mikro-orm/mikro-orm/blob/5.x/packages/core/src/utils/ConfigurationLoader.ts#L138-L139) system to `commonjs`, which makes it incompatible with the module system we are using, ie `Node16`.

So, in order to continue using the Mikro ORM CLI within our modules, we will have to monkey-patch the block of code responsible for configuring `ts-node`. However, the monkey-patching must be done before their CLI gets booted.

As a result of this, we have to create a wrapper CLI on top of Mikro ORM CLI that performs the following steps.

- Monkey-patch the relevant code
- Register Mikro ORM CLI as the second step.

Due do this, we will have to use this new wrapper CLI within the modules, which is exposed as `medusa-db`. Maybe, `medusa-db` is not a great name, so please send your suggestions.
This commit is contained in:
Harminder Virk authored and GitHub committed 2024-10-03 04:51:20 +00:00
1 parent a94f30ba97
commit 2d1cf12dac
26 files changed
+196 -117

No files matched your search

+10 -2
View File
@@ -4571,7 +4571,7 @@ __metadata:
languageName: node
linkType: hard
"@jercle/yargonaut@npm:1.1.5":
"@jercle/yargonaut@npm:1.1.5, @jercle/yargonaut@npm:^1.1.5":
version: 1.1.5
resolution: "@jercle/yargonaut@npm:1.1.5"
dependencies:
@@ -5061,6 +5061,7 @@ __metadata:
resolution: "@medusajs/api-key@workspace:packages/modules/api-key"
dependencies:
"@medusajs/framework": ^0.0.1
"@mikro-orm/cli": 5.9.7
"@swc/core": ^1.7.28
"@swc/jest": ^0.2.36
jest: ^29.7.0
@@ -5428,6 +5429,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@medusajs/framework@workspace:packages/core/framework"
dependencies:
"@jercle/yargonaut": ^1.1.5
"@medusajs/medusa-cli": ^1.3.22
"@medusajs/modules-sdk": ^1.12.11
"@medusajs/orchestration": ^0.5.7
@@ -5457,11 +5459,13 @@ __metadata:
pg: ^8.13.0
rimraf: ^3.0.2
supertest: ^4.0.2
tsconfig-paths: ^4.2.0
typescript: ^5.6.2
vite: ^5.2.11
zod: 3.22.4
peerDependencies:
"@medusajs/medusa-cli": ^1.3.22
"@mikro-orm/cli": 5.9.7
"@mikro-orm/core": 5.9.7
"@mikro-orm/knex": 5.9.7
"@mikro-orm/migrations": 5.9.7
@@ -5471,10 +5475,14 @@ __metadata:
pg: ^8.13.0
vite: ^5.2.11
peerDependenciesMeta:
"@mikro-orm/cli":
optional: true
ioredis:
optional: true
vite:
optional: true
bin:
medusa-mikro-orm: ./dist/mikro-orm-cli/bin.js
languageName: unknown
linkType: soft
@@ -31291,7 +31299,7 @@ __metadata:
languageName: node
linkType: hard
"tsconfig-paths@npm:4.2.0":
"tsconfig-paths@npm:4.2.0, tsconfig-paths@npm:^4.2.0":
version: 4.2.0
resolution: "tsconfig-paths@npm:4.2.0"
dependencies: